You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 886f6eb
Browse filesBrowse the repository at this point in the historyBrowse files
fix: close council audit findings on budget derivation
Addresses all 8 actionable findings from the solo Athena council audit of
the prior two commits (emergency drop bypass + budget derivation).
- #1 (unanimous, MEDIUM): `historianChunkTokens` was cached once per hook
while RPC/TUI re-derived fresh on each invocation. Same trigger could
produce different chunk sizes depending on source. Unified by turning
the hook's value into a `getHistorianChunkTokens` thunk called at each
historian spawn site.
- #2 + #8 (MEDIUM + LOW): `modelContextLimitsCache` was never populated in
production. Removed the dead field from `MagicContextDeps.config`,
`EventHandlerDeps.config`, `resolveContextLimit`, and
`resolveHistorianContextLimit`. Context limits are resolved through
`getModelsDevContextLimit` which already reads both models.dev cache
and custom `provider.*.models.*.limit.context` from opencode.json.
Dropped the unsafe `(config as { modelContextLimitsCache? }).X` casts
in rpc-handlers.ts and tui-action-consumer.ts.
- #3 (MEDIUM, latent coupling): `shouldApplyPendingOps` only bypassed the
`!compartmentRunning` gate but still required `scheduler==="execute"`.
If `MAX_EXECUTE_THRESHOLD` were ever raised above 85%, heuristic
cleanup would fire at emergency threshold while pending ops silently
stopped materializing. Added `forceMaterialization` to the first
clause so the emergency bypass is self-sufficient.
- #4 (MAJORITY, MEDIUM): `pickHistorianModelKey` returned only the first
fallback chain entry, silently ignoring malformed (provider-less)
overrides. Rewrote `resolveHistorianContextLimit` to:
- use an explicit `provider/model` override as-is;
- warn and fall through for provider-less overrides (never silently
pick a wrong default);
- scan the full expanded fallback chain and use the MINIMUM resolved
context, protecting against OpenCode falling back to a
smaller-context entry.
- #7 (LOW, clarity): Comment on the emergency bypass overstated safety
as "SQLite WAL-safe." Actual safety comes from disjoint databases
(historian reads opencode.db, drops write context.db). Rewrote the
comment to reflect the true invariant plus
`queueDropsForCompartmentalizedMessages` idempotency.
Also tightened the pending-op read gate to include `forceMaterialization`
so queued ops are visible during emergency bypass even if the scheduler
returned "defer" in edge configurations.
Tests:
- Removed in-test `modelContextLimitsCache` fixtures from
`event-resolvers.test.ts` and `event-handler.test.ts` (no longer part
of the API).
- Added three targeted tests for `resolveHistorianContextLimit`
(no-override chain scan, explicit override, provider-less warn+fallthrough).
- Made `TransformDeps.getHistorianChunkTokens` optional with a 20K default
so existing tests keep working without explicit threading.
Verified: 479 plugin tests pass, 13 e2e tests pass, typecheck clean.
0 commit comments