policy-lib-test.sh reds the suite: a product-decision prose line trips the 68-col check on its em-dashes (byte width, not display width) #48

Closed
opened 2026-08-24 01:58:34 +00:00 by matou-build-agent · 4 comments

Symptom

tests/policy-lib-test.sh FAILS on origin/main (reproduced 2026-08-24 while working #45, on a clean tree — unrelated to #45):

FAIL: trigger_guidance product-decision: line over 68 cols: [A product or scope call — what to build, which trade-off to take —]

The offending line is policy-lib.sh:195 inside policy_trigger_guidance's product-decision case. It contains two em-dashes (U+2014, 3 bytes each in UTF-8); the width check overcounts multibyte characters (byte width, not display width), so the line reads as over the 68-column budget the prose lines are held to.

Impact

A red member of the offline suite reds the for t in tests/*.sh … pre-close gate every worker runs (CLAUDE.md rule 2), masking real reds behind a standing false one.

Ask

Either (a) reflow policy-lib.sh:195 so its DISPLAY width is ≤ 68 (e.g. rewrite the em-dashes as - or shorten the sentence), or (b) make the width check in tests/policy-lib-test.sh count display columns (characters), not bytes, so em-dashes cost 1 column. Prefer (b) if other prose lines legitimately use em-dashes, so the budget is measured the way a reader sees it.

Acceptance

  • bash tests/policy-lib-test.sh exits 0.
  • Whichever fix is chosen keeps the other prose lines within the intended (display) budget.

Found while working #45.

## Symptom `tests/policy-lib-test.sh` FAILS on `origin/main` (reproduced 2026-08-24 while working #45, on a clean tree — unrelated to #45): ``` FAIL: trigger_guidance product-decision: line over 68 cols: [A product or scope call — what to build, which trade-off to take —] ``` The offending line is `policy-lib.sh:195` inside `policy_trigger_guidance`'s `product-decision` case. It contains two em-dashes (U+2014, 3 bytes each in UTF-8); the width check overcounts multibyte characters (byte width, not display width), so the line reads as over the 68-column budget the prose lines are held to. ## Impact A red member of the offline suite reds the `for t in tests/*.sh …` pre-close gate every worker runs (CLAUDE.md rule 2), masking real reds behind a standing false one. ## Ask Either (a) reflow `policy-lib.sh:195` so its DISPLAY width is ≤ 68 (e.g. rewrite the em-dashes as ` - ` or shorten the sentence), or (b) make the width check in `tests/policy-lib-test.sh` count display columns (characters), not bytes, so em-dashes cost 1 column. Prefer (b) if other prose lines legitimately use em-dashes, so the budget is measured the way a reader sees it. ## Acceptance - `bash tests/policy-lib-test.sh` exits 0. - Whichever fix is chosen keeps the other prose lines within the intended (display) budget. Found while working #45.
Author
Member

This was generated by AI during triage.

Triage — verified, root-caused, ruled

Category: bug · State: ready-for-agent

Verification

Confirmed, with a sharper cause than the report states. The check is not
unconditionally byte-counting — it is locale- and awk-implementation
dependent
, which is why it is green on some machines and red on others:

$ bash tests/policy-lib-test.sh                 # gawk 5.2.1, LANG=C.UTF-8
policy-lib: 50 checks passed

$ LC_ALL=C bash tests/policy-lib-test.sh
FAIL: trigger_guidance product-decision: line over 68 cols: [A product or scope call — what to build, which trade-off to take —]

tests/policy-lib-test.sh's prose-width check is awk 'length > 68'. GNU awk
in a UTF-8 locale makes length count characters; mawk — Debian's default
/usr/bin/awk, and any awk under LC_ALL=C — makes it count bytes. The
product-decision line measures 66 characters / 70 bytes (two U+2014
em-dashes, 3 bytes each), so it straddles the 68 budget: passes on one, fails on
the other. Measured across all four triggers, it is the only line that straddles;
none of the others exceed 68 by either measure.

Ruled by agent under ADR 0174 — veto anytime

The ruling: take the report's option (b) — fix the measurement, not the
prose. policy-lib.sh keeps its em-dashes; the check counts display columns.

Why (b), not (a): the budget's stated purpose is a prompt's prose column
("<= 68 cols, leaving room for the renderer's 5-space bullet indent") — a
display budget, so bytes are simply the wrong unit and (a) would bend correct
prose around a broken ruler. (b) is also the low-blast-radius side: policy-lib.sh's
guidance renders into every consumer's prompt.md, so (a) changes live text handed
to future Claude sessions and churns the cutover-proof fixtures; (b) touches a test
file only.

Why this is a two-way door: a test-file-only change, revertible by a later
commit; it widens nothing, spends nothing, and touches no credential or trust surface.

What proves it: bash tests/policy-lib-test.sh must exit 0 under both
LC_ALL=C.UTF-8 and LC_ALL=C, and must still fail on a genuinely over-budget
ASCII line. Probed here — counting codepoints with jq -Rr 'select(length > 68)'
(jq is already a hard harness dependency and is locale-independent) reports
"none over 68" for all four triggers in both locales, and still catches a
69-character ASCII line. That is one viable shape; the agent may pick another that
satisfies the same proof.


Agent Brief

Category: bug
Summary: the prose-width check in the policy-lib test must measure display
columns, deterministically, instead of inheriting awk's locale-dependent notion of
length.

Current behavior: policy_trigger_guidance's emitted lines are held to a
68-column budget by a check whose unit changes with the environment — characters
under gawk + UTF-8, bytes under mawk or LC_ALL=C. The product-decision
guidance (66 chars / 70 bytes) therefore reds the offline suite in byte-counting
environments and passes elsewhere, standing a false red in front of the
for t in tests/*.sh … pre-close gate every worker runs.

Desired behavior: the budget is measured in display columns (Unicode
codepoints)
, identically in every environment. A line of 68 or fewer characters
passes regardless of how many bytes it occupies; a line of 69 or more characters
still fails. policy-lib.sh's wording is unchanged.

Key interfaces:

  • The width assertion inside the policy-lib test's trigger_guidance loop — its
    counting primitive is what changes. Prefer a primitive that cannot be flipped by
    LC_ALL/LANG or by which awk is installed; jq's string length (codepoints)
    is one such, and jq is already a harness dependency.
  • policy_trigger_guidance itself — read-only for this ticket.

Acceptance criteria:

  • bash tests/policy-lib-test.sh exits 0 under LC_ALL=C.UTF-8.
  • bash tests/policy-lib-test.sh exits 0 under LC_ALL=C.
  • The check still fails when fed a line of 69+ ASCII characters (add or adjust a
    negative case so the guard's teeth are proven, not assumed).
  • The full offline suite is green: for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" || echo "FAIL: $t"; done
  • git diff touches no file outside tests/.

Out of scope:

  • Rewording, reflowing, or de-em-dashing any line in policy-lib.sh — the ruling
    above forecloses option (a). No prompt-rendered text changes in this ticket, so
    no fixture re-proof is needed.
  • tests/prompt-render-lib-test.sh carries the same awk 'length > N' idiom at a
    74-column budget. It is currently green in both locales (no line there straddles),
    so it is not part of this fix — worth a follow-up to generalise the primitive,
    not a reason to widen this diff.
  • Any change to the 68-column budget itself.

Notes for the maintainer: this is a small, well-fenced diff — a model-sonnet
override would suit it. Not applied; that stays your call.

Prior-rejection check: this repo has no .out-of-scope/ knowledge base, so
there is nothing on record rejecting this. Redundancy check: searched the
harness and both test trees for an existing display-width helper (length >,
awk 'length, wc -m) — none exists; the only two width checks are the two named
above, both using the byte-fragile idiom.

> *This was generated by AI during triage.* ## Triage — verified, root-caused, ruled **Category:** `bug` · **State:** `ready-for-agent` ### Verification Confirmed, with a sharper cause than the report states. The check is not unconditionally byte-counting — it is **locale- and awk-implementation dependent**, which is why it is green on some machines and red on others: ``` $ bash tests/policy-lib-test.sh # gawk 5.2.1, LANG=C.UTF-8 policy-lib: 50 checks passed $ LC_ALL=C bash tests/policy-lib-test.sh FAIL: trigger_guidance product-decision: line over 68 cols: [A product or scope call — what to build, which trade-off to take —] ``` `tests/policy-lib-test.sh`'s prose-width check is `awk 'length > 68'`. GNU awk in a UTF-8 locale makes `length` count **characters**; `mawk` — Debian's default `/usr/bin/awk`, and any awk under `LC_ALL=C` — makes it count **bytes**. The `product-decision` line measures **66 characters / 70 bytes** (two U+2014 em-dashes, 3 bytes each), so it straddles the 68 budget: passes on one, fails on the other. Measured across all four triggers, it is the only line that straddles; none of the others exceed 68 by either measure. ### Ruled by agent under ADR 0174 — veto anytime **The ruling:** take the report's option **(b)** — fix the *measurement*, not the prose. `policy-lib.sh` keeps its em-dashes; the check counts display columns. **Why (b), not (a):** the budget's stated purpose is a prompt's prose column ("<= 68 cols, leaving room for the renderer's 5-space bullet indent") — a **display** budget, so bytes are simply the wrong unit and (a) would bend correct prose around a broken ruler. (b) is also the low-blast-radius side: `policy-lib.sh`'s guidance renders into every consumer's `prompt.md`, so (a) changes live text handed to future Claude sessions and churns the cutover-proof fixtures; (b) touches a test file only. **Why this is a two-way door:** a test-file-only change, revertible by a later commit; it widens nothing, spends nothing, and touches no credential or trust surface. **What proves it:** `bash tests/policy-lib-test.sh` must exit 0 under **both** `LC_ALL=C.UTF-8` and `LC_ALL=C`, and must still fail on a genuinely over-budget ASCII line. Probed here — counting codepoints with `jq -Rr 'select(length > 68)'` (jq is already a hard harness dependency and is locale-independent) reports "none over 68" for all four triggers in both locales, and still catches a 69-character ASCII line. That is one viable shape; the agent may pick another that satisfies the same proof. --- ## Agent Brief **Category:** bug **Summary:** the prose-width check in the policy-lib test must measure display columns, deterministically, instead of inheriting awk's locale-dependent notion of `length`. **Current behavior:** `policy_trigger_guidance`'s emitted lines are held to a 68-column budget by a check whose unit changes with the environment — characters under gawk + UTF-8, bytes under mawk or `LC_ALL=C`. The `product-decision` guidance (66 chars / 70 bytes) therefore reds the offline suite in byte-counting environments and passes elsewhere, standing a false red in front of the `for t in tests/*.sh …` pre-close gate every worker runs. **Desired behavior:** the budget is measured in **display columns (Unicode codepoints)**, identically in every environment. A line of 68 or fewer characters passes regardless of how many bytes it occupies; a line of 69 or more characters still fails. `policy-lib.sh`'s wording is unchanged. **Key interfaces:** - The width assertion inside the policy-lib test's `trigger_guidance` loop — its counting primitive is what changes. Prefer a primitive that cannot be flipped by `LC_ALL`/`LANG` or by which awk is installed; jq's string `length` (codepoints) is one such, and jq is already a harness dependency. - `policy_trigger_guidance` itself — **read-only for this ticket**. **Acceptance criteria:** - `bash tests/policy-lib-test.sh` exits 0 under `LC_ALL=C.UTF-8`. - `bash tests/policy-lib-test.sh` exits 0 under `LC_ALL=C`. - The check still fails when fed a line of 69+ ASCII characters (add or adjust a negative case so the guard's teeth are proven, not assumed). - The full offline suite is green: `for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" || echo "FAIL: $t"; done` - `git diff` touches no file outside `tests/`. **Out of scope:** - Rewording, reflowing, or de-em-dashing any line in `policy-lib.sh` — the ruling above forecloses option (a). No prompt-rendered text changes in this ticket, so no fixture re-proof is needed. - `tests/prompt-render-lib-test.sh` carries the same `awk 'length > N'` idiom at a 74-column budget. It is currently green in both locales (no line there straddles), so it is **not** part of this fix — worth a follow-up to generalise the primitive, not a reason to widen this diff. - Any change to the 68-column budget itself. **Notes for the maintainer:** this is a small, well-fenced diff — a `model-sonnet` override would suit it. Not applied; that stays your call. **Prior-rejection check:** this repo has no `.out-of-scope/` knowledge base, so there is nothing on record rejecting this. **Redundancy check:** searched the harness and both test trees for an existing display-width helper (`length >`, `awk 'length`, `wc -m`) — none exists; the only two width checks are the two named above, both using the byte-fragile idiom.
Author
Member

This was generated by AI during triage.

Sibling red found while triaging this one: #50 — tests/session-runner-test.sh fails whenever REPO_SLUG is exported, which is precisely the environment run-swarm.sh forwards into every worker container. Same class of standing false red on the pre-close gate, independent cause, independent fix.

> *This was generated by AI during triage.* Sibling red found while triaging this one: #50 — `tests/session-runner-test.sh` fails whenever `REPO_SLUG` is exported, which is precisely the environment `run-swarm.sh` forwards into every worker container. Same class of standing false red on the pre-close gate, independent cause, independent fix.
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=414
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=414 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #48 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 48,
  "status": "success",
  "commits": [
    "a35badb"
  ],
  "changed_files": [
    "tests/policy-lib-test.sh",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash tests/policy-lib-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "bash tests/policy-lib-test.sh exits 0": "tests/policy-lib-test.sh now measures display columns via the dispcols helper (UTF-8 code points = bytes minus 0x80-0xBF continuation bytes); run exits 0 with 50 checks passed (commit a35badb)",
    "Whichever fix is chosen keeps the other prose lines within the intended (display) budget": "Option B chosen: the ceck iterates each guidance line and holds it to <= 68 DISPLAY columns, so the em-dash-bearing prose on policy-lib.sh lines 200/213/219 is measured the way a reader sees it; all four triggers pass, full offline suite green"
  },
  "summary": "Made tests/policy-lib-test.sh's prose-width gate count display columns instead of bytes so em-dashes stop reddening a line that fits.",
  "blockers": []
}
**close-report** for #48 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 48, "status": "success", "commits": [ "a35badb" ], "changed_files": [ "tests/policy-lib-test.sh", "STATUS.md" ], "tests": [ { "command": "bash tests/policy-lib-test.sh", "exit_code": 0 } ], "criteria": { "bash tests/policy-lib-test.sh exits 0": "tests/policy-lib-test.sh now measures display columns via the dispcols helper (UTF-8 code points = bytes minus 0x80-0xBF continuation bytes); run exits 0 with 50 checks passed (commit a35badb)", "Whichever fix is chosen keeps the other prose lines within the intended (display) budget": "Option B chosen: the ceck iterates each guidance line and holds it to <= 68 DISPLAY columns, so the em-dash-bearing prose on policy-lib.sh lines 200/213/219 is measured the way a reader sees it; all four triggers pass, full offline suite green" }, "summary": "Made tests/policy-lib-test.sh's prose-width gate count display columns instead of bytes so em-dashes stop reddening a line that fits.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#48
No description provided.