sc-compose adversarial fuzz report 20261007-1

Phase T t-7: bead attach / by-path pour (ADR-0023) and render --append

Generated: 2026-10-07

FAIL

Summary

Fuzz run descriptionPhase T t-7 full campaign over bead attach / by-path pour (ADR-0023) and render --append: 9 confirmed bugs promoted as ignored regressions.
Iterations1149
Pass1083/1149
ResultFAIL
Fuzz run descriptionIterationsPassResult
ADR-0023 negative contract (id, scope, relation, conflict rows), path confinement and symlinks, render --append failures, exit 3 vs exit 2 285 270/285 FAIL
metamorphic and differential relations: attach twice == once, relation order, CRLF revision, preview == apply, Phase R registry pour vs origin/develop, CLI vs Python receipts, concurrency, determinism 304 289/304 FAIL
request JSON shapes; Unicode/control characters in parent, ref, step ids, relation endpoints and metadata; render --append records 312 296/312 FAIL
bead templates with loops, conditionals and includes producing formulas up to 500 steps; TOML/JSON parity; formula grammar refusals 248 228/248 FAIL

Adversarial fuzz worker

boundary-probe

Session sc-compose-fuzz-20261007-1 · Worker boundary-probe

FAIL

Fuzz run descriptionIterationsPassResult
ADR-0023 negative contract (id, scope, relation, conflict rows), path confinement and symlinks, render --append failures, exit 3 vs exit 2 285 270/285 FAIL: 1 confirmed bug(s)

Inputs exercised

CaseTemplate / inputOutcome
boundary-probe/id_rule_refid_rule_ref6/14 passed
boundary-probe/id_rule_parentid_rule_parent2/7 passed
boundary-probe/id_rule_stepid_rule_step8/8 passed
boundary-probe/scopescope18/18 passed
boundary-probe/request_shaperequest_shape29/29 passed
boundary-probe/relation_requestrelation_request10/10 passed
boundary-probe/relationsrelations14/14 passed
boundary-probe/relation_typesrelation_types18/18 passed
boundary-probe/pour_modepour_mode7/7 passed
boundary-probe/conflict (real bd)conflict (real bd)39/39 passed
boundary-probe/ids_bdids_bd15/15 passed
boundary-probe/pathspaths41/42 passed
boundary-probe/appendappend63/64 passed

Findings

FUZZ-012

Minimal template / frontmatter
wf/m.formula.toml.j2: formula = "m" / version = 1 / type = "workflow" / [[steps]] id = "a" title = "A"
Input
{"operation":"render","working_directory":"<ws>","template":"wf/m.formula.toml.j2","rendered_formula":"<ws>/build/out.formula.toml","compose_variables":{},"bead_variables":{}} (process cwd != working_directory)
Expected
A relative template resolves against working_directory, so the render succeeds from any cwd (ADR-0021 line 207 'All paths resolve relative to working_directory'; help bead request table).
Observed
Exit 3 BEADS_TEMPLATE_PATH_INVALID 'invalid template path: wf/m.formula.toml.j2'. Succeeds only when cwd == working_directory. origin/develop behaves the same (pre-existing). Reproduced 3/3 by the coordinator.
Requirement / ADR
ADR-0021 paths paragraph; help bead request table; ADR-0023 Authorization and confinement
Requirement / ADR follow-up
No new ADR needed; the contract already states the rule.
Root cause
validate_request canonicalizes request.template (and normalize_output the rendered_formula) as given, so relative paths resolve against the process cwd.
Recommended fix
Join relative template/rendered_formula onto the canonical working_directory before canonicalizing and confining.

Adversarial fuzz worker

differential-probe

Session sc-compose-fuzz-20261007-1 · Worker differential-probe

FAIL

Fuzz run descriptionIterationsPassResult
metamorphic and differential relations: attach twice == once, relation order, CRLF revision, preview == apply, Phase R registry pour vs origin/develop, CLI vs Python receipts, concurrency, determinism 304 289/304 FAIL: 2 confirmed bug(s)

Inputs exercised

CaseTemplate / inputOutcome
differential-probe/R1 attach twice == onceR1 attach twice == once36/36 passed
differential-probe/R2 relation order and inputsR2 relation order and inputs40/40 passed
differential-probe/R3 CRLF / lone CR revisionR3 CRLF / lone CR revision48/48 passed
differential-probe/R4 preview == applyR4 preview == apply24/24 passed
differential-probe/R5 head vs origin/developR5 head vs origin/develop51/60 passed
differential-probe/R6 CLI vs Python receiptsR6 CLI vs Python receipts37/37 passed
differential-probe/R7 concurrency (append + attach)R7 concurrency (append + attach)19/25 passed
differential-probe/R8 determinismR8 determinism14/14 passed
differential-probe/R9 extra metamorphicR9 extra metamorphic20/20 passed

Findings

FUZZ-013

Minimal template / frontmatter
formula = "re g0" / version = 1 / type = "workflow" / [[steps]] id = "a" title = "A"
Input
render request with "formula_name":"re g0" (also "café", "a+b", "")
Expected
ADR-0023 Decision 1: additive only; Phase R requests parse unchanged. Baseline accepts these requests (exit 0 render/validate/registry preview-pour).
Observed
Head: exit 3 BEADS_REQUEST_DESERIALIZATION_FAILED 'invalid graph formula ...; follow ADR-0023' for every operation, including render, which never uses the name. formula_name "" now gives deserialization failure instead of BEADS_FORMULA_NAME_REQUIRED on pour. Reproduced 3/3 by the coordinator, head vs baseline.
Requirement / ADR
ADR-0023 Decision 1 and Consequences; ADR-0021 FormulaNameRequired
Requirement / ADR follow-up
Decision owner team-lead: either keep the grammar and amend ADR-0021/0023 (documenting the breaking change), or confine the grammar to the uses that need it (registry path, graph metadata).
Root cause
Commit e1b5168 made BeadComposeRequest.formula_name a validating FormulaName newtype, so serde rejects names outside [A-Za-z0-9_][A-Za-z0-9_.-]* during request parsing.
Recommended fix
Validate formula_name only where it becomes a path or bd argument, with a stable code, and keep Phase R parsing unchanged; or record the break in an ADR.

FUZZ-014

Minimal template / frontmatter
formula = "x" / version = 1 / type = "workflow" / [[steps]] id = "a" title = "A {{{ tag }}}"
Input
request k: ref race<k>, compose_variables {"tag":"T<k>"}, rendered_formula <ws>/build/x.formula.toml
Expected
ADR-0023 Atomic apply and Revision: each request's beads come from its own rendered text; GraphApplyFailed means bd wrote nothing.
Observed
Coordinator repro (3 trials): trial 1: a failed receipt (GraphApplyFailed, 'nothing was written') whose own bd create returned ids for the other request's plan; trial 2: a succeeded receipt for ref race20 created a bead titled 'A T21', i.e. the other request's content. Worker saw cross-contamination in 27/27 trials. Deterministic regression via a path-honest fake bd.
Requirement / ADR
ADR-0023 Decision 6, Graph plan, Revision, Errors (GraphApplyFailed); UC-9
Requirement / ADR follow-up
No new ADR needed for the invariant; if a shared rendered_formula is to be unsupported, document and refuse it.
Root cause
graph::run re-reads rendered_formula from disk and bd cooks it by path, and PendingCreate::execute writes then applies the fixed path <rendered_formula>.graph.json, so concurrent requests sharing the path race on both files.
Recommended fix
Hash and cook the bytes this request rendered (private copy), and write the plan to a per-invocation path or hold a lock across render-cook-apply.

Adversarial fuzz worker

shape-probe

Session sc-compose-fuzz-20261007-1 · Worker shape-probe

FAIL

Fuzz run descriptionIterationsPassResult
request JSON shapes; Unicode/control characters in parent, ref, step ids, relation endpoints and metadata; render --append records 312 296/312 FAIL: 3 confirmed bug(s)

Inputs exercised

CaseTemplate / inputOutcome
shape-probe/f1 request shape (render/validate)f1 request shape (render/validate)73/73 passed
shape-probe/f2 attach request shapef2 attach request shape50/50 passed
shape-probe/f3 attach ids (bd)f3 attach ids (bd)44/52 passed
shape-probe/f4 step content (bd)f4 step content (bd)56/57 passed
shape-probe/f5 attach re-run (bd)f5 attach re-run (bd)12/13 passed
shape-probe/f6 pour (bd)f6 pour (bd)13/14 passed
shape-probe/f7 render --appendf7 render --append48/53 passed

Findings

FUZZ-015

Minimal template / frontmatter
UC-8 loop: formula = "batch" ... {% for i in range(1, count + 1) %}[[steps]] id = "item_{{{ i }}}" ... needs = ["item_{{{ i - 1 }}}"]{% endfor %}
Input
attach, compose_variables {"count":36}, parent <epic>, ref batch
Expected
FR-23.5 / ADR-0023 UC-4, UC-5: re-running an attach whose beads all exist succeeds and writes nothing; UC-8 generates many steps; no step limit is documented.
Observed
First attach creates 36 beads; every re-run or preview-attach exits 2 with BEADS_PROCESS_OUTPUT_LIMIT ('Beads Attach output exceeded the 65536-byte capture limit') and no receipt. Threshold ~34 minimal steps (fewer with metadata). The 500-step attach fails even on its first run (bd show stderr for 500 missing ids ~101 KB) and a 500-step graph preview-pour fails on bd cook --json (78 KB). Reproduced 3/3 by the coordinator at count=36.
Requirement / ADR
FR-23.5, FR-23.6; ADR-0023 UC-4, UC-5, UC-8, UC-9, Conflict rules
Requirement / ADR follow-up
No new ADR needed for re-run; if a step ceiling remains, document it in ADR-0023 and the bead manual.
Root cause
GraphReader::issues issues one `bd show <parent> <every planned id> --json`; bd v1.3.1 prints ~1.9 KB per existing bead, beyond runner PROCESS_OUTPUT_LIMIT_BYTES (64 KiB per stream). The cook --json read hits the same cap for large formulas.
Recommended fix
Batch bd show reads, and size the capture limit for graph reads (or stream-parse) so attach scales to the documented use cases.

FUZZ-016

Minimal template / frontmatter
formula = "one" / version = 1 / type = "workflow" / [[steps]] id = "a" title = "A"
Input
attach request with "parent":"--help" (or "--version"); or relation {"from":"step:a","to":"bead:--db=/nonexistent","type":"related"}
Expected
ADR-0023 Conflict rules / Relation validation: a missing parent is BEADS_GRAPH_PARENT_NOT_FOUND and a missing bead: endpoint is GraphRelationInvalid(bead_not_found). BeadId only requires non-empty, no whitespace.
Observed
Exit 2 failed BEADS_GRAPH_READ_FAILED; argv ['bd','show','--help','--help.inj-a',...] and ['bd','show','--db=/nonexistent',...]: bd parsed the ids as options and, for --db=, opened a different database. Controls with ordinary missing ids give the documented codes. Reproduced 3/3 per variant by the coordinator. No write is reachable.
Requirement / ADR
ADR-0023 Conflict rules, Relation validation; BeadId contract
Requirement / ADR follow-up
No new ADR needed.
Root cause
Request ids are spliced into `bd show <ids...> --json` and `bd dep list <id> --json` with no `--` separator.
Recommended fix
Pass ids after `--` (bd v1.3.1 accepts it) or reject bead ids starting with '-' at the BeadId boundary.

FUZZ-017

Minimal template / frontmatter
{"id": 12345678901234567890123, "amount": 0.10000000000000000001}
Input
no variables; destination absent
Expected
help render 'Appending JSON records' step 2: the object is parsed and re-serialized and only its key order may differ; FR-7 render --append.
Observed
Exit 0; appended {"amount":0.1,"id":1.2345678901234568e+22}. Integers above u64 become lossy floats, long decimals round, 1e2 -> 100.0, -0 -> -0.0. Plain render passes the body unchanged. Reproduced 3/3 by the coordinator; --append does not exist on origin/develop.
Requirement / ADR
FR-7 render --append; FR-8a; help render 'Appending JSON records'
Requirement / ADR follow-up
No new ADR needed; if normalization is intended, the manual must say so.
Root cause
append_json_record parses into serde_json::Value without arbitrary_precision and re-serializes.
Recommended fix
Validate the object but keep the original number tokens (arbitrary_precision or RawValue plus minification).

Adversarial fuzz worker

template-probe

Session sc-compose-fuzz-20261007-1 · Worker template-probe

FAIL

Fuzz run descriptionIterationsPassResult
bead templates with loops, conditionals and includes producing formulas up to 500 steps; TOML/JSON parity; formula grammar refusals 248 228/248 FAIL: 3 confirmed bug(s)

Inputs exercised

CaseTemplate / inputOutcome
template-probe/A render fidelityA render fidelity60/60 passed
template-probe/B TOML vs JSON preview parityB TOML vs JSON preview parity53/53 passed
template-probe/C formula grammar refusalsC formula grammar refusals45/45 passed
template-probe/D/E real attach + re-run fidelityD/E real attach + re-run fidelity11/12 passed
template-probe/scale 30-500 stepsscale 30-500 steps5/10 passed
template-probe/G whitespace/delimiters/includesG whitespace/delimiters/includes21/25 passed
template-probe/H special text through attachH special text through attach12/12 passed
template-probe/I step-id caseI step-id case1/1 passed
template-probe/J graph pour parityJ graph pour parity6/6 passed
template-probe/K ref id rule and scopeK ref id rule and scope10/15 passed
template-probe/revision CRLFrevision CRLF3/3 passed
template-probe/misc includes/pathsmisc includes/paths1/6 passed

Findings

FUZZ-018

Minimal template / frontmatter
main.formula.toml.j2: formula = "inc" / version = 1 / type = "workflow" / @<frag/common.toml.j2> / [[steps]] id = "local" ...; frag/common.toml.j2: [[steps]] id = "shared" title = "Shared step"
Input
render request, compose_variables {}
Expected
help bead 'Shared step blocks': include fragments with sc-compose's @<path> include syntax; FR-23.1 (structure from loops, conditionals, includes); FR-3.
Observed
Exit 0 but the rendered formula keeps the literal line '@<frag/common.toml.j2>'; the same text through plain `sc-compose render` expands the include. A later preview-attach fails with BEADS_COOK_FAILED. Reproduced 3/3 by the coordinator; origin/develop renders the same.
Requirement / ADR
FR-23.1, FR-3, bead manual 'Shared step blocks', ADR-0023 step_construct guidance
Requirement / ADR follow-up
No new ADR needed.
Root cause
render_formula calls Renderer::render_named on the raw template text and bypasses sc-composer's include-expansion pipeline.
Recommended fix
Run include expansion (confined to working_directory) before rendering bead templates.

FUZZ-019

Minimal template / frontmatter
{% if %}
Input
render request, compose_variables {}
Expected
FR-8: diagnostics carry a human-readable message; RenderFailed has a cause message.
Observed
Exit 2, BEADS_RENDER_FAILED, render stage stderr_excerpt and stdout_excerpt empty; text mode prints only 'stage Render: failed (BEADS_RENDER_FAILED)'. Reproduced 3/3 by the coordinator; same on baseline.
Requirement / ADR
FR-8 Determinism and Diagnostics
Requirement / ADR follow-up
No new ADR needed.
Root cause
The receipt built for a render failure drops RenderFailed.message.
Recommended fix
Record the render error message in the render stage's stderr_excerpt, as graph stages do via record_error.

FUZZ-020

Minimal template / frontmatter
formula = "g" / version = 1 / type = "workflow" / [[steps]] id = "a" title = "T a" needs = ["a"]
Input
preview_attach under an existing epic, ref gcx
Expected
ADR-0023 Errors: GraphApplyFailed carries bd's failure cause so the caller can fix it.
Observed
Exit 2 BEADS_GRAPH_APPLY_FAILED with message 'graph apply failed (Some(1)): {; [argv]': the cause is '{', the first line of bd's pretty-printed JSON; the real error (blocking dependency cycle) appears only in stdout_excerpt. Reproduced 3/3 by the coordinator.
Requirement / ADR
ADR-0023 Errors (GraphApplyFailed, GraphReadFailed)
Requirement / ADR follow-up
No new ADR needed.
Root cause
process_failure_cause falls back to stdout and short_cause takes its first non-empty line.
Recommended fix
Parse bd's JSON error object (the `error` field) before falling back to the first line.

Recommendations

9 confirmed bugs, all promoted as ignored regression tests.

Metadata

Campaign idt7-20261007-0001
Session idsc-compose-fuzz-20261007-1
Seed7023
Targetfull
Baselineorigin/develop (080f261)
Head58e3b49
Workers4 x 200 requested cases (actual 285/304/312/248)
Per-worker timeout600 s
Confirmed bugs9 (FUZZ-012..FUZZ-020, all promoted as #[ignore] regression tests)
Intentional boundaries7
Inconclusive10
Environmentbd v1.3.1 in scratch workspaces bound to a throwaway dolt sql-server on 127.0.0.1:62888 (stopped after the campaign); isolated HOME; DO_NOT_TRACK=1 (bd metrics off); no network services.