Skip to content

feat(opencode-v2): port compaction ownership, destructive policy, step usage from #1194 - #2

Closed
Scratchydisk wants to merge 2 commits into
mainfrom
feat/v2-compaction-port
Closed

Scratchydisk wants to merge 2 commits into
mainfrom
feat/v2-compaction-port

Conversation

@Scratchydisk

Copy link
Copy Markdown
Owner

Ports the separable pieces of mksglu#1194 onto our monolithic V2 setup (no core.ts restructure, no target-axis):

  • Compaction ownership: options.compaction (own default / passthrough|host). Own mode sets event.result={summary} so the host skips model summarization (zero LLM calls).
  • Destructive-tool policy: ctx_purge/ctx_upgrade refuse unless CONTEXT_MODE_ALLOW_DESTRUCTIVE=1.
  • v2-native usage capture: session.step.started/ended correlation via new parseOpencodeV2StepUsage(); message.updated kept as fallback.
  • Docs: OpenCode 2 section in platform-support.md + opencode-v2.json template. session-extract bundle synced.

Verification: 12 new tests (targeted suites 140 passed, typecheck clean) + live sessions on real opencode 2.0.12 (ctx_stats end-to-end, ctx_purge refusal, StepEnded rows, zero load errors). Full suite has 33 pre-existing failures in hooks/session bundles, reproduced on clean tree.

…p usage from mksglu#1194

Ports the separable pieces of mksglu#1194 onto our monolithic
V2 setup (no core.ts restructure, no target-axis):

- Compaction ownership: resolveCompactionMode() reads options.compaction
  ('own' default, 'passthrough'/'host' alias). Own mode sets
  event.result={summary} so the host skips model summarization (zero LLM
  calls); passthrough leaves result unset while still persisting the
  snapshot for cross-session resume. Empty snapshot: unset either way.
- Destructive-tool policy: ctx_purge/ctx_upgrade refuse inside execute
  unless CONTEXT_MODE_ALLOW_DESTRUCTIVE=1 (V2 host does no per-call
  permission prompt for plugin tools).
- v2-native usage capture: correlate session.step.started model by
  assistantMessageID with session.step.ended tokens/cost via new
  parseOpencodeV2StepUsage() (reasoning folded into output, native USD
  verbatim); message.updated kept as fallback.
- Docs: OpenCode 2 section in platform-support.md + opencode-v2.json template.

Tests: 12 new (parser mapping/edge cases, mode resolution, policy
unit+refusal, own/passthrough/empty compaction, step correlation
end-to-end into session DB). Targeted suites 140 passed, typecheck clean.
Full suite shows 33 pre-existing failures in hooks/session bundles,
reproduced on clean tree.
@Scratchydisk
Scratchydisk deleted the feat/v2-compaction-port branch September 24, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant