Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1913002
fix(intake): record WHY the forge refused, not just that it did
sscodeai Nov 8, 2026
ace0334
fix(intake): decide the rounding semantics in the short step too
sscodeai Nov 8, 2026
9285d64
fix(gate): stop the budget from eating the reason it was added for
sscodeai Nov 8, 2026
5544a77
feat(intake): repair the document from what step 1 already decided
sscodeai Nov 8, 2026
d064e71
fix(intake): the repair step can actually run, and the measurement ca…
sscodeai Nov 8, 2026
ac8b592
fix(intake): a step that reads {step.X} must depend on X
sscodeai Nov 8, 2026
3ba6f51
fix(engine): substitute a DOTTED placeholder, so {step.X} reaches its…
sscodeai Nov 8, 2026
7034b45
fix(intake): read a fenced shape answer
sscodeai Nov 8, 2026
11aa404
fix(intake): pass the shape answer through a file, not a quoted argument
sscodeai Nov 8, 2026
67d639b
feat(intake): drop a relation step 1 did not allow
sscodeai Nov 8, 2026
9847394
fix(intake): refuse to repair a document that is not YAML
sscodeai Nov 8, 2026
0f8599b
feat(intake): repair a blocking decision that no check exercises
sscodeai Nov 8, 2026
93970e9
fix(intake): on a QUOTIENT answer, do not write decisions nothing can…
sscodeai Nov 8, 2026
29ee38b
fix(intake): remove a decision no allowed relation can verify
sscodeai Nov 8, 2026
f6b19f1
fix(intake): a differential entry's anchor is a relation kind too
sscodeai Nov 8, 2026
3fb629f
fix(intake): one id per key
sscodeai Nov 8, 2026
5384cfc
docs(measurement): the intake passes on the first attempt and delivers
sscodeai Nov 8, 2026
ddbac28
fix(test): the placeholder guard's capture group is possibly undefined
sscodeai Nov 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/bugs-fixed.md

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions docs/measurements/intake-first-attempt-2026-11-09.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# The intake, on the first attempt, end to end

Measured 2026-11-09, run `wf-20794cb8`.

## The run

Request: a command-line tool that reads `suite,passed,total` and prints a pass percentage per suite.

```
intake_attempt delivery accepted on the FIRST attempt
ambiguity_confirmation approved
judge_forge forged, sha256:53a08b1f0381
artifact_acceptance PASSED (3 checks ok) — ACCEPT-001 written
publish PR #87 opened
merge MERGED, head 746b5cd0
== delivered
```

No repair round, no re-confirmation, no human step.

## What landed

`sscodeai/takumi-delivery-demo` `main`, `docs/requirements/intake.yaml`:

```
run: "bash summary.sh {csv}"
columns: "suite:id,passed:measure,total:other"
relation: derived-ratio
```

## What it took

Fourteen ledger rows (#129–#142), and only two of them were about the intake's *output*:

| # | what was broken |
|---|---|
| #129 | a deterministic repair step, so a missing decided value does not cost a whole rewrite |
| #130 | the step named `{requirement}`, which does not exist at intake time |
| **#131** | **the measurement counted a run that never started as a pass** |
| #132 | a step read `{step.shape_decision}` without depending on that step |
| **#133** | **`renderPrompt` matched `\w+`, which has no dot — so `{step.X}` never substituted, in ANY workflow** |
| #134 | step 1 answers inside a ``` fence, which the key reader could not see |
| #135 | a multi-line answer cannot travel as a quoted shell argument |
| #136 | a relation step 1 did not allow is dropped |
| #137 | the repair edits the document, so it must refuse one that is not YAML first |
| #138 | a blocking decision no check exercises is bound via its `checkedAs` mode |
| #139 | on a QUOTIENT answer, do not write decisions nothing can check |
| #140 | and when the model writes them anyway, remove them |
| #141 | a `differential:` entry names its check with `anchor:`, not `relation:` |
| #142 | two ids on one key |

**Eight of those fourteen were defects in the CHAIN, not in the model's output** — including one
(`#133`) that silently disabled every step-to-step handoff in every workflow, and one (`#131`) that made
the measurement itself lie.

## What this does NOT establish

**One run.** The measured first-attempt rate before this was **1 in 6** across rate9 and rate10 (the two
measurements taken after the chain was functional). A single first-attempt pass does not move that
number, and `intake-reliability` in `docs/limitations.yaml` stays open for exactly that reason: an
unattended run must still be expected to cost two to three attempts for most requests.

What it DOES establish is narrower and worth having: the repairs work, the chain hands its own decisions
from step to step, and a first attempt *can* pass — which was not true while #133 was in place.
48 changes: 47 additions & 1 deletion extensions/skills/req-intake/prompts/shape.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,54 @@ denominator and the ratio — it has no count or sum for them to find, so those
`row-order-invariance` needs no fields at all (it shuffles the input and compares the two reports), and
`mutation-detection` and `browser-scenario` run commands, so all three work for either shape.

**AND THEREFORE, ON A QUOTIENT ANSWER, DO NOT WRITE THOSE DECISIONS AT ALL.** This is the half that has
been costing runs: a ratio document correctly narrowed its relations to the four above and then recorded
blocking decisions "what happens to a malformed row" (`checkedAs: skip-count`) and "what happens to a
repeated id" (`checkedAs: merge`) — decisions that ONLY `malformed-row-accounting` and
`duplicate-resolution` can verify, and those cannot read a ratio line. The forge then refuses:

blocking decision(s) AMB-001, AMB-002 are exercised by no declared relation or anchor

So when a request mentions malformed rows or repeated ids and the answer is a QUOTIENT, do not turn them
into `ambiguities`. State the behaviour in the REQUIREMENT text instead ("a row that cannot form a valid
record is skipped", "rows naming the same id are merged") where it is a plain instruction to the
implementer, and leave the `checkedAs` vocabulary to decisions something can actually check. A decision
nothing can check is worse than no decision: it blocks the run.

The same applies to an AGGREGATE answer only for the relations you did NOT list — if
`malformed-row-accounting` is in your `ALLOWED_RELATIONS`, such a decision IS checkable and belongs in
`ambiguities` with its `checkedAs`.

## The fourth thing: what the ROUNDING answer means to a judge

Every decision a relation settles must carry a `checkedAs:` — a machine-readable word for what the
human's answer MEANS, because prose is for humans and a judge will not guess. Measured 2026-11-08: a
ratio document settled its rounding decision but wrote no `checkedAs`, and the forge refused the whole
document with

the decision AMB-001 is settled by REL-001, and the relation needs to know what its answer MEANS:
give it "checkedAs: <half-up truncate>"

so the run was lost before any code was written. The rule is #12 of the document prompt and it was
ignored there, which is the same thing that happened to the field model (#102), the entry point (#107)
and the relation list (#121).

So decide it HERE, where it is the only question: **for a QUOTIENT answer, which rounding does the
judge apply?**

- `half-up` — a value exactly halfway rounds away from zero (6.25 → 6.3). This is what "round normally",
"round half up", or an unqualified "rounded to one decimal place" means.
- `truncate` — everything after the last printed digit is dropped (6.29 → 6.2, and 6.25 → 6.2).

If the request says "rounded" without qualifying it, answer `half-up`: it is the ordinary reading of
the word, and a document that picks the other one is choosing a behaviour the request did not ask for.

For an AGGREGATE answer whose number is rounded by a relation, the same two words apply; if nothing in
the answer is rounded at all, write `NONE`.

## Your answer

Answer with EXACTLY these six lines and nothing else:
Answer with EXACTLY these seven lines and nothing else:

```
ANSWER_SHAPE: AGGREGATE
Expand All @@ -105,6 +150,7 @@ THE_NUMBER_IS: <one short phrase naming the printed number, e.g. "mean salary pe
THE_TWO_COUNTS_ARE: <for QUOTIENT only: what is divided by what, e.g. "passes divided by total runs". Write NONE for AGGREGATE.>
ENTRY_POINT: bash <name> {csv}
ALLOWED_RELATIONS: <the exact list above for your shape, copied verbatim>
ROUNDING_MEANS: <half-up | truncate | NONE>
WHY_NOT_THE_OTHER: <one sentence: why the other shape does not express this number>
```

Expand Down
40 changes: 39 additions & 1 deletion extensions/workflows/intake-attempt/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ steps:
If it says `ANSWER_SHAPE: AGGREGATE`, use `count`/`sum`/`min`/`max`/`mean` on the per-id line and
do NOT declare `derived-ratio`.

IT ALSO DECIDED WHAT THE ROUNDING ANSWER MEANS, AND `checkedAs:` MUST CARRY IT. Step 1's answer
includes `ROUNDING_MEANS: <half-up | truncate | NONE>`. The decision that settles the rounding
(the one a `derived-ratio` or `independent-aggregation` relation names in `decides:`) MUST carry
`checkedAs: <that word>`, written ON THE AMB-nnn ENTRY next to `chosen:`, never on the relation.
Measured 2026-11-08: a ratio document settled its rounding decision with no `checkedAs`, and the
forge refused the whole document — the run was lost before any code was written. If step 1 said
`NONE` and a relation still settles a rounding decision, write `half-up` and say why in one clause.

IT ALSO DECIDED WHICH RELATIONS ARE POSSIBLE, AND `relations:` MUST BE A SUBSET OF THAT LINE.
Step 1's answer includes `ALLOWED_RELATIONS: ...`. Every `relation:` you write must be named in
it; a relation that is not there is REFUSED by the forge and the run is lost before any code is
Expand Down Expand Up @@ -97,6 +105,36 @@ steps:
produces:
- docs/requirements/intake.yaml
dependsOn: [shape_decision]
# REPAIR THE DOCUMENT FROM WHAT STEP 1 ALREADY DECIDED (ledger #129).
#
# Measured 2026-11-08: the first attempt passes its own gate 1 time in 3, twice over, and with the
# forge's words finally visible (#126/#128) the failures turned out to be the SAME SHAPE — a decision
# step 1 made correctly is missing from the document: `checkedAs:` absent while step 1 answered
# `ROUNDING_MEANS: half-up`; `deliverable.run` absent while step 1 answered `ENTRY_POINT: ...`.
#
# Those are DETERMINISTIC: the answer is already known and the document merely failed to carry it.
# Asking the model to rewrite the whole document to fix a missing word is how the rate stayed at 1 in 3
# through four rounds of prompt rules. This repairs the document from step 1's own answers, and REFUSES
# rather than inventing a decision step 1 did not make.
- id: intake_repair
type: tool
# THE ANSWER GOES IN A HEREDOC, NOT AS A QUOTED ARGUMENT (ledger #135).
#
# Step 1's answer is MULTI-LINE — it arrives inside a ``` fence — and `--shape-text "{step.shape_decision}"`
# splices those newlines into a double-quoted shell argument. Measured 2026-11-08, immediately after #134
# made the fence parse: `/bin/sh: 9: Syntax error: Unterminated quoted string`, and the run died with no
# repair attempted at all. A quoted argument can hold a phrase; it cannot hold a document.
prompt: |
shape_file=$(mktemp)
cat > "$shape_file" <<'TAKUMI_SHAPE_EOF'
{step.shape_decision}
TAKUMI_SHAPE_EOF
bash "$TAKUMI_PROJECT/scripts/intake-repair.sh" --doc docs/requirements/intake.yaml --shape "$shape_file"
rc=$?
rm -f "$shape_file"
exit $rc
dependsOn: [req_intake, shape_decision]
timeoutMs: 60000
- id: intake_shape
# The document's contract IS this attempt's verdict — a `quality_gate`, not an `acceptance`: an
# acceptance is bound to a CONFIRMED requirement and nothing is confirmed yet at intake time, so
Expand All @@ -106,5 +144,5 @@ steps:
type: quality_gate
prompt: |
bash extensions/workflows/request-intake/checks/intake-shape-tap.sh
dependsOn: [req_intake]
dependsOn: [intake_repair]
timeoutMs: 180000
10 changes: 10 additions & 0 deletions extensions/workflows/request-intake/checks/intake-shape-tap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ else
timeout 120 bash "$FORGE" 2>&1)
FORGE_STATUS=$?
rm -rf "$JUDGE_TMP" "$WORK_TMP" "$GATE_DIR"
# THE FORGE'S OWN WORDS, UP FRONT (ledger #126).
#
# `#103` keeps a failing gate's `not ok` lines, but the REASON lives in these comment lines. Measured
# 2026-11-08: every `intake_shape` refusal recorded `not ok 4 - a judge can be forged ... (exit 1: no
# delivery could be judged against this document)` and the sentence that said WHY was past the budget,
# so the one thing a reader needs was the one thing cut. The first line of a forge refusal is its
# verdict, so it goes first, before the transcript that buries it.
if [ "$FORGE_STATUS" -ne 0 ]; then
printf '%s\n' "$FORGE_OUT" | head -1 | sed 's/^/# FORGE SAID: /'
fi
printf '%s\n' "$FORGE_OUT" | sed 's/^/# /'
if [ "$FORGE_STATUS" -eq 0 ] && printf '%s\n' "$FORGE_OUT" | grep -qE '^[[:space:]]*JUDGE_FORGE[[:space:]]*[:=][[:space:]]*ok[[:space:]]*$'; then
ok "a judge can be forged from the document as the confirmation will leave it"
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/quality-gate-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ const TOTAL_BUDGET = 4000;
* Lines that report a failure, across the frameworks this gate meets: TAP (`not ok`), node:test
* (`✗`, `not ok`), mocha/chai (`failing`, numbered `1)` under a `Failing` heading), go test (`--- FAIL`),
* pytest (`FAILED`), cargo (`test ... FAILED`), and rust/assertion markers (`AssertionError`, `Error:`).
*
* LEDGER #128: a tool's own `# FORGE SAID:` / `# REFUSED:` / `# reason:` line is a falsifying line too.
* The gate writes them as comments because TAP reserves `#` for diagnostics, and #103's budget threw
* them away — so the one sentence that named the defect was the one thing cut, twice over (#126 then
* this). A comment is not automatically noise: one that follows a failure is usually the reason.
*/
const FALSIFYING = /^(?:not ok\b|✗|✘|×|---\s*FAIL|\s*✗)|FAILED\b|Failing\b|^AssertionError\b|^\s*Error:/;
const FALSIFYING =
/^(?:not ok\b|✗|✘|×|---\s*FAIL|\s*✗)|FAILED\b|Failing\b|^AssertionError\b|^\s*Error:|^#\s*(?:FORGE|REFUSED|REFUSE|REASON|FATAL|ERROR)\b/i;

/** How many lines the summary may spend on rescuing failures past the head. */
const RESCUE_BUDGET = TOTAL_BUDGET - HEAD_BUDGET;
Expand Down
32 changes: 31 additions & 1 deletion packages/core/src/test/acceptance-gate8.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,34 @@ test('Gate 8: skill without manifest/skill follows step.prompt fallback (never h

test('renderPrompt: unknown placeholders left intact', () => {
assert.equal(renderPrompt('keep {unknown}', {}), 'keep {unknown}');
});
});
// LEDGER #133 — a var name may contain DOTS.
//
// `{step.shape_decision}` is how one workflow step hands its own answer to the next; the engine stores
// it as `vars['step.shape_decision']`. `renderPrompt` substituted with `\w+`, which does NOT match a
// dot, so every such placeholder reached its consumer VERBATIM.
//
// Measured 2026-11-08: two real unattended runs died with "intake-repair: step 1 recorded no
// ANSWER_SHAPE" while step 1 had answered perfectly — the script was handed the literal text
// `{step.shape_decision}`. And because the engine deliberately leaves unknown keys intact (an unfilled
// placeholder should be visible, not blank), nothing threw: the failure surfaced three steps later,
// naming the wrong cause.
test('renderPrompt: a DOTTED placeholder is substituted', () => {
assert.equal(
renderPrompt('answer: {step.shape_decision}', { 'step.shape_decision': 'ANSWER_SHAPE: QUOTIENT' }),
'answer: ANSWER_SHAPE: QUOTIENT',
);
});

test('renderPrompt: dotted and plain placeholders resolve in one template', () => {
const out = renderPrompt(
'{requirement} says {step.shape_decision}',
{ requirement: 'docs/requirements/intake.yaml', 'step.shape_decision': 'QUOTIENT' },
);
assert.equal(out, 'docs/requirements/intake.yaml says QUOTIENT');
});

test('renderPrompt: an unknown DOTTED key is still left intact', () => {
// The deliberate behaviour must survive the widening: a placeholder nobody filled stays visible.
assert.equal(renderPrompt('keep {step.nobody}', {}), 'keep {step.nobody}');
});
Loading
Loading