50%

enhance-wiring

Goal

Finish the enhance-existing write path that was swept into HEAD unwired and untested, so a related duplicate folds into the existing bug.

Implementation Sketch

Deliver the enhance-wiring slice of the graph-native relatedness + dedup capability per the plan mission; ground every claim against the verified intel-graph facts in the overview.

Work Items

  • VERIFY-FIRST — the related_enhance branch in append_open_bug (added by s-6924d386’s dedup-verdict wiring, which runs before this section) may already call enhance_bug_entry as part of realizing its enhanced_existing exit_reason. Confirm the call is present, correctly threaded (bug_id, context, provenance), and relies on enhance_bug_entry’s own internal require_write_unlock call for the open-bugs unlock discipline (do NOT add a second unlock check in the wiring code). If the branch exists but does not yet call enhance_bug_entry, wire the call in. Import from the public scripts.plan_corpus.bug_tracker.api re-export — enhance_bug_entry moved to _field_setters_text.py under refactor e4ba1fb70; api.py keeps the import path valid via re-export, never import the private module path. Do NOT re-author enhance_bug_entry itself.
  • Test enhance_bug_entry’s genuinely-unpinned legs (test_write_choke_validation.py already pins the happy path at :235 and corrupted-entry rejection at :176 via e4ba1fb70 — do not re-duplicate those): the exact provenance-line format ([enhanced <provenance>] <context>, default provenance add-bug), idempotent noop when the line is already present in note, ApiError when bug_id is a closed or missing entry (closed-bug -> file new, not enhance), and BugTrackerLockError when no live open-bugs unlock is held (test_write_path_unlock.py currently has zero enhance_bug_entry coverage — this leg is unpinned today). Extend the existing _bug/_seed_open_direct fixtures and the autouse unlock fixture rather than inventing a new fixture path. Also exercise the wired related_enhance path end-to-end through the real python -m scripts.add_bug_runtime append production CLI entry point, not only a seam-injected direct enhance_bug_entry(...) call.
  • Resolve the public extractor wrappers tokenize_words/extract_paths (verified already dead today: zero callers of the public names anywhere in the repo, production or test — relatedness.py’s own dispatch logic calls the private _tokenize_words/_extract_paths directly, and the wrappers exist in TWO public surfaces: signals.py:360-376 canonical, plus relatedness.py’s all re-export). If section 02 (relatedness-graph-rewrite) and every other consuming section land with no genuine external consumer of the public names, delete both the wrapper functions and the relatedness.py re-export. Otherwise collapse to ONE public home (signals.py; relatedness.py’s re-export is documented as a transitional shim) and add a dedicated wrapper-contract test for the surviving surface. No uncalled dead scaffolding and no duplicate public surface left behind.

Fresh intel (regenerated)

VERDICT: enhance-wiring is a pure Python-tooling section whose CODE terrain is structurally invisible to the code-symbol graph (the ori repo indexes compiler_repo/ Rust + .ori only — 0 Python symbols, verified), but whose SUBSTRATE — the related-nodes graph query the whole plan rides on — is live and was probed end-to-end this session. Three decisive facts the section’s work inherits:

  1. enhance_bug_entry is real, tested-at-the-choke, and UNCALLED. It lives at scripts/plan_corpus/bug_tracker/_field_setters_text.py:142 (moved out of api.py by the e4ba1fb70 module split; originally swept in at e559cc38 under an unrelated BUG-04-139 commit, verified via git show). grep confirms zero production callers; the literal related_enhance branch it documents exists ONLY in docstrings (_field_setters_text.py:151, _result_types.py:80) — no verdict enum, no branch in append_open_bug, and NO bug_dedup.py anywhere. The wiring target (bug_tracker_io.py:append_open_bug) currently has exactly two paths: redirect-on-signals or append.
  2. [JOIN] The verdict layer this wiring consumes does not exist yet, and the walk order says that is fine. dag-ascii order: s-f7b5e470 (related-nodes query, in-progress in the graph snapshot) -> s-c7999cd5 (relatedness-graph-rewrite) -> s-6924d386 (bug-dedup-module) -> s-d35ea8d5 (THIS) -> skill-surface -> tests-and-docs -> 4 plan-side twins. enhance-wiring runs AFTER bug-dedup-module delivers the related_enhance verdict. The section’s job is the WRITE leg only: branch append_open_bug on the dedup verdict -> call enhance_bug_entry under the open-bugs unlock. Re-authoring verdict logic here is cross-section scope bleed.
  3. [JOIN] The live related-nodes probe exposes the exact failure mode the downstream branch must gate against. Probed live: plain-English text returns count: 0 (the input_refs-empty short-circuit at query_graph.py:2666 fires BEFORE the fulltext leg — only backtick/error-code-bearing text ranks at all), while backticked text returns hits that (a) include CLOSED bugs (resolved/obe rows returned), and (b) rank on common-English title tokens (an unrelated typeck bug outranked genuine tracker-family bugs). enhance_bug_entry’s open-entry-only ApiError is therefore the LAST-LINE guard, not a corner case — the w-e85ae8eb closed-bug test is load-bearing, and the upstream verdict (s-6924d386 scope) must gate on score/status, never count>0.

Decisions forced before work: (a) treat w-137a5f98 as verify-first wiring of an existing function — the plan-fold already says “do NOT re-author”; (b) w-e85ae8eb’s matrix must SUBTRACT what already landed — test_write_choke_validation.py (e4ba1fb70) already pins the happy path + corrupted-entry rejection; the genuinely-unpinned legs are provenance-line format, idempotent noop, closed/missing-id ApiError, and the no-unlock BugTrackerLockError (test_write_path_unlock.py has zero enhance coverage — verified); (c) w-3f100236’s wrapper disposition: tokenize_words/extract_paths now live canonically in signals.py with relatedness.py re-exporting them — importer inventory shows only in-package tests + __main__.py/api.py/bug_tracker_io.py consumers, none of which import the two wrappers by name from outside the package.


(full dossier: enhance-wiring—s-d35ea8d5.intel.md)