Skip to content

feat(memory): nunchi-primary merge order + 16KiB default cap for ccc-piri - #963

Merged
jinon86 merged 1 commit into
mainfrom
feat/nunchi-primary-merge-order
Aug 5, 2026
Merged

feat(memory): nunchi-primary merge order + 16KiB default cap for ccc-piri#963
jinon86 merged 1 commit into
mainfrom
feat/nunchi-primary-merge-order

Conversation

@jinon86

@jinon86 jinon86 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Live verification on soonwook (vps6) after #960 exposed a silent starvation bug: the canonical load-memory.sh output 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:

  1. Nunchi-primary merge order (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).
  2. 16 KiB default cap for ccc-piri: the launcher defaults CCC_CODEX_MEMORY_MAX_BYTES to 16384 (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_BYTES nunchi block in AGENTS.md marker recall by fresh Piri session
8192 (default) ~30 bytes (header fragment) MISSING
16384 full block, truncated=false ✅ exact fact recalled

Test marker, temp sessions, and temp files were cleaned up afterwards; bridge error log empty.

Changes

  • claude/hooks/nunchi/codex-loader.py: prepend merge + docstring
  • scripts/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 documentation

Test plan

  • ccc_codex_memory_test.py 36/36
  • ccc-piri.test.sh 15/15
  • install-nunchi.test.sh 43/43
  • ccc-codex-memory.test.sh pass
  • Full validate-harness.sh PASS
  • Live marker round-trip on vps6

…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.
@jinon86
jinon86 requested a review from seoseo-ai as a code owner August 5, 2026 12:05

@seoseo-ai seoseo-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after explicit operator authorization using the local seoseo-ai credential.

@jinon86
jinon86 merged commit 63c8b56 into main Aug 5, 2026
8 checks passed
@jinon86
jinon86 deleted the feat/nunchi-primary-merge-order branch August 5, 2026 12:15
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.

2 participants