Skip to content

fix(sync-project, doctor): restore the look-ledger seen hook when a project lacks it - #414

Merged
MendixMau merged 9 commits into
masterfrom
night/fix-look-ledger-hook
Oct 16, 2026
Merged

MendixMau merged 9 commits into
masterfrom
night/fix-look-ledger-hook

Conversation

@MendixMau

@MendixMau MendixMau commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Direct lane

What changed and why: In a lab project the look ledger read "0 of 31 pages seen" while 22 of those pages had screenshots. The project's .claude/settings.json held only what mxcli init writes: no look-ledger.sh seen hook, no session-check hook, no wrapper allow-list, no permissions sidecar. install-claude-permissions.sh is the only writer of the hooks and is called only by init-project.sh at scaffold time. The one later caller, sync-project.sh, ran it in --check mode and printed a warning inside a long report. doctor.sh checked the allow-list but never the hooks. So a project that missed the scaffold-time install (or whose settings file was rewritten by a later mxcli init) stayed without the hook, silently, and seen.tsv was never written. Fix: install-claude-permissions.sh --hooks-only (hooks only; no allow/deny/ask entries, no pruning, nothing in settings.local.json); sync-project.sh runs it when the hooks are missing and the project installed the profile before (--dry-run reports it), else it warns; doctor.sh warns and names the fix.

Impact

Row Answer
Process No new gate or human step. A toolkit pull may now write two hook lines into .claude/settings.json, only in a project that installed the permission profile before (sidecar with a non-empty allow, or .mxtk/permission-profile). Any other project gets a WARN with the one-line install-claude-permissions.sh <dir> --hooks-only command. Opt-out: .mxtk/no-hook-repair.
Dependencies Touches bin/install-claude-permissions.sh, bin/sync-project.sh, bin/doctor.sh. No _common.sh or exec.sh change. Unblocks the planned owed-LOOK threshold (#232): a block on this ledger is unsafe while the hook can be absent. No new tool or platform assumption; Bash 3.2 and Python as before.
Context cost none: no routed or always-loaded file touched
Behaviour n/a: scripts only
Runtime Sync adds one --hooks-only --check call (a single JSON read, well under a second). Doctor adds two greps.

Field evidence: a copy of the lab project (APFS clone, original untouched). Before: no hooks in settings.json, no seen.tsv, 110 owed rows, 31 pages OWED. After sync-project.sh: both hooks present and the project's own hook and allow entries kept. A Read of a capture png through the installed hook command wrote a seen.tsv row, and a second capture matching an owed page flipped it to SEEN in look-ledger.sh status (31 OWED became 30 OWED, 1 SEEN). Note: the copy sat under /tmp, where an unrelated .mpr in an ancestor directory moved the ledger root, so the hook run on the copy used PROJECT_ROOT set explicitly (the documented override); this is the known tier-3 behaviour in _common.sh, not part of this change.

  • No client data anywhere in the diff
  • Size cap: 5 files, about 190 lines excluding CHANGELOG
  • Test tier reached: T1. tests/wave2/test-look-ledger-hook-repair.sh 13/13 pass on this branch (adds the declined-project, formatting and opt-out cases) and fails on master (H1 to H3, H6 at least; master has no --hooks-only). test-install-claude-permissions.sh 77/77 and test-look-ledger.sh 11/11 still pass.
  • CHANGELOG.md line appended, credited; bin/check-pr-discipline.sh origin/master clean

🤖 Generated with Claude Code

Merge after #421.

…roject lacks it

A lab project's look ledger read 0 of 31 pages seen while 22 had screenshots:
.claude/settings.json held only what mxcli init writes. install-claude-permissions.sh
(the only writer of the hooks) had never run there, sync-project.sh only printed a
warning, and doctor.sh checked the allow-list but not the hooks.

install-claude-permissions.sh gains --hooks-only (hooks only, no allow/deny/ask
entries, no pruning, nothing in settings.local.json). sync-project.sh runs it when the
hooks are missing (--dry-run reports). doctor.sh warns and names the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MendixMau and others added 2 commits October 16, 2026 11:34
… opt-out (review of #414)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MendixMau and others added 2 commits October 16, 2026 17:30
…er hook repair test

Source bin/lib/portable.sh, call require_py and use "$PY". The hook command
extraction no longer opens a heredoc inside $(...), which bash 3.2 cannot parse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MendixMau added a commit that referenced this pull request Oct 16, 2026
Independent review: APPROVE (421-r3). Follow-up commit 583487a only adds portability-ok markers on a diagnostic message and deliberate fake interpreter wrappers in the test (self-reviewed).

# #421 delta r3 (cb1bcc0)
Scope: the two CHANGES items in 421-r2.md.
1. The merge step now runs as `if ! "$SETTINGS_PY" - ... <<'PYMERGE' ... then cp snapshot; WARN; fi`, the shape r2 verified, so a failed merge under `set -euo pipefail` restores the snapshot byte for byte instead of exiting.
   New cases: fake python3 that passes the version probe and fails the merge; one that truncates the target then fails. test-wire-agents-settings.sh 17/17 on head; on c426e51 the 8 new assertions fail (9/17).
2. origin/master merged in; CHANGELOG conflict resolved keeping both sides. test-wire-agents-kiro 12/12.
APPROVE. Merge before #414.
MendixMau and others added 4 commits October 16, 2026 19:55
…layout

--hooks-only refuses to rewrite a hand-formatted file (exit 3). The one-line-hook
fixture only passed on hosts where mxcli on PATH had normalised the file first, and
failed on the CI runner (H4/H6, run 38897076571).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MendixMau
MendixMau merged commit 2896a56 into master Oct 16, 2026
2 checks passed
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.

1 participant