feat(memory): nunchi-primary merge order + 16KiB default cap for ccc-piri - #963
Merged
Conversation
…piri Live verification on soonwook exposed a silent starvation bug: the canonical loader output alone is ~11KB on fleet nodes, so the appended nunchi block was truncated away entirely under the 8192-byte whole-snapshot cap — node-global Piri (and Codex nodes with large canonical snapshots) never actually received nunchi context. 1. codex-loader.py now prepends the bounded nunchi block before the canonical context, matching the documented gate-3 'nunchi primary' contract: under cap pressure the canonical tail is sacrificed first instead of silently dropping nunchi. 2. ccc-piri defaults CCC_CODEX_MEMORY_MAX_BYTES to 16384 (16 KiB, hard max 24576) so canonical + nunchi both fit on fleet nodes; an explicit operator value always wins. Verified live on vps6 before this change: marker fact written to nunchi was recalled by a fresh Piri session only after raising the cap. Tests: prepend order pinned in ccc_codex_memory_test.py (36/36) incl. a new cap-survival regression test; ccc-piri cap default + override (15/15); install-nunchi 43/43; full harness PASS.
seoseo-ai
approved these changes
Aug 5, 2026
seoseo-ai
left a comment
Collaborator
There was a problem hiding this comment.
Approved after explicit operator authorization using the local seoseo-ai credential.
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
Live verification on soonwook (vps6) after #960 exposed a silent starvation bug: the canonical
load-memory.shoutput alone is ~11KB on fleet nodes, so the nunchi block — appended after canonical and truncated at the 8192-byte whole-snapshot cap — never actually reached the injected context. A marker fact written to nunchi was invisible to fresh Piri sessions (MISSING) until the cap was raised.Two fixes:
codex-loader.py): the bounded nunchi block now precedes the canonical context, matching the documented gate-3 "nunchi primary" contract. Under cap pressure the canonical tail is sacrificed first instead of nunchi vanishing silently. Affects both the Codex and Piri lanes (intentional — same contract).CCC_CODEX_MEMORY_MAX_BYTESto16384(hard max 24576, whole-file budget untouched) so canonical + nunchi both fit; an explicit operator value always wins.Live evidence (vps6, before this patch)
CCC_CODEX_MEMORY_MAX_BYTESMISSINGtruncated=falseTest marker, temp sessions, and temp files were cleaned up afterwards; bridge error log empty.
Changes
claude/hooks/nunchi/codex-loader.py: prepend merge + docstringscripts/ccc-piri: default cap 16384 (explicit env wins)scripts/ccc_codex_memory_test.py: order assertions updated + new cap-survival regression test (36/36)scripts/ccc-piri.test.sh: cap default + override tests (15/15)docs/memory.md: merge-order rationale + ccc-piri cap documentationTest plan
ccc_codex_memory_test.py36/36ccc-piri.test.sh15/15install-nunchi.test.sh43/43ccc-codex-memory.test.shpassvalidate-harness.shPASS