Task-core compaction migration (intel routine #2)#5
Merged
Conversation
…ompaction without drift New intel-layer routine. Claude Code auto-compacts (summarizes + drops the transcript) when the window fills; the generic summary loses load-bearing detail -> the agent drifts (re-litigates settled calls, repeats dead-ends, forgets constraints). This lets the agent decide what survives: a dense, AI-facing TASK-CORE written before the compaction boundary and read back after. - .gnkit/lib/context-pressure.mjs: estimate window fullness from the transcript — accurate (the last assistant message's input+cache usage = the real prompt size) + cheap (128KB tail-read), byte-size fallback. - .claude/hooks/gitnexus-context-pressure.mjs (PostToolUse): at >= contextPressureThreshold (default 0.9) of contextWindowTokens (default 200k; set 1000000 for 1M-context sessions), nudge the agent to write/refresh .gnkit/.gitnexus-task-core.md. Once per pressure zone (re-arms when pressure drops after a compaction); keeps nudging while NO core exists (compacting coreless is data loss). PreCompact can't inject context or make the agent act, so this is the pre-compaction trigger. - SessionStart(compact) recovery brief now READS the task-core FIRST. - task-core at .gnkit/.gitnexus-task-core.md — gitignored, survives compaction AND new sessions (a task can span both; agent overwrites it when the task changes; clearSessionState re-arms the nudge but leaves the core). - gitnexus-taskcore skill: the format (GOAL/CONSTRAINTS/DECISIONS/STATE/ANCHORS/GOTCHAS/OPEN-Qs/ USER-PREFS) + density rules (for the model, not humans) + recovery routine. Contract + workspace router + pack/sync manifests wired; contextPressureNudges scorecard counter. Claude-only trigger (compaction is a Claude Code concept); the task-core file + contract teaching are runtime-agnostic, so Cursor/Zed agents can keep one by hand. 59/59 tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
A dense, AI-facing task-core save-state that survives context compaction without drift — the intel-enhancement layer's second cognitive routine (after microscope).
Problem
Claude Code auto-compacts (summarizes + drops the transcript) when the window fills. The generic summary keeps the gist but loses load-bearing detail — a decision's why, a ruled-out dead-end, the exact file:line mid-edit — so the agent drifts: re-litigates settled calls, repeats failed approaches, forgets constraints.
Mechanism
.gnkit/lib/context-pressure.mjs— estimate window fullness from the transcript: accurate (last assistant message'susage.input + cache= the real prompt size), cheap (128KB tail-read), byte-size fallback..claude/hooks/gitnexus-context-pressure.mjs(PostToolUse) — at ≥contextPressureThreshold(default 0.9) ×contextWindowTokens(default 200k; 1M-context sessions set 1000000), nudge the agent to write/refresh.gnkit/.gitnexus-task-core.md. Once per pressure zone (re-arms when a compaction shrinks the transcript); keeps nudging while no core exists (compacting core-less = data loss). PreCompact can't inject context or make the agent act — so this PostToolUse hook is the pre-compaction trigger.gitnexus-taskcoreskill — the dense format (GOAL/CONSTRAINTS/DECISIONS+why/STATE/ANCHORS/GOTCHAS/OPEN-Qs/USER-PREFS) + density rules (for the model, not humans) + recovery routine. Contract + workspace router + pack/sync manifests wired;contextPressureNudgesscorecard counter; config knobs in.gnkit/gitnexus-hooks.json.The task-core lives at
.gnkit/.gitnexus-task-core.md— gitignored, survives compaction and new sessions (a task can span both). Claude-only trigger (compaction is a Claude Code concept); the core + contract are runtime-agnostic.v1 is a nudge (not a hard block). Tests: 59/59; fresh-install integration verified (hook wired, files land, contract present).
🤖 Generated with Claude Code