feat(systemcontext): adopt incremental context and git-tree snapshots from opencode - #231
Merged
Merged
Conversation
… from opencode Add two genuinely-missing capabilities adopted from opencode's design: - internal/systemcontext: composable, incrementally-rendered model context runtime (Source/Codec/Reconciler/Epoch) that preserves a cache-stable baseline and emits only changed context as an update. Includes the ctxmgr.IncrementalContext host integration and an opt-in engine wiring (HAWK_INCREMENTAL_CONTEXT=1) so unchanged memories do not rewrite the system prompt each turn. - internal/gitsnapshot: git-object-store file-tree snapshots sharing the source repo object db via objects/info/alternates, with content-addressed Capture, Diff, throwaway-index Preview, Restore, and compare-and-swap WriteIfUnchanged to prevent concurrent clobbering. 8 of the 10 originally proposed opencode adoptions already exist in eyrie/ hawk (prompt caching, tool-output spill, least-privilege permissions, usage ledger, reasoning variants, error taxonomy, OAuth refresh, redaction); these two were the confirmed gaps. All new packages build, lint clean, and pass their tests (systemcontext 12, gitsnapshot 7, ctxmgr + engine suites green).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adopts the two genuinely-missing capabilities identified from a deep-dive of the opencode codebase, implemented idiomatically for hawk.
Changes
#3 — Incremental System-Context (
internal/systemcontext/+ctxmgr.IncrementalContext+ engine wiring)A composable, incrementally-rendered model-context runtime:
Source[V]/Codec/SystemContext/Reconciler/Epoch(opencode's Context Source / epoch / reconcile pattern)ctxmgr.IncrementalContexthost integration; opt-in engine wiring (HAWK_INCREMENTAL_CONTEXT=1) so unchanged memories don't rewrite the## Relevant Memoriessection#5 — Git-object-store file snapshots (
internal/gitsnapshot/)objects/info/alternates(no re-hash of large repos)Capture(tree IDs),Diff, throwaway-indexPreview(dry-run without touching worktree),RestoreWriteIfUnchanged— compare-and-swap to prevent concurrent clobberingScope note
8 of the 10 originally proposed opencode adoptions already exist in eyrie/hawk (prompt caching, tool-output spill, least-privilege permissions, usage ledger, reasoning variants, error taxonomy, OAuth refresh, redaction). This PR implements only the two confirmed gaps, avoiding duplication.
Testing
internal/systemcontext(12 tests),internal/gitsnapshot(7 tests)internal/engine+ctxmgrsuites greengo testsuite,go vetgolangci-lint0 issues,gofmtclean