Repository navigation
Description
Would you find a staged, behavior-preserving separation of responsibilities in src/index.ts useful?
Maintenance benefit
The reviewed v0.14.17 entry point is about 1,770 lines. Length alone is not the concern: one setup closure combines host compatibility, session identity, tool workflows, injection-cache policy, status assembly, and capture scheduling. Understanding a change to one policy requires following shared closure state and callbacks across those other responsibilities.
There are already useful foundations to preserve, including schema.ts, SessionLru, the shared resolver tree, and the existing regression suites.
Possible boundaries
These are options for discussion, not a prescribed directory layout or a request to extract everything:
- Injection epochs: own the epoch/prompt state, eviction, rendering, refresh decisions, and compaction invalidation.
- Host adaptation and session identity: normalize supported event shapes and expose explicit per-call identity.
- Tool registration and workflows: keep schemas and descriptions near their handlers, with explicit dependencies instead of access to the entire setup closure.
- Auto-capture scheduling: own trigger eligibility, cooldowns, subscription cleanup, and dispatch to the existing capture/gate helpers.
- Status assembly: share store-summary calculations between the chat report and status payload.
Suggested first step
If the direction fits, the epoch section looks like a coherent first extraction. Its interface could handle prompt updates, context delivery, compaction, and status inspection, leaving setup to wire it to the host. The important benefit would be making the cache policy readable in one place with its dependencies explicit.
Keep that as one independently reviewable PR. Other extractions could be accepted, deferred, or dropped separately. Coordinate with active work touching index.ts, especially #158; no existing fix should wait on this reorganization.
Boundaries and verification
Preserve tool schemas and responses, repository visibility, lock ordering, capture defaults, and the exact injected bytes/invalidation behavior, including #162/#165. Keep the current lifetime of process-shared cooldown state; moving it into an instance would change behavior. Preserve the existing hook-level regressions and run the project's checks. This proposal makes no performance claim and needs no new framework or dependency.
Which, if any, of these boundaries would make the project easier for you to maintain? A smaller extraction or keeping the current arrangement are both reasonable choices. No implementation is attached; this issue is for your direction on scope and timing.
The separate, smaller gate-outcome typing proposal is #167; neither proposal depends on accepting the other.
Activity
WhollyMindless commentedon Oct 29, 2026
I am taking the suggested injection-epoch boundary as a separate, optional PR. #170 already covers host compatibility parsing, so this extraction will preserve that event-listener wiring and leave session identity, tool workflows, and capture scheduling in setup. I will check a combined tree with #158, #169, #170, and #171 before posting. This is one stage of the proposal, not an attempt to close the broader design discussion.
WhollyMindless commentedon Oct 31, 2026
Additional evidence for the existing Status assembly part of this proposal, from the review of main
bf9f4d233064c0594834c44d72648ac532ff13e8(ARCH-2):memory_statusinsrc/index.ts(around 1258–1283) recomputes store summaries afterbuildPayloadinsrc/injection-epochs.ts(around 103–131) already performs corresponding work. The reviewed path has two loadAll/readLedger passes and duplicated summary logic. This supports sharing a summary calculation if that extraction is still useful; it does not justify another issue for the same refactor.Please keep the visibility-policy decision separate: #213 asks whether blocked-write details and aggregate store counts should be repository-scoped. A behavior-preserving extraction should preserve today's semantics until that decision is made, or explicitly implement the accepted policy with regression coverage.
This is evidence for your consideration, not a claim or implementation reservation. Happy to leave the arrangement as-is or take a narrower approved step.
abogartz commentedon Nov 1, 2026
The architecture review synthesis (2026-11-01) promotes this proposal to consensus High: both independent reviewers reached the same conclusion without consulting each other (2026-10-31 finding O1; 2026-11-01 finding S1). Verified at
2a2cb92: 1,739 lines, 14 inline tool registrations, and thememory_updatehandler alone spans roughly lines 551-872.The layout both reviews converged on: one module per tool under
src/tools/exporting name + schema + handler;src/events.tsfor the six event hooks;src/index.tsreduced to the composition root that lists them; the sharedguarded/gateContextclosures (src/index.ts:286,:294) moved into an exported helper so handlers stay independent of plugin wiring.Execution notes: incremental, one tool per commit - the 15.7-second unit suite makes this refactor cheap. Start after #241 (characterization e2e matrix) lands: this split moves exactly the registration and wiring paths that today only five of fourteen tools exercise on a real host.
Severity label updated from low to high.
abogartz commentedon Nov 1, 2026
Taking the staged split, starting with the epoch section as the first independently reviewable PR. #243 (merged) is the acceptance net; the #162/#165 byte-stability tests are the oracle. Freeze rule applies: PRs touching src/index.ts rebase onto each landed extraction, not vice versa. Steps: epochs -> capture scheduling -> per-tool registration -> host/session identity -> status assembly.
abogartz commentedon Nov 1, 2026
The agreed architecture landed as a staged pair:
src/tools/, entry 1739→866).src/(stacked on refactor(tools): split the tool registration block into src/tools modules (#168) #247): core/, store/, gate/, identity/, inject/, recall/, hits/, evidence/, consolidate/, capture/, portable/, init/, command/, status/, tools/, viewer/, tui/. Grab-bags split: memory.ts → store/model + store/files; inject.ts → inject/ + recall/; status.ts, portable.ts, config.ts, logfmt.ts, capture.ts, init.ts, consolidate.ts, tombstones.ts → concept files.Behavior-preserving: declaration bodies verbatim; unit 842/0 and e2e 30/0 identically on the restructured tree. The PR body encodes the folder rules in machine-processable form for reconcile tooling. #220 (
runWriteGateverdict decomposition) now has its home —gate/gate.ts— and follows as its own PR.Reconcile rule: while #247/#248 are open, PRs touching src/ rebase onto #248, not the reverse.
fix(sweep): re-anchor the mutant catalog onto the domain folders (#168)
refactor(src): restructure the flat src/ tree into domain folders (#168)
fix(sweep): re-anchor the mutant catalog onto the domain folders (#168)
refactor(src): restructure the flat src/ tree into domain folders (#168)
fix(sweep): re-anchor the mutant catalog onto the domain folders (#168)
Merge pull request #247 from abogartz/refactor/tool-registry
7 remaining items
WhollyMindless commentedon Nov 3, 2026
Second remaining slice is ready in #265: per-setup session binding and call-context helpers extracted into src/identity/session-context.ts. The moved block matches base after indentation normalization. Existing identity regressions pass 31/31 on Windows and Linux; full Windows gate passes (862 unit tests, 26 skips; 30/30 E2E). This is standalone from main and does not depend on #261. Capture/hook orchestration remains the later stage; automation labels unchanged. Please feel free to defer, narrow or reject.
WhollyMindless commentedon Nov 3, 2026
The identity slice (#265) is approved with no requested changes. Claiming the capture-orchestration part of the final stage as a separate PR: move capture configuration, subscriptions and dispatch behind explicit dependencies while preserving process-wide cooldowns and existing cleanup behavior (#211 remains separate). Hook registration will remain a subsequent smaller extraction so each diff stays reviewable. No competing automation claim or overlapping open capture PR is present; labels will remain untouched.
WhollyMindless commentedon Nov 3, 2026
Capture orchestration is ready in #266. Cooldowns stay process-wide, existing capture exports remain available, and cleanup behavior is preserved (#211 stays separate). Focused capture suites pass 59/59 on Windows and Linux; full Windows gate passes (862 unit tests, 26 skips; 30/30 E2E). The governed-path assertion follows the moved gate call and was verified to fail when that call is removed. Hook registration and the generic guard remain the final smaller slice after guidance or merge. No automation labels changed; feel free to defer, narrow or reject.
WhollyMindless commentedon Nov 3, 2026
Capture orchestration (#266) is approved; its cosmetic trailing-newline nit is fixed. Claiming the final smaller slice: hook registration, the measured-usage subscription, shared runtime context types and the generic fail-soft hook guard. I will preserve registration order, synchronous caller binding, the live compaction-capture seam, and cleanup ownership. No competing claim or overlapping hook PR is present; automation labels remain untouched.
WhollyMindless commentedon Nov 3, 2026
Final planned hook-registration slice is ready in #267: src/events.ts owns hook registration and measured usage; core modules hold the structural host types and fail-soft guard. Setup retains cleanup ownership and supplies a live compaction-capture callback lookup. Existing assertions are unchanged. Focused suites pass 65/65 on Windows/Linux; full Windows gate passes (862 unit tests, 26 skips; 30/30 E2E). Together #261, #265, #266 and #267 cover the remaining checklist; keep #168 open until they are merged/reconciled. I will maintain compatibility as main advances. Automation labels unchanged; feel free to defer or reject.
Merge pull request #261 from WhollyMindless/refactor/168-status-summary
abogartz-opencode-self-improvement commentedon Nov 3, 2026
🎉 This issue has been resolved in version 0.15.12 🎉
The release is available on:
Your semantic-release bot 📦🚀
Merge pull request #265 from WhollyMindless/refactor/168-session-context
Merge pull request #266 from WhollyMindless/refactor/168-capture-runtime
Merge pull request #267 from WhollyMindless/refactor/168-hook-registr…
abogartz-opencode-self-improvement commentedon Nov 3, 2026
🎉 This issue has been resolved in version 0.15.13 🎉
The release is available on:
Your semantic-release bot 📦🚀
docs(bench): make the append-publication regeneration recipe actually…
chore(hygiene): retire single-issue bench fossils and ignore research…