Skip to content

M-AILANG-FMT-ADOPTION: ailang fmt discoverability + opt-in harness hooks#415

Merged
sunholo-voight-kampff merged 6 commits into
devfrom
sprint/m-ailang-fmt-adoption
Jul 19, 2026
Merged

M-AILANG-FMT-ADOPTION: ailang fmt discoverability + opt-in harness hooks#415
sunholo-voight-kampff merged 6 commits into
devfrom
sprint/m-ailang-fmt-adoption

Conversation

@sunholo-voight-kampff

Copy link
Copy Markdown
Collaborator

Mission iteration 65. Closes the ailang fmt adoption gap now that Phase 2 (PR #414) made it lossless. No parser/type/codegen/runtime change — prompts, docs, build-glue, and opt-in hooks only.

Milestones (executor: opus · evaluator: sonnet, generator≠judge — PASS 89/100 round 1)

  • M1 — teaching prompt v0.16.3 (append-only in prompts/versions.json, active flipped; old versions serve byte-identical). Prompt now tells the model ailang fmt exists.
  • M2docs/docs/reference/formatter.md Adoption section (exit-code contract table 0/1/2/3, five contract clauses, make fmt-check-ail, copy-paste Claude Code PostToolUse hook config, Motoko cross-repo contract text); cross-linked from the development-workflow guide.
  • M3make fmt-check-ail (standalone AILANG drift check; not in make ci, which is byte-identical) + opt-in scripts/hooks/format_ail.sh with the Mark-approved SIGTERM→grace→SIGKILL escalation and no ailang fmt stderr suppression.

Notable deviation

fmt-check collided with the pre-existing Go gofmt CI gate → AILANG target shipped as fmt-check-ail to keep make ci byte-identical. Docs reflect the shipped name.

Verification

  • Evaluator independently re-ran hook tests (b) non-parsing→exit-3-silent, (c) unreadable→exit-2-advisory, (d) SIGTERM-ignoring stub reaped in ~11s not 300s (the regression the escalation fixes); idempotence no-op; make test green; make ci byte-identical.
  • Controller reproduced the full Docusaurus build → SUCCESS after running the CI-only sync-registry.sh step (the executor's flagged "docs build failure" was that skipped generation step + stale cache, not a sprint defect).
  • Append-only proof: ailang prompt --version v0.16.2 | grep -i fmt empty; current prompt teaches fmt.

Design doc: design_docs/implemented/v0_30_0/m-ailang-fmt-adoption.md. Bookkeeping: #399.

🤖 Generated with Claude Code

sunholo-voight-kampff and others added 6 commits July 20, 2026 00:15
Adds prompts/v0.16.3.md = byte-identical prefix of v0.16.2 plus a ~6-line
Formatting section (command usage only, no AILANG code snippet so no
ailang check surface). Registers it append-only in versions.json with its
sha256 and flips "active" to v0.16.3; existing entries are byte-preserved.

Gate sanity tripwires (Phase-2 landed): fmt --help documents lossless
comment preservation (not the Phase-1 blanket refusal); a non-parsing temp
file exits 3; a commented-but-parseable file exits 0.

Verified after rebuild: `ailang prompt | grep -i fmt` returns the teaching
line; `ailang prompt --version v0.16.2 | grep -i fmt` is still empty
(append-only proof — old prompt served byte-identical).

Refs #399

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CLI audit: `ailang --help` and `ailang fmt --help` are already Phase-2-current
(exit-code table 0/1/2/3, lossless-comment text) — no Phase-1 limitation drift.

Adds an Adoption section to docs/docs/reference/formatter.md: the exit-code
contract table with hook interpretation, the five contract clauses
(idempotence, meaning-preservation, atomicity, non-blocking+non-silent,
never-format-non-parsing), the `make fmt-check` description, a copy-paste
Claude Code PostToolUse hook config, and the Motoko per-edit cross-repo
contract (text only — no cross-repo commit).

Cross-links from the development-workflow guide to /docs/reference/formatter#adoption.

Note: a full Docusaurus build currently fails on a PRE-EXISTING base-tree
sidebar error (missing doc ids reference/errors/* + reference/formatter),
reproduced identically with these edits stashed — not caused by this sprint.
These edits are additive content to an existing page with a valid anchor link.

Refs #399

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a standalone `make fmt-check-ail` target reporting `ailang fmt --check`
drift over examples/**/*.ail + stdlib/**/*.ail (exit 1 + drifted paths on
drift, 0 when canonical). It is NOT wired into `make ci` — the `make ci`
recipe is byte-identical before/after (verified). Note: `fmt-check` was
already taken by the Go gofmt CI gate, so the AILANG target uses a
non-colliding name. Informational drift baseline over 393 .ail files:
31 canonical, 268 drift, 87 exit-2 comment-refusals, 7 parse errors (no
mass reformat — out of scope).

Adds scripts/hooks/format_ail.sh: a non-blocking (always exit 0), non-silent
(surfaces every non-exit-3 failure via hookSpecificOutput.additionalContext),
bounded PostToolUse hook. The bounded-timeout guard escalates
SIGTERM->grace->SIGKILL before wait (kill; sleep 1; kill -9; wait) so a
SIGTERM-ignoring fmt cannot wedge the turn (the design doc's shipped
kill-then-unbounded-wait snippet was the pre-fix version). The `ailang fmt`
invocation never discards stderr (2>&1 into the capture file, never
2>/dev/null); jq presence is probed up front and the first jq call is
unsuppressed; the silent branch is pinned to exactly exit 3.

Registers the hook opt-in in .claude/settings.json under PostToolUse
matcher Edit|Write, after the existing (unchanged) Go hook.

Manual tests all pass (turn never blocked): (a) valid .ail formatted;
(b) non-parsing .ail -> exit 3 silent defer, file untouched; (c) chmod-000
file -> exit 2 advisory surfaced; (d) SIGTERM-ignoring stub ailang -> reaped
by SIGKILL after grace (~4s, not 300s), file byte-identical, timeout advisory
surfaced, no orphan. Idempotence spot-check: second run is a no-op.
make test green.

Refs #399

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
M3 discovered `fmt-check` is already the Go gofmt CI gate, so the AILANG
drift target ships as `fmt-check-ail`. Update the formatter Adoption section
and the development-workflow cross-links to match, and note why the name
differs.

Refs #399

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The build's embed step copies prompts/ into cmd/ailang/prompts/ (the tree
embedded into the binary); commit the v0.16.3 file + versions.json active
flip so the shipped binary serves the fmt teaching prompt. Also updates the
auto-generated docs/docs/prompts/current.md to reflect the active v0.16.3.

Refs #399

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…mented

Controller finalization for mission iteration 65 (evaluator D1/D2):
- CHANGELOG: add v0.30.0 entry for the fmt-adoption sprint (prompt v0.16.3,
  fmt-check-ail, format_ail.sh hook, formatter.md Adoption section)
- Move design doc + sprint plan planned/ -> implemented/v0_30_0/, status ✅ IMPLEMENTED

Sprint: executor (opus) M1-M3, evaluator (sonnet, generator≠judge) PASS 89/100 r1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sunholo-voight-kampff
sunholo-voight-kampff enabled auto-merge (squash) July 19, 2026 22:45
@sonarqubecloud

Copy link
Copy Markdown

@sunholo-voight-kampff
sunholo-voight-kampff merged commit b787bb9 into dev Jul 19, 2026
18 checks passed
@sunholo-voight-kampff
sunholo-voight-kampff deleted the sprint/m-ailang-fmt-adoption branch July 19, 2026 23:02
sunholo-voight-kampff added a commit that referenced this pull request Jul 19, 2026
… LANDED (#416)

PR #415 squash b787bb9; executor (opus, worktree) M1-M3, evaluator (sonnet,
generator≠judge) PASS 89/100 r1. ailang fmt now discoverable (teaching prompt
v0.16.3) + opt-in auto-format PostToolUse hook w/ Mark-approved SIGKILL escalation.
Controller disproved a false "docs build failure" (skipped CI-only sync-registry.sh
gen step). Post-merge dev CI CI/Build/Deploy-Docs all green @ b787bb9. metered=$0.00.

- Log entry 70; STATUS stamp iter-65 added, iter-62 rotated to archive.
- Queue: m-ailang-fmt-adoption → [LANDED].

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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