cli: drift status, shadow drift detail, per-query staleness + prime block (spec steps 1–3)#35
Open
jschatz1 wants to merge 3 commits into
Open
cli: drift status, shadow drift detail, per-query staleness + prime block (spec steps 1–3)#35jschatz1 wants to merge 3 commits into
jschatz1 wants to merge 3 commits into
Conversation
kai status gains a Graph: section (human) and a drift block (--json) classifying the semantic graph against git HEAD: synced, graph-behind (with unprocessed count and oldest-commit age), graph-ahead, diverged (both legs), orphaned, or unpinned — each with an action hint. Classification is merge-base/rev-list only, no semantic work on the status path. Pin sites: the post-commit bridge import records each processed commit in .kai/graph-refs.json, and kai import pins every replayed commit (batched, one write), attributing the branch ref only when the branch tip is the last imported commit.
🔍 Kai reviewWarning Needs a look — intent partially matches, 2 flags.
+617 −14 · 4 files · reaches 15 View finding → · Awaiting your verdict — Kai never approves its own finding. |
kai shadow drift (no flags) now shows the git-drift detail: the graph↔git relationship, each unprocessed commit with files touched and import targets, the superseded leg of a divergence, and the manifest location. Explicit --snap/--git-ref keep the legacy snapshot-content comparison. The drift manifest is synced after the bridge-import and kai-import pin sites, so catch-up shrinks it and new drift extends it without per-query git work.
…ness block Query commands (query callers/dependents/impact, test affected, blame) now classify their answer against graph drift before printing: an orphaned graph or intersection above staleness.refuse_after_intersecting refuses with the reason instead of answering; otherwise the answer prints with a one-line stale-valid/stale-suspect annotation on stderr (suppressible with --quiet). fresh stays silent. --strict (or staleness.strict in config) makes stale-suspect exit 75, following the CI tripwire convention. blame --json embeds the full staleness block without changing existing output shapes. kai prime appends a '## Staleness' section to injected context — outside the char budget so truncation can't drop the trust signal — listing intersecting commits and steering the agent to prefer current file contents over stale symbol lists.
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.
Steps 1–3 of the graph staleness / git drift spec. Companion to kaicontext/kai-engine#23, which this depends on.
kai status (step 1)
One line per relationship with an action hint;
--jsongains thedriftblock. Merge-base/rev-list only on the status path.kai shadow drift (step 2)
No-flag default is the drift detail view: per-commit files touched, import-target annotations (
[adds imports into pkg/foo]), the superseded leg on divergence, manifest state. Explicit--snap/--git-refkeep the legacy snapshot comparison. Pin sites (bridge import,kai import) sync the manifest so catch-up shrinks it.Per-query staleness (step 3)
kai query callers|dependents|impact,kai test affected,kai blame:stale-refused(orphaned graph, or ≥staleness.refuse_after_intersectingintersecting commits) suppresses the answer and errors with the reason. Default: never refuse.--quietto suppress):freshstays silent.--strict(orstaleness.strict) makes stale-suspect exit 75 (the CI tripwire convention). Default exit stays 0 so existing scripts don't break.kai blame --jsonembeds the full staleness block (existing shapes preserved).kai primeappends a## Stalenesssection to injected context — outside the char budget so truncation can't drop it — listing intersecting commits and steering agents to prefer current file contents.New config slice:
staleness.strict,staleness.refuse_after_intersecting(zero values = annotate, never block).Verified end-to-end
Scratch repo: synced query silent → drift commit touching
pkg/foo→ same query annotates stale-suspect with the commit, unrelated query stale-valid;--strictexits 75; threshold config refuses before printing;--quietsuppresses; prime carries the block; blame JSON embeds it. All suites green (engine drift/status,cmd/kai,internal/config, vet, gofmt).Note for CI
Builds against local engine via
go.work; proxy-resolved CI needs an engine tag containing kaicontext/kai-engine#23.🤖 Generated with Claude Code