From 77b48d24273d46e8da71aab514b5213c47518a93 Mon Sep 17 00:00:00 2001 From: Jason-Vaughan <95194903+Jason-Vaughan@users.noreply.github.com> Date: Sat, 23 May 2026 18:28:35 -0700 Subject: [PATCH] Recover global rules clobbered by CLAUDE.md regeneration (#240) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bug. lib/engines.js#_generateClaudeMd regenerates CLAUDE.md from the DB-stored global rules on every session launch / engine PATCH / startup sync, overwriting the on-disk file in place. PR-driven raw- file edits to CLAUDE.md are silently discarded the next time TC restarts — the content lives on in git log but is functionally absent from the live ruleset. Affected this session. Two PRs: - #234: versioning bump-level decision table (Releases & Versioning section). - #236: stale-plan archive rule + gh issue view --json state issue-state check (Build Plans & Chunks section). Both were clobbered after the first TC restart following each merge. Recovery already performed via store.globalRules.save() in the restart-bug investigation session. The regenerated CLAUDE.md is now byte-for-byte identical to HEAD (diff is empty), so the next TC restart produces no surprise drift. This commit adds: - A defensive comment block to lib/engines.js#_generateClaudeMd documenting the regeneration contract and pointing future readers (human or automated agent) at the three durable edit paths: landing-page editor, PUT /api/rules/global (10 KB body cap), or store.globalRules.save() from a node script. The same regeneration pattern applies to Codex / Aider / Gemini config files (cross- referenced in the comment). - A CHANGELOG ### Fixed entry summarizing the recovery + linking to #240 for the public-facing diagnostic and recovery procedure for other cloners. The structural fix (preventing the trap from ever firing again) is tracked separately in #240 — likely either a tracked-file canonical source with startup sync, or an append-only marker pattern that regeneration preserves. Design call belongs to whoever picks up the structural work. Refs #240 --- CHANGELOG.md | 4 ++++ lib/engines.js | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8e386..4af7791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to TangleClaw are documented in this file. ## [Unreleased] +### Fixed + +- **Recover global rules from #234 + #236 silently clobbered by CLAUDE.md regeneration (#240)** — `lib/engines.js#_generateClaudeMd` regenerates `CLAUDE.md` from the DB-stored global rules on every session launch / engine PATCH / startup sync, overwriting the on-disk file in place. PR-driven raw-file edits to `CLAUDE.md` (e.g. via `git`) are silently discarded the next time TC restarts — the content lives on in `git log` but is functionally absent from the live ruleset. Two PRs this session were affected: **#234** (the versioning bump-level decision table) and **#236** (the stale-plan archive rule + `gh issue view --json state` issue-state check). Both rule blocks were clobbered after the first TC restart following each merge; the celebrated "structural lessons codified in CLAUDE.md" claim in those PR descriptions was technically true in git history and functionally false in the running ruleset. **Recovery procedure run this session:** read the live DB content via `store.globalRules.load()`, splice the two missing rule blocks back into their respective sections (`Build Plans & Chunks` for #236, `Releases & Versioning` for #234) preserving sibling content, write back via `store.globalRules.save(merged)` (which normalizes and persists to `_globalRulesPath()`). Verified end-to-end: the regenerated `CLAUDE.md` is now byte-for-byte identical to HEAD (diff is empty), so the next TC restart produces no surprise drift. **Defensive comment added** to `lib/engines.js#_generateClaudeMd` documenting the regeneration contract and pointing future readers (or automated agents tempted to commit directly to `CLAUDE.md`) at the durable edit paths: landing-page editor, `PUT /api/rules/global` (10 KB body cap), or `store.globalRules.save()` from a node script. The same regeneration pattern applies to Codex / Aider / Gemini config files — same trap, less commonly hit because TC-v3 itself uses Claude. Public diagnostic + recovery procedure for any other cloner who is affected is documented in #240. Structural fix (preventing the trap from ever firing again — likely either a tracked-file canonical source with startup sync, or an append-only marker pattern that regeneration preserves) is tracked in #240 as separate work. + ### Changed - **"Run Critic" button: clarify the contract via label + confirm dialog + toast (#230)** — the methodology-action button on prawduct projects was previously labeled `Run Critic` with `confirm: false`, so clicking it skipped any dialog and silently POSTed to `/api/projects/:name/actions/invoke-critic`. The handler only appends an entry to `.tangleclaw/critic-runs.json`; it never *runs* a Critic. New operators clicked the button expecting an automated review, saw the toast `Run Critic: recorded`, and reasonably concluded the button was broken (it wasn't — the contract was mislabeled). **What changed.** (1) Label renamed `Run Critic` → `Mark Critic Run` (`data/templates/prawduct/template.json:106`) so the imperative is honest about what the click does. (2) `confirm: false` → `confirm: true` so the contract-clarifying dialog actually fires. (3) Two new optional per-action wording fields added to the methodology template schema — `confirmMessage` and `successToast` — used by `public/session.js#invokeMethodologyAction` when present, falling back to the generic `Run "