Self-healing journal import, .ctxrc promotion, GitNexus fold — reviewed & fixed#132
Merged
Conversation
Make `ctx journal import` growth-aware: the unit of memory becomes the source transcript (has it grown?) rather than the output file (does it exist?). --all now imports new sessions AND re-renders any whose transcript has grown, skipping only unchanged sources; hand-edited entries are detected via a body render-hash and never clobbered. Wired into a SessionEnd hook and the wrap-up ceremony so it self-heals with no flags to remember. Adversarial-review fixes folded in: - C1: `ctx journal site` refreshes the render-hash after its in-place body normalize (+ persists state); otherwise every site-normalized entry was false-flagged as a foreign edit and stranded. - M1: the source stat is committed by execute only AFTER a clean write (via ImportPlan.Sources), so a failed/partial grown write no longer advances the stat and silently forgets the growth. - M3: resume/multi-file dedup keeps the richest transcript (most messages) and growth compares the source path too, so switching to a larger resume copy counts as growth instead of truncating. - M4: adopting a pre-v2 entry backfills its render-hash so a later growth sweep can self-heal it. - L1: grown re-renders count as GrownCount, not RegenCount, so a routine interactive sweep no longer trips the regenerate prompt; the summary reports "complete N grown". - L3: entry writes are atomic (temp+rename); the SessionEnd hook can be killed mid-write. Regression tests: full New->Unchanged->Grown->ForeignEdit cycle plus a failed-write-does-not-strand test. Spec: specs/journal-import-self-heal.md Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Expose six previously-hardcoded knobs as .ctxrc keys: auto_prune_days, agent_cooldown_minutes, task_budget_pct, convention_budget_pct, title_slug_max_len, recall_list_limit. Absent keys keep prior behavior. Adversarial-review fixes folded in: - C2: auto_prune_days guards <=0 (getter + health.AutoPrune); a negative day count moved the prune cutoff into the future and deleted every session-state file. - C3: title_slug_max_len guards <=0; a negative reached the slice bound in slug.FromTitle and panicked. - M2: agent_cooldown_minutes/task_budget_pct/convention_budget_pct are pointer types, so an explicit 0 (disable / zero-allocation) is distinct from unset (default) rather than being coerced back. - L5: budget percentages clamp to [0,1] and each tier caps at the remaining budget, so percentages summing past 1.0 can't overrun. - L9: the schema-vs-struct bijection test reflects over the real rc.CtxRC (homed in package rc to avoid the assets->rc import cycle), so it can no longer drift from a hand-maintained copy. - L10: slug/doc.go concurrency note corrected (FromTitle is not pure; Reset races the cache). Regression tests: negative-value fallbacks, 0-disables-cooldown, budget clamp, explicit-zero allocation. Spec: specs/ctxrc-constant-promotion.md Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Delete the three EXPERIMENTAL (discardable) project skills ctx-experimental-plan / -spec / -handoff. Their only reason to exist was bridging ctx to spec-kit, which this project does not use (zero speckit references outside the trio). ctx-experimental-plan duplicated /ctx-plan and -spec was a lesser /ctx-spec; content is preserved in git history. Add the operator-facing docs/recipes/spec-driven-development.md, the full design->spec->implement pipeline narrative (/ctx-brainstorm, /ctx-plan, /ctx-spec, /ctx-task-out, /ctx-implement), and register it in the recipe index and design-before-coding cross-links. Review fix: the "load-bearing rules" prose said four, the section lists five. Spec: specs/remove-experimental-spec-kit-chain.md Signed-off-by: Jose Alekhinne <jose@ctx.ist>
npx gitnexus does not run on this box (tree-sitter@0.21.1 fails to build against Node 24). Vendor a thin Docker wrapper that uses the official arm64 image (Node 22 + prebuilt deps), staying off the host: hack/gitnexus-docker.sh (index / mcp / passthrough), gitnexus-index.sh, strip-gitnexus.sh, and make gitnexus-index / gitnexus-mcp / strip-gitnexus targets. Replace every `npx gitnexus` reference in docs and skills (GITNEXUS/CLAUDE/AGENTS, getting-started, multi-tool-setup, ctx-remember, ctx-architecture-enrich). Data-loss guard: GitNexus prunes registry entries whose paths it cannot stat in-container, so the wrapper mounts every registered repo on all registry-touching branches. Review fixes (shell): registry_mounts fails loud (python3 preflight; hard-fail on non-empty-but-unparseable registry on registration/passthrough branches) instead of fail-open; empty-array expansions are set -u safe; strip-gitnexus preserves content on unbalanced markers. Spec: specs/gitnexus-docker-fold.md Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Add the batch of orphaned recipe and CLI pages to zensical.toml's nav (KB recipes, dream, architecture-deep-dive, cli/kb|handover|dream|event| message|bootstrap, runbooks) so they are reachable from the sidebar. Delete the stale docs/cli/connect.md (superseded by connection.md) and fix the leftover `ctx connect` references: the broken command in the hub-deployment runbook becomes `ctx connection register`, and stale `ctx connect` display labels across hub/CLI pages become `ctx connection` (the command was renamed; no `connect` alias exists). Guard: internal/compliance/docs_nav_test.go asserts every non-blog docs page is in the nav AND every nav Markdown entry resolves to a real file (so a deleted-but-still-linked page fails tests), with a sentinel that prevents a vacuous pass. Also fixes a pre-existing broken doc icon (lucide/message-square-cog -> message-square-text) that blocked any site build. Spec: specs/docs-link-integrity.md Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Regenerate the tracked site/ (zensical build + ctx site feed) so it reflects the cumulative docs changes in this branch: the new spec-driven-development recipe renders, the deleted connect page is pruned, the repaired nav and the message-page icon fix land. site/ is tracked with no CI build step, so it is staged with the docs it renders. Persist the review outcome to .context: mark the adversarial-review task done and record the session's learnings (site rewrites entry bodies -> refresh render_hash; zensical's frozen lucide bundle; PATH ctx is a stale install; assets<-rc import cycle). Spec: specs/meta/chores.md Signed-off-by: Jose Alekhinne <jose@ctx.ist>
Add a Process Invariant to CONSTITUTION.md (and a session-start reminder to AGENT_PLAYBOOK_GATE.md): every commit must carry a DCO `Signed-off-by:` trailer (commit with `git commit -s`) and must NOT carry a `Co-Authored-By:` / agent-or-tool sign-off, overriding any harness default that suggests one. Also require reading `git log -5` for the trailer convention before the first commit of a session. Prompted by six commits this session that carried an agent sign-off and no DCO because the existing history's convention was never checked. Both files are injected into every agent's context at session start, so the rule reaches all agents rather than living only in one session's private memory. Spec: specs/spec-trailer-discipline.md Signed-off-by: Jose Alekhinne <jose@ctx.ist>
The ctx-commit skill said to include Signed-off-by but never said how (git commit -s) and never forbade Co-Authored-By, so a bypass to raw git commit produced commits with an agent sign-off and no DCO. Close the gap: mandate `git commit -s`, explicitly prohibit `Co-Authored-By:` / agent-or-tool sign-offs, point at the CONSTITUTION Process Invariants, and require checking `git log -5` for the trailer convention first. Update the checklist and sync the Copilot-CLI mirror. Spec: specs/spec-trailer-discipline.md Signed-off-by: Jose Alekhinne <jose@ctx.ist>
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
A multi-spec changeset (the "jumbo diff") put through a 4-pass adversarial code
review before merge. The review surfaced 20 findings (3 critical,
4 medium, 13 low); all are fixed, each with regression tests. Docs are
updated and the tracked docs site is rebuilt. Every commit carries a truthful
Spec:trailer and a DCOSigned-off-by.267 files changed (including 182 generated
site/files; ~85 hand-editedsource/doc files).
What's in it (by spec)
feat: self-healing journal import (Phase JI)—specs/journal-import-self-heal.mdctx journal importbecomes growth-aware: the unit of memory is the sourcetranscript (has it grown?), not the output file (does it exist?).
--allimports new sessions and completes any whose transcript has grown, skipping
only unchanged sources. Hand-edited entries are detected via a body render-hash
and never clobbered. Wired into a SessionEnd hook + the wrap-up ceremony, so it
self-heals with no flags to remember.
feat: promote runtime constants to .ctxrc—specs/ctxrc-constant-promotion.mdSix new opt-in
.ctxrckeys:auto_prune_days,agent_cooldown_minutes,task_budget_pct,convention_budget_pct,title_slug_max_len,recall_list_limit. Absent keys preserve prior behavior.chore: remove experimental spec-kit skills; add spec-driven recipe—specs/remove-experimental-spec-kit-chain.mdDelete the unused
ctx-experimental-{plan,spec,handoff}skills (they onlybridged to an unused spec-kit); add the operator-facing
spec-driven-developmentrecipe and register it in the nav/index.build: vendor GitNexus Docker tooling; drop npx gitnexus—specs/gitnexus-docker-fold.mdnpx gitnexusdoesn't run here (tree-sitter@0.21.1 vs Node 24). Vendor a Dockerwrapper (
hack/gitnexus-*.sh) + Make targets. Aregistry_mountshelper guardsagainst GitNexus pruning registry entries whose paths it can't stat in-container
(fails loud on a missing
python3on registry-touching branches).docs: repair site nav; fix connect→connection references—specs/docs-link-integrity.mdAdd orphaned recipe/CLI pages to the nav; delete the stale
cli/connect.md(superseded by
connection.md); fix brokenctx connectreferences. Newdocs_nav_test.goguards nav reachability both ways (page↔nav).chore: rebuild docs site+ DCO governanceRegenerate the tracked
site/(zensical). Mandate DCO sign-off and forbid agentsign-offs in
CONSTITUTION.md, the session-start gate, and the/ctx-commitskill (with Copilot mirror).
Adversarial review — 20 findings fixed
Critical
ctx journal siterewrote entry bodies in place without refreshingthe render-hash, so growth-aware import false-flagged every site-normalized
entry as foreign-edited and stranded it. Fixed: refresh the hash + persist
state on every body-authoring pass.
auto_prune_daysmoved the prune cutoff into the futureand deleted every session-state file. Fixed:
<= 0guard in the getterand defensively in
health.AutoPrune.title_slug_max_lenreached a slice bound and panickedevery
ctx journal source/import. Fixed:<= 0guard.Medium
write silently forgot the growth. Moved to execute, gated on a clean write.
agent_cooldown_minutes: 0couldn't disable the cooldown. Cooldownand budget-percentage keys are now pointer types (explicit
0≠ unset).transcript. Now picks the largest; growth also compares the source path.
growth as a foreign edit. Now backfills the hash at adoption.
Low —
GrownCountsplit (routine growth no longer trips the regenerateprompt) · atomic entry writes · shell
registry_mountsfail-open +python3preflight · budget clamp to
[0,1]and per-tier cap · nav-test sentinel +reverse-link check · drift-proof reflection-based schema test · doc/wording
fixes.
New regression tests cover every confirmed bug: negative-value fallbacks,
0-disables-cooldown, budget clamp, adoption hash, failed-write-doesn't-strand,GrownCount, and the fullNew → Unchanged → Grown → ForeignEditself-healcycle.
Behavior / migration notes
render-hash). v1 files load tolerantly and round-trip as v2 on the next save.
ctx journal import --allno longer skips existing entries — it completesgrown ones. Hand-edited entries are protected (detected by render-hash and
left untouched with a warning).
.ctxrckeys are opt-in; unset means prior defaults.Testing
make build✓ ·gofmtclean ·golangci-lint0 issues ·make test0 failures (169 packages) · docs site rebuilt with zensical and verified
(new recipe rendered, stale
connectpage pruned).