Skip to content

chore: remove stale scaffolding and correct comments - #169

Merged
abogartz merged 3 commits into
abogartz:mainfrom
WhollyMindless:chore/stale-scaffolding
Oct 29, 2026
Merged

abogartz merged 3 commits into
abogartz:mainfrom
WhollyMindless:chore/stale-scaffolding

Conversation

@WhollyMindless

@WhollyMindless WhollyMindless commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Unused declarations and stale comments make the current paths harder to follow. This removes unused production imports, the unused CaptureOptions/CaptureDeps interfaces and unused members of the local host interface, and the unreachable .d.ts ranking branch.

Comments now describe markdown command installation, the current session hooks, and observed turn-end capture events. The event-fidelity requirement and concurrency/lock-ordering explanations are retained. No runtime behavior change is intended.

This is an independently mergeable cleanup. It leaves the architectural choices in #167 and #168 open.

Validation:

  • bun run gate: typecheck and lint passed; existing lint warnings remain.
  • Unit tests: 620 passed, 12 skipped (the same skips as the baseline).
  • Real-host end-to-end tests: 11 passed.

@abogartz abogartz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE — cleanup is real, inert, and the comment fixes are accurate

Reviewed at head 913adc0 (merge-base e32327a / v0.14.17) on macOS, Bun 1.4.3, plus a merge worktree against current main 20bb57e (v0.14.18) so a semantic conflict with #158 could not hide behind mergeable=CLEAN.

Every claim below was checked against the tree, not the body.

1. "No runtime behavior change" — verified, not assumed

I transpiled all six changed files with Bun's own TS transpiler (the loader the host uses) and byte-compared base vs head, then compared again with comments stripped:

file emitted JS
src/triggers.ts byte-identical (comment-only change)
src/capture.ts src/gates.ts src/index.ts src/inject.ts differ only in the removed import specifiers
src/resolver.ts differs only in the removed rank += 1000

There are no statement, order, or expression changes. The only theoretical hazard is that deleting an import changes module-load side effects: src/types.ts is two export const arrays and nothing else, and it is still imported by src/schema.ts:18, src/portable.ts:22, src/capture.ts:7 — so index.ts dropping its line cannot change what executes.

2. The removals are machine-verified unused, and complete for src/

bunx biome lint --max-diagnostics=100000 on base vs head, grouped per file — the diff is exactly five diagnostics, all lint/correctness/noUnusedImports:

src/capture.ts  1 -> 0    src/gates.ts 1 -> 0    src/index.ts 2 -> 0    src/inject.ts 1 -> 0
Found 397 warnings -> Found 392 warnings;  no rule gained a warning anywhere

I also confirmed each by grep in the merged tree: loadAll has zero occurrences left in src/gates.ts, and STATUSES/TYPES/isVisibleHere/visibleTo zero in src/index.ts (visibleTo lives on in inject.ts/schema.ts, where it is still used). Base src/index.ts:16 was the types.ts import and TYPES/STATUSES appeared nowhere else in that file.

CaptureOptions / CaptureDeps: zero references in any tracked file type on head, zero in test/, e2e/, bench/, and zero in my untracked local bench/live-capture-audit.ts. Not a public-surface change either — package.json exports exposes only . and ./tui, so no consumer can import src/capture.ts by subpath.

PluginCtx.command / session.prompt: the only surviving trace of the host command API on base was prose (src/index.ts:8 on main), not a call site, and session.prompt now exists solely as the guarded("session.prompt (inject)") label at src/index.ts:1614 — the hook is registered through ctx.session.hook("prompt"), whose typing is untouched. ctx.command = 0 hits on head, and "command" in ctx style capability probing appears nowhere.

3. The dead .d.ts branch is provably dead, and the new comment is the true one

relRank returns Infinity at resolver.ts:244 on the same predicate rel.endsWith(".d.ts") two lines above the rank += 1000 it deletes, so that line was unreachable. Worth noting the rewritten comment's word "excludes" is now correct and was worth checking: buildTreeIndex drops non-finite ranks at resolver.ts:301 (.filter((f) => relRank(f) < Infinity)), so .d.ts, node_modules and VCS dirs never reach the sort at 348/350 — they are excluded, not merely deprioritised.

4. Every rewritten comment was fact-checked (this is the part that could have gone wrong)

  • Event fidelity block (index.ts:217-232). "test/event-fidelity.test.ts requires every trigger to appear in both that recording and the installed @opencode/schema manifest" — true: two separate tests assert CAPTURE_EVENT_TYPES ⊆ declaredSet and ⊆ observed, plus controls proving both sources parsed. The three named non-triggers are exactly as described — session.idle, session.status, session.execution.failed each appear in node_modules/@opencode/schema/dist/event-manifest.d.ts and each appear 0 times in test/fixtures/host-events.jsonl, while both triggers appear once. The compression keeps the load-bearing rule (a trigger requires a recording) and the status-needs-idle-filtering caveat.
  • src/command.ts claim — true, and it corrects a live falsehood: src/command.ts mirrors command/<name>.md into commandsDir() and index.ts:52/:276 call ensureInitCommand/ensureMemoryReportCommand; nothing registers a command through the host.
  • triggers.ts:267 "Called from the session prompt hook" — true: checkNewSession is called at index.ts:1389, inside ctx.session?.hook("prompt", …) registered at :1382.
  • inject.ts header — "relevance-ranked memory frozen per epoch by src/index.ts" and "ride the session context hook's system parts" match index.ts:1323-1376 (hook("context") → event.system.push), and "contextual pull appends relevant memory to grep/glob/read results" matches inject.ts:454 (if (!["grep","glob","read"].includes(tool)) return []).
  • "see the note on plugin" still resolves — the type-only-import note is intact at index.ts:1723-1732.

5. Gates

Body claims reproduced on head: unit = 620 pass / 12 skip / 0 fail (I ran bun test ./test/ at 913adc0); typecheck + lint exit 0. I ran the e2e leg on the merged tree rather than re-running it on head — head's own run is the CI test/smoke legs, which are green. Merged tree (main 20bb57e + this) full bun run gate: all green, tsc + biome + unit 644 pass / 12 skip / 0 fail + e2e 11 pass / 0 fail — i.e. no test-count drift against #158, so nothing here was quietly unpinned. CI's four legs are green on this head.


Non-blocking nits

N1 — src/types.ts:1-4 is now stale in exactly the way this PR fixes elsewhere. It still reads "index.ts feeds these into the tool JSON Schemas; capture.ts uses them to prompt and validate." After this branch deletes index.ts's last import of the module, the enums reach the schemas via src/schema.ts:18 (consumed at schema.ts:57 and :96), STATUSES has no other consumer than schema.ts, and capture.ts uses only TYPES (:50 prompt, :64/:122 validation). One-line rewrite to name schema.ts would make the header true again — and this PR is the change that makes the current sentence demonstrably false, which is why I am raising it here rather than as a new issue.

N2 — the same rule still flags the test tree: 15 unused imports (test/convergence.test.ts:18, test/frontier.test.ts:16,22, test/gated-injection.test.ts:20,21,25, test/helpers/scripted.ts:18, test/realrepo.test.ts:8,9,13,17, test/security-capture-crop.test.ts:10, test/security-evidence-path.test.ts:11,18, test/status.test.ts:18), all noUnusedImports, all FIXABLE. Your body says "unused production imports", so this is not a discrepancy — just noting the cleanup is one-sided and a bunx biome lint --write-able follow-up exists. I would not widen this PR for it.

Nothing in the diff removes coverage: no test or e2e file references any removed symbol or any removed prose (grep for V1 port, CaptureOptions, CaptureDeps, tiny-digest, relRank across test/ and e2e/ returns nothing), so no pinned invariant depended on the scaffolding.

@abogartz
abogartz merged commit 657a758 into abogartz:main Oct 29, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.14.19 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants