Skip to content

feat(systemcontext): adopt incremental context and git-tree snapshots from opencode - #231

Merged
Patel230 merged 1 commit into
mainfrom
feat/incremental-context-gitsnapshot
Aug 22, 2026
Merged

feat(systemcontext): adopt incremental context and git-tree snapshots from opencode#231
Patel230 merged 1 commit into
mainfrom
feat/incremental-context-gitsnapshot

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

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)
  • Preserves a cache-stable baseline and emits only changed context as an update (vs. rebuilding the whole system prompt each turn)
  • Durable JSON snapshots + stale-while-revalidate on unavailable sources
  • ctxmgr.IncrementalContext host integration; opt-in engine wiring (HAWK_INCREMENTAL_CONTEXT=1) so unchanged memories don't rewrite the ## Relevant Memories section

#5 — Git-object-store file snapshots (internal/gitsnapshot/)

  • Linked snapshot repo sharing the source repo's object DB via objects/info/alternates (no re-hash of large repos)
  • Content-addressed Capture (tree IDs), Diff, throwaway-index Preview (dry-run without touching worktree), Restore
  • WriteIfUnchanged — compare-and-swap to prevent concurrent clobbering

Scope 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

  • New packages: internal/systemcontext (12 tests), internal/gitsnapshot (7 tests)
  • internal/engine + ctxmgr suites green
  • Full pre-push hooks green: boundary guards, external-drift, govulncheck, entire go test suite, go vet
  • golangci-lint 0 issues, gofmt clean

… 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).
@Patel230
Patel230 merged commit 0584f97 into main Aug 22, 2026
26 of 27 checks passed
@Patel230
Patel230 deleted the feat/incremental-context-gitsnapshot branch August 22, 2026 14:19
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