def pending_key(repo_path: str) -> str:
"""THE HOOK COMPUTES THIS TOO, from `CLAUDE_PROJECT_DIR` (`clew_hook._comment_key`), so both
resolve the path the same way; a test pins that the two agree.
@brief Pending key.
@return Key.
"""
return hashlib.sha256(os.path.realpath(repo_path).encode("utf-8")).hexdigest()[:16]
comments.py¶
clew/mcp_server/comments.pyWiki comments: what a person writes on a served page, kept for the agent (2.1, owner Q/A).
_eventsThe log's events, in order; an unreadable line is skipped.
clew/mcp_server/comments.py:165
Show on the map →
Called by all
Calls none
Source · 12 lines
def _events(self) -> list[dict[str, Any]]: """@brief Events. @return List.""" if not self.path.is_file(): return [] events = [] for line in self.path.read_text(encoding="utf-8").splitlines(): try: events.append(json.loads(line)) except json.JSONDecodeError: continue return eventsActivity · 9 steps
Flows
main(clew/guard/main.py)main(clew/cli.py)clew-first-build-—_first_build_worker(clew/mcp_server/server.py)_publicA stored event's public fields.
clew/mcp_server/comments.py:220
Show on the map →
Called by add, all
Calls none
Source · 3 lines
def _public(event: dict[str, Any]) -> dict[str, Any]: """@brief Public fields. @return Dict.""" return {k: event[k] for k in ("id", "at", "page", "anchor", "quote", "body")}1 more lines, not shown
Activity · 1 steps
Flows
main(clew/guard/main.py)main(clew/cli.py)clew-first-build-—_first_build_worker(clew/mcp_server/server.py)addRecord a comment.
clew/mcp_server/comments.py:95
Show on the map →
Called by none
Calls
_append,_check, _public,_write_pendingSource · 21 lines
def add(self, page: str, anchor: str, quote: str, body: str) -> dict[str, Any]: """REFUSED, NEVER CUT: an empty body or a field over its limit raises ValueError naming it. @brief Add a comment. @return The comment. """ _check(body, page, anchor, quote) record = { "op": "add", "id": secrets.token_hex(6), "at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), "page": page, "anchor": anchor, "quote": quote, "body": body, } with _LOCK: self._append(record) self._write_pending() return {**_public(record), "status": "new"}Activity · 6 steps
Requirements
REQ-DDB-WIKI-054
allEvery comment, oldest first, with its status.
clew/mcp_server/comments.py:132
Show on the map →
Called by
_accepted,_apply, _bounded_output,_checked_blocking, _checked_list_section, _class_side_is_only_enum_mirrors,_comment_fields, _comments,_components, _derives_from_py_enum, _edge_defaults,_insert_recovered_macro15 more
_is_flat_req_list,_joined,_one_class,_prepare,_receiver_module, _recover_class_fields_into,_recover_into, _sbom, _string_list, _strings,_tier, flowchart_section, read_key_list, reconcile, unreadTested by
61 tests
test_a_bare_term_finds_the_files_containing_it, test_a_call_to_an_overridden_endpoint_is_annotated_with_its_implementors, test_a_comment_is_pushed_as_a_channel_notification, test_a_config_symbols_own_gates_carry_the_resolved_default, test_a_declared_root_outside_the_repository_is_refused, test_a_measured_link_carries_its_extent, test_a_non_virtual_function_gets_no_override_fields, test_a_real_build_records_a_breakdown_covering_every_stage, test_a_runtime_is_enabled_branch_is_not_a_gate, test_a_session_ignoring_the_index_is_escalated, test_a_step_brief_is_plain_text_and_the_home_card_counts_every_flow, test_a_steps_dialog_carries_its_recorded_values49 more
test_an_ambiguous_call_without_a_selector_behaves_as_before, test_an_audience_can_redact_owners, test_an_index_without_the_relation_degrades_to_empty, test_an_oversized_reply_compacts_the_message_but_keeps_the_axis, test_c_binding_edge_is_resolved_and_never_exact, test_callees_merge_dataflow_tagged_as_key_not_call, test_chain_trace_records_what_the_fanout_taper_dropped, test_clew_documents_itself_with_its_own_wiki, test_dossier_does_not_double_report_dataflow, test_dot_flows_are_balanced_digraphs, test_each_assertion_is_a_diamond_failing_into_its_mode, test_each_file_is_one_slice_of_its_block, test_every_block_is_a_wedge_and_wedges_do_not_overlap, test_every_test_s_slice_of_a_flow_comes_from_one_pass_over_its_steps, test_extracting_items_that_match_no_member_is_refused, test_flows_past_the_cap_open_in_a_details, test_grading_appends_a_pass_history, test_harvested_sites_carry_provenance, test_inherited_members_do_not_pair_the_interface_with_itself, test_lens_facts_ride_on_components_and_absent_sources_stay_absent, test_list_files_pattern_is_a_glob_over_path_or_filename, test_mermaid_flows_are_sequence_diagrams, test_n_dossiers_share_the_budget_instead_of_each_claiming_it, test_neighbours_past_the_cap_open_in_a_details, test_no_successor_has_appeared_for_roots_on_the_modern_revisions, test_out_of_line_constructor, test_python_binding_edge_is_resolved_and_never_exact, test_python_definitions_are_recovered_with_class_qualification, test_python_self_qualified_call_is_member_provenance, test_query_surface_invariants_hold_on_real_data, test_registration_site_is_harvested_but_is_not_itself_a_call_edge, test_requirement_traceability_state_is_known, test_search_prose_returns_a_snippet, test_set_scoring_counts_members_and_precision, test_submodules_and_clones_both_become_sub_indexes, test_test_code_is_a_lens_not_a_box, test_test_files_and_common_keys_are_left_out, test_text_escalates_and_never_repeats, test_the_chain_loses_its_outermost_ring_before_a_neighbour_list_is_trimmed, test_the_dossier_names_the_callees_the_index_cannot_resolve, test_the_five_strength_vocabularies_are_distinct_objects, test_the_override_fields_reach_the_mcp_wire, test_the_payload_keeps_the_shape_the_folder_reads, test_the_prose_corpus_returns_snippets, test_the_site_has_an_architecture_tab, test_the_view_strip_has_every_view_in_order, test_udm_default_is_unresolved_not_absent, test_vote_records_the_reason_each_attempt_failed, test_with_nothing_declared_blocks_are_packagesCalls _events,
_events, _public, listSource · 10 lines
def all(self) -> list[dict[str, Any]]: """@brief All comments. @return List.""" comments: dict[str, dict[str, Any]] = {} for event in self._events(): if event.get("op") == "add": comments[event["id"]] = {**_public(event), "status": "new"} elif event.get("op") == "read" and event.get("id") in comments: comments[event["id"]]["status"] = "read" return list(comments.values())Activity · 7 steps
Requirements
REQ-DDB-WIKI-054
Flows
main(clew/guard/main.py)main(clew/cli.py)clew-first-build-—_first_build_worker(clew/mcp_server/server.py)for_repoThe store for one repository.
clew/mcp_server/comments.py:81
Show on the map →
Called by none
Calls pending_key
Source · 6 lines
def for_repo(cls, state_root: Path, repo_path: str, counted: bool = True) -> CommentStore: """@brief Locate a repository's store. @return Store.""" key = pending_key(repo_path) root = Path(state_root) return cls(root / LOG_DIR / f"{key}.jsonl", root / PENDING_DIR / key, counted)Activity · 3 steps
Requirements
REQ-DDB-WIKI-054
mark_readMark comments read (they stay in the log).
clew/mcp_server/comments.py:121
Show on the map →
Called by none
Calls
_append,_write_pendingSource · 7 lines
def mark_read(self, ids: list[str]) -> None: """@brief Mark read. @return None.""" with _LOCK: for cid in ids: self._append({"op": "read", "id": cid}) self._write_pending()Activity · 4 steps
Requirements
REQ-DDB-WIKI-054
pending_keyThe pending-count file's name for a repository: a hash of its resolved path.
clew/mcp_server/comments.py:51
Show on the map →
Called by
_comment_env, for_repoTested by
5 tests
test_a_repository_that_chose_the_channel_has_its_comments_pushed, test_by_default_a_comment_is_counted_for_the_hook_and_not_pushed, test_the_hook_and_the_store_share_the_pending_key, test_the_pending_count_is_a_file_the_hook_can_read, test_the_pending_key_is_the_resolved_repository_pathCalls none
Source · 10 lines
def pending_key(repo_path: str) -> str: """THE HOOK COMPUTES THIS TOO, from `CLAUDE_PROJECT_DIR` (`clew_hook._comment_key`), so both resolve the path the same way; a test pins that the two agree. @brief Pending key. @return Key. """ return hashlib.sha256(os.path.realpath(repo_path).encode("utf-8")).hexdigest()[:16]Activity · 1 steps
Requirements
REQ-DDB-WIKI-054
unreadThe comments not yet read, oldest first.
clew/mcp_server/comments.py:146
Show on the map →
Called by
_write_pendingCalls all
Source · 4 lines
def unread(self) -> list[dict[str, Any]]: """@brief Unread comments. @return List.""" return [c for c in self.all() if c["status"] == "new"]Activity · 1 steps
Requirements
REQ-DDB-WIKI-054