Skip to content

fix(gate-check,status): mark a stale Current stage readout and list unlogged exec scripts (#767) - #777

Open
MendixMau wants to merge 1 commit into
masterfrom
triage/767-stale-stage-readout
Open

MendixMau wants to merge 1 commit into
masterfrom
triage/767-stale-stage-readout

Conversation

@MendixMau

Copy link
Copy Markdown
Owner

Fixes #767

Direct lane

What changed and why (one paragraph): This implements triage options 1 and 3. Both only warn, and both are computed when someone reads the position, never per exec row. project-bin/exec.sh is not touched.

Option 1 (staleness marker). When docs/BUILD-LOG.md has exec rows dated after the ## Current stage readout, gate-check prints Current stage line is from <date>; N exec rows since — re-run bin/gate-check.sh. It does this on every run, after any rewrite. bin/status.sh prints the same line under WATCH.

  • gate-check's own rewrite now stamps · last exec <date> inside the parenthesis: (derived by gate-check on D · last exec D2; re-run it …).
  • It also rewrites when that date has moved, so a full run clears the warning. A second run is still byte-identical.
  • The reference date is the last exec date, which the log itself wrote, so UTC and local dates cannot disagree. Lines written before this change fall back to the derived date.
  • Comparison is by day: rows from the reference day itself are not counted. That can miss a same-day exec, but it never warns on a current readout.

Option 3 (change-log nudge). Under the Change log: line, a separate WARN — N exec script(s) since Stage 5 started with no cr: tag and no build-plan row … lists those scripts, deduplicated, at most 10.

  • "Stage 5 started" means the first BUILD-LOG row whose script architecture/build-plan.md names. The stage readout is the thing this issue found stale, so the nudge does not read it.
  • Plan matching accepts the script name verbatim, or the abbreviated 060-…-customer_overview.mdl form that brd-to-build-plan.md uses.
  • If no row matches the plan, nothing is printed.
  • The Change log verdict (PASS on 0 rows) and the exit code are unchanged.

Both readers live in one sourced library, the new bin/lib/build-log-read.sh.

Impact

Row Answer
Process None. Two new WARN lines; nothing blocks, and no verdict or exit code changes (asserted in test-change-log.sh T10). Not done: having Stage 6 / --closeout refuse on a stale readout (the triage's open question; the maintainer approved warn-only).
Dependencies Changes bin/gate-check.sh (readout block, Change log block) and bin/status.sh. New bin/lib/build-log-read.sh. It reads docs/BUILD-LOG.md, which project-bin/exec.sh log_build() writes on every exec, and architecture/build-plan.md (Stage 4, found with resolve_artifact, so both layouts). The BUILD-LOG path is the same hard-coded $PROJECT_DIR/docs/BUILD-LOG.md that gate-check and status.sh already use. The new stamp sits inside the parenthesis. The other parsers of ^\*\*Stage were checked: status.sh:56, token-burn.sh:353, obligation-check.sh:182. Fixture assertions cover status.sh WHERE and _ob_current_stage, and test-token-burn.sh passes (63/63). Plain POSIX awk, checked under mawk (byte-oriented); the … match uses length("…"), which also holds in UTF-8 awks. Shares bin/status.sh with #765's PR, so the two need a composition check.
Context cost none: no routed or always-loaded file touched
Behaviour NOT RUN: scripts only, no skill text changed. The only agent-read text is the two new output lines. Maintainer to accept or request A/B.
Runtime Full gate-check --no-html on a scaffolded fixture with a 300-row BUILD-LOG, alternating master and branch: master 1216 / 1247 / 1408 ms, branch 1218 / 1278 / 1386 ms (within noise). The three helpers alone took about 20 ms per run on the same 300 rows (10 runs: 198 ms).

Time cost: per gate-check / status run · ~0.02 s on a Linux container (300-row log) · can force rework: n · offset: maintainer OK (nothing per exec row; exec.sh unchanged)

Field evidence: a field report from a greenfield build in auto mode, 2026-11-13, relayed by the maintainer and anonymised.

  • The register read "Stage P — needs attention" after the build had finished.
  • Late asks went into numbered scripts with no change-log row.

This PR has not been run against that project. The fixtures reproduce both symptoms on input built from the captured exec.sh BUILD-LOG in tests/wave2/fixtures/verify-446/BUILD-LOG.captured.md. The stage-header fixture uses that file verbatim. The change-log fixture keeps the captured row shape and substitutes only timestamp, script name and the cr: tag.

Fixture results, master vs branch (the same new fixture files run against each tree):

Fixture master branch
tests/wave2/test-stage-header.sh bin/gate-check.sh 18 ok, 3 failed 21 ok, 0 failed
tests/wave2/test-change-log.sh bin/gate-check.sh 54 passed, 3 failed 57 passed, 0 failed
  • On master, T13 has no stale note from gate-check, none from status.sh, and no · last exec stamp.
  • On master, T10 has no nudge line, the unlogged script is not listed, and the duplicate check fails.

Existing fixtures that cover the changed lines, all on the branch:

Fixture Result
test-bug03-gates.sh 99 ok
test-status-bare-var.sh 3/3
test-status-existing-app.sh 27/27
test-status-lint-unversioned.sh 4/4
test-status-session-cwd.sh 10/10
test-obligation-final-look.sh 17/17
test-token-burn.sh 63/63

Checks, all clean: bin/check-scripts.sh, the leak guard against origin/master, and bin/check-portability.sh.

  • No client data anywhere in the diff
  • Size cap: 6 files changed, about 200 lines, of which 68 are fixtures and 1 is CHANGELOG
  • Test tier reached: T1. Scoped wave2 fixtures were run on branch and master; no field run.
  • For a new/changed instrument:
    • Golden input is captured: the BUILD-LOG rows come from the verify-446 capture.
    • Both layouts: the build plan resolves via resolve_artifact, and the BUILD-LOG path is the same one gate-check and status already use.
    • Both platforms: no new tools; plain awk/sed; checked with mawk; check-portability is clean.
  • For a new skill: n/a
  • CHANGELOG.md line appended, crediting the field report
  • New bug entries: n/a

Review: pending independent review


Generated by Claude Code

…ge (#767)

Warn-only, computed at read time, nothing per exec row (exec.sh untouched).

- gate-check (every run) and status.sh (WATCH) print "Current stage line
  is from <date>; N exec rows since — re-run bin/gate-check.sh" when exec
  rows in docs/BUILD-LOG.md post-date the readout's stamp.
- gate-check's rewrite stamps "· last exec <date>" inside the parenthesis,
  and rewrites when that date moved; the **Stage N prefix parsed by
  status.sh, token-burn.sh and obligation-check.sh is unchanged.
- Under the "Change log:" line, a WARN lists exec scripts since Stage 5
  started (first row the build plan names) with no cr: tag and no
  build-plan row. Verdict and exit code unchanged.

New bin/lib/build-log-read.sh; fixtures test-stage-header.sh T13 and
test-change-log.sh T10, built on the captured verify-446 BUILD-LOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXpQSjXefSNicGGqP4aiSC
@MendixMau

Copy link
Copy Markdown
Owner Author

Review: MERGE. Both #767 warn-only options work, and no parsed output or verdict changes. One side effect, which is intended: gate-check now rewrites the ## Current stage line whenever the newest exec date moves, at most once per exec day. That is a PROJECT.md diff the old "a date alone is no change" rule avoided.

Value: Fixes the issue as reported, with one shared library and no change to exec.sh.

  • The stale readout is handled by mxtk_stage_stale_note in bin/lib/build-log-read.sh. It is called from gate-check.sh (after the rewrite, ~:4448) and from status.sh:58-61 (WATCH).
  • The stamp · last exec D is added at gate-check.sh:~4400.
  • The unlogged-ask nudge is mxtk_unlogged_execs, printed under Change log: (~:3620).

Regression risk: No verdict or exit-code change.

  • Existing synced projects get one rewrite of a derived line, because an old line has no last exec and so differs from the computed one. Hand-written lines stay untouched, because that branch runs first.
  • The new stamp sits inside the parenthesis. status.sh:56/223, obligation-check.sh:184 and token-burn match only the prefix or (derived by gate-check, so they are unaffected.
  • Output that status.sh parses from gate-check is unaffected: the new WARN prints after Next up:, so NEED_ATTN ends before it.
  • Both layouts: the plan comes through resolve_artifact.
  • awk: the … handling is consistent in byte and UTF-8 awks.
  • Noise risk: Stage 6 fix scripts and other unplanned helper scripts get listed as "an unlogged ask?". The list is warn-only and capped at 10.

Correctness: No bugs found.

  • status.sh:60 sources the library without a guard, where gate-check guards it with -r. Harmless, since it is the same checkout.
  • The comparison is by day, as documented. BUILD-LOG rows are local time (captured header), and the stamp takes its date from the log, so there is no skew.
  • Golden input is the captured verify-446/BUILD-LOG.captured.md.
  • Run in a detached worktree: test-stage-header 21/0, test-change-log 57/0, test-bug03-gates 99/0, test-obligation-final-look 17/0, all five test-status-*.sh green.

Context cost: 66196 → 66196 always-loaded words (measured). No routed file is touched.

Time cost: per gate-check or status read, one or two awk passes over BUILD-LOG, tens of ms on 300 rows. Nothing per exec row.

Conflicts: none with origin/master. It conflicts with #776 in bin/status.sh's WATCH loop and in CHANGELOG. Both are trivial: take both, for _w in "$STAGE_STALE" … "$LINT_UNVERSIONED" "$TS_WATCH"; do, and keep both CHANGELOG lines. With those resolved, all fixtures pass on the merged tree.


Generated by Claude Code

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.

[bug] Stage readout in PROJECT.md goes stale after the last gate pass, and late asks skip change-intake

2 participants