Skip to content

fix(workflow): a step that concludes blocked: fails the run - #118

Merged
itaior merged 4 commits into
mainfrom
fix/167-blocked-conclusion-fails-step
Nov 23, 2026
Merged

itaior merged 4 commits into
mainfrom
fix/167-blocked-conclusion-fails-step

Conversation

@itaior

@itaior itaior commented Nov 23, 2026

Copy link
Copy Markdown
Member

Refs https://gitlab.tikalk.dev/tikalk/engineering/agentic-sdlc/adlc-workspace/-/issues/167

Why

On 2026-11-22, a #151 re-send ran as run fa82c68a (adlc-cli 2.15.0):

  1. plan (factory-mission --plan) hit the dependency hard gate because #164 was still open. It posted its refusal, set the issue back to spec-gated, wrote {"conclusion":"blocked: dependency-gate on #164 (open)"}, and exited 0.
  2. The engine marked the step complete, so gate-spec paused with "(no agent payload)" and nothing to approve.
  3. The approval then started execute on a mission that had already been refused, and the run had to be terminated by hand.

factory-mission uses blocked: only for final refusals: the dependency gate, a run with no issue, a refused pause publish, a run that ends without an MR, and the record-capture halt. Nothing in a skill can choose the agent's exit code, so the engine has to treat this conclusion as the end of the run.

What changes

In src/workflow/steps/agent.mjs, after an agent step exits 0 and its output is merged:

  • If the conclusion starts with blocked: (any case, after leading spaces), the step fails with that conclusion as the error. The output is still merged, so the error and the conclusion show up in the run.
  • It's a logical failure and never sets fast_failure. The run ends failed, workflow run exits 10, and the Argo lane's retryStrategy does not retry 10. The result is one pod, no gate post and no execute.
  • The check runs before the question payload is read, so a step that refused never pauses to ask.
  • Any other conclusion, including one that mentions blocked: later on, behaves as before.

The README gains a short note in the step-output section.

Tests

  • New file tests/workflow-blocked-conclusion.test.mjs with 10 tests, all in the lane's shape plan → gate-spec → execute:
    • B1: a blocked plan fails the run, execute never runs and the gate never pauses. Case and leading-space variants count too.
    • B2: there is no fast_failure, classifyWorkflowStatus gives 10, and adlc-cli workflow run exits 10 with run_failed that is not aborted.
    • B3: a normal conclusion, one that mentions blocked: later, no conclusion, or no output file all still pause at the gate.
    • B4: a blocked conclusion wins over a question payload.
  • Before the fix, 6 of the 10 failed. The CLI one reproduced fa82c68a exactly: plan completed, then gate-spec paused, exit 3.
  • Full npm test: 1105 of 1109 pass. The 4 failures are the target-branch tests TB1 ×2, TB3, and "no target branch on a single-branch clone", and they fail the same way on a clean main checkout here.

Rollout

This needs a release (2.16.0). Then the agentic-container ADLC_CLI_SPEC pin, then the runner image, then the tikal-infrastructure overlay. After that comes a drill: an issue with an open dependency should give one pod, no gate post and one dependency-gate note.

🤖 Generated with Claude Code

itaior and others added 2 commits November 23, 2026 11:21
An agent step that exited 0 with a `blocked:` conclusion (for example
factory-mission --plan refusing on the dependency gate) completed, so
the next gate paused with nothing to approve and an approval started
execute on a refused mission (adlc-workspace#167, run fa82c68a).

The engine now fails such a step with the conclusion as the error,
before any question payload is read. The run ends failed without
fast_failure, so `workflow run` exits 10 and the lane does not retry.
Other conclusions keep today's behaviour.

Refs adlc-workspace#167

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ct blocked errors

Security review of the blocked-conclusion change: a blocked step keeps
its merged agent output, so an agent-written "aborted" string would have
turned the failure into an abort (exit 1, retried). The engine now
compares `aborted === true`, which only the gate sets. The blocked error
is passed through redactSecrets with the agent's env and kept on one line.

Refs adlc-workspace#167

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@itaior

itaior commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Pushed 7835b7b to address an automated security review of the first commit:

  • An agent-written aborted could select the abort state (fixed). A blocked step keeps its merged agent output, so an "aborted": "…" string would have turned the logical failure into an abort, which exits 1 and is retried. engine.mjs now requires aborted === true in both places. Only the gate sets it, as a boolean, and agent output holds only strings. Test B5 covers this.
  • The conclusion reaches the error unredacted (fixed). The blocked error now goes through redactSecrets with the env the agent ran with, and control characters are collapsed so it stays on one line. Test B6 covers this.

Full suite: 1107 of 1111 pass, with the same 4 target-branch failures as on main.

@itaior itaior left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

factory-review verdict: NOT merge-ready (1 Important open)

Reviewed revision: head 7835b7b / base ac4810c / merge-base ac4810c, detached checkout, all REVIEW.md passes (bugs, security, spec-compliance, quality) via adversarial trio (Auditor / Adversary / Pragmatist) + cross-examination. CI on this head: all green (9 jobs pass). No prior verdict exists on this PR.

Checked: blocked-regex true/false cases · output merged on failure path · blocked-before-question ordering · .aborted reader sweep (both engine sites strict; only writer is gate.mjs:323) · stdout never parsed · redactSecrets pattern/env coverage · no .github/ changes · no existing test touched.

Not checked: the "4 target-branch failures are pre-existing on main" claim (trust-based; falsifiable — run those 4 tests on clean main).

🔴 Important (blocks merge)

F2 — a valid blocked: refusal is silently discarded when any sibling output field is invalid → the exact #167 failure recurs. src/workflow/steps/agent.mjs:205 merges readStepOutput(...) all-or-nothing (:422-430: one non-string value, >16 fields, or a >2048-char value rejects the whole object to {}), and the blocked check at :212 reads the post-validation object. Reproduced live on this head: {"conclusion": "blocked: dependency-gate on #164 (open)", "elapsed": 12} (plausible agent sloppiness) → step COMPLETES, run PAUSES at gate-spec with nothing to approve — the bug this PR fixes. Same for a conclusion longer than 2048 chars. Required correction: make the refusal fail-closed (e.g. sniff blocked: from the raw file before validation, or per-field filtering that preserves a valid conclusion), plus a B1-adjacent test with a poisoned sibling field. Note this also narrows B5's meaning: a boolean aborted: true can never arrive via the file today (string-only validation drops it first), which is why B5 uses "aborted": "true".

💬 Advisory (non-blocking)

  • N1: Leading U+200B (zero-width space) evades /^\s*blocked:/i (agent.mjs:212) — a visual refusal that doesn't fail. No privilege gained; cooperating agents won't do this. Consider stripping format chars before testing.
  • N2 (test gap for F2): no B-series test covers blocked: + poisoned sibling; add one with the fix.
  • N3: tests/workflow-blocked-conclusion.test.mjs:201 — assert.notEqual(failed.status, "aborted") passes vacuously if status is ever omitted; prefer assert.equal(failed.status, "failed"). The real weight is on :197 (r.status === 10).
  • N4: The error is redacted but the raw conclusion persists unredacted in state.json step results (B-series pins plan.output.conclusion == BLOCKED at :150). Pushed refs are scrubbed (refs.mjs:133); local state.json is trusted-local — document that or scrub too.
  • N5: Newline-split credentials evade pattern + exact-match redaction (pre-existing redactor property, not a regression); the control-collapse runs after redaction and doesn't re-join.
  • N6 (latent): profile.envVars is in the agent's env (run.mjs:47-56) but not in the redact call's env (agent.mjs:217). Sole in-tree entry is non-secret (GOOSE_MODE), so zero impact today.
  • N7: C1 controls U+0080–U+009F survive the collapse, unlike the repo's own gate-payload.mjs:26 / ui/ansi.mjs sanitizers. ESC (0x1b) is covered, so ANSI injection is neutralized; consistency fix only.
  • N8: Bidi/zero-width chars survive — visual log spoofing possible, but one-lining + JSON escaping already prevent framing forgery. Social-engineering only.
  • N9: README (:285-293) says "fails the step with that text as the error" but after 7835b7b it is redacted + one-lined, and omits the documented leading-whitespace/case tolerance. One clause fixes the drift.
  • N10: The pre-existing question-budget error (agent.mjs:230) starts with literal blocked: — now a second human-visible blocked: string with a different meaning. No behavior interaction (nothing matches on error text), but consider rewording to avoid future confusion.

Label set to validation: the PR stays in the lifecycle stage until F2 is resolved. Re-review required on any new head before merge-readiness can be declared.

@itaior itaior added the validation Passed automated factory-review validation; awaiting human approval label Nov 23, 2026
…il closed)

factory-review F2 on #118: step output merges all-or-nothing, so a
`blocked:` conclusion next to one invalid sibling field (a number, a
reserved key, >16 fields, a >2048-char value) or in a file that does not
parse was dropped, the step completed, and the run paused at the spec
gate with nothing to approve, the #167 failure again. The refusal is now
read from the raw file before validation.

Also: invisible format characters (U+200B, U+FEFF) before the prefix no
longer hide it; C1 controls are collapsed in the error; the CLI test
asserts run_failed status "failed"; the README says what the error holds.

Refs adlc-workspace#167

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@itaior

itaior commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Response to the factory-review verdict on 7835b7b. I pushed 6b38ebf. A re-review is needed on the new head.

🔴 F2: fixed

The refusal is now read from the raw ADLC_STEP_OUTPUT file, before the all-or-nothing validation. The new helper readBlockedConclusion in src/workflow/steps/agent.mjs:

  • parses the JSON and takes conclusion;
  • if the file isn't valid JSON, falls back to the first "conclusion": "…" string in the text;
  • caps the text at 2048 characters.

The step's merged output still follows the old rules. Only the fail/complete decision comes from the raw file, so it now fails closed.

The new B7 tests reproduced F2 before the fix and pass now. Each one runs a blocked conclusion with a non-string sibling (elapsed: 12), a conclusion over 2048 characters, more than 16 fields, a reserved sibling key, or JSON that doesn't parse. One more test checks that an invalid file without blocked: still completes as before.

💬 Advisory

# Action
N1 Fixed. The prefix is /^[\s\p{Cf}]*blocked:/iu, so U+200B and U+FEFF no longer hide it (test B8).
N2 Fixed with the B7 tests.
N3 Fixed. The test asserts failed.status === "failed".
N4 Left as is. state.json stays trusted-local, the same as every other merged step-output field before this PR, and pushed refs are already scrubbed (refs.mjs).
N5 Left as is. It's a property of the redactor that predates this PR, not a regression.
N6 Left as is. The only in-tree profile.envVars entry is GOOSE_MODE, which isn't secret. Worth a separate issue if profiles ever carry secrets.
N7 Fixed. The collapse now covers U+0080–U+009F (test B6).
N8 Left as is. One line plus JSON escaping already stop anyone forging a frame.
N9 Fixed. The README says the error is redacted and kept on one line, that the prefix may follow whitespace or format characters, and that the refusal is read before validation.
N10 Left as is. Nothing matches on error text, and rewording the question-budget error would touch the existing #148 tests.

On "Not checked": I ran those 4 target-branch tests on a clean origin/main worktree (ac4810c), and the same 4 fail there (115 run, 111 pass).

Full npm test on 6b38ebf: 1115 of 1119 pass, with the same 4 failures.

Security review of 6b38ebf:
- the conclusion is redacted in full, then collapsed and capped, so a
  secret across the 2048-character cut is never half-kept;
- in a file that does not parse, every "conclusion" string is decoded
  (valid escapes one by one) before the prefix check and redaction, so
  glpat-... is redacted as glpat-..., and a blocked conclusion after
  another one still counts.
An unreadable or oversized file keeps today's outcome unless a readable,
bounded part of it says blocked:, so a run that never refused is unchanged.

Refs adlc-workspace#167

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@itaior

itaior commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Pushed a93d2c9 after an automated security review of 6b38ebf:

  • Redact before capping (fixed). The blocked conclusion is now redacted in full first, then collapsed to one line and capped at 2048 characters, so a secret that crosses the cut is never half-kept. Test B9.
  • Decoding in the not-JSON fallback (fixed). Valid escapes in each "conclusion" string are decoded one by one before the prefix check and redaction, so \u0067lpat-… is redacted as glpat-…. Invalid escapes are left as they are. Test B9.
  • Every match counts (fixed). In a file that doesn't parse, every "conclusion" string is checked, not just the first one. Test B9.
  • Unreadable or oversized file (not changed, on purpose). The step keeps today's outcome unless a readable part of the file, within the 64 KiB bound, says blocked:. Failing every unreadable or oversized output file would change runs that never refused, which #167 rules out.

npm test: 1118 of 1122 pass, with the same 4 target-branch failures as on main. The review is needed on this head (a93d2c9) now, not 6b38ebf.

@itaior itaior left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

factory-review verdict: MERGE-READY (0 Important open)

Reviewed revision: head a93d2c9 / base ac4810c / merge-base ac4810c, detached checkout at exact head, all REVIEW.md passes (bugs, security, spec-compliance, test-integrity, ci-integrity, quality) via adversarial trio (Auditor / Adversary / Pragmatist) + cross-examination. This re-review was required: the iter-0 verdict on 7835b7b named a superseded head (pushes 6b38ebf, a93d2c9 followed). F2 from iter-0 is fixed and verified below.

Prior verdict delta: F2 (valid blocked: discarded on poisoned sibling) is resolved — refusal is now read from the raw file via readBlockedConclusion before validation (fail closed), with B7 tests reproducing each poisoned case. Redact-then-cap order fixed (B9), fallback decodes escapes and checks every match (B9), Cf-tolerant prefix (B8). All 23 B-tests pass locally; CI on this head is 11/11 green.

Checked: blocked-prefix true/false cases incl. Cf chars · fail-closed on all 5 B7 poison shapes · blocked-before-question ordering (code + B4) · output merged on failure path · fast_failure never set on blocked path · exit-10 mapping · redact-whole-then-cap order · tolerant decode edge cases (trailing backslash, partial \u, double-escape) · .aborted reader sweep (both engine sites strict === true, sole writer gate.mjs:323 boolean) · stdout never parsed · no .github/ changes in PR diff · no existing test touched (tests diff is one new file, +285/−0).

Not checked: full-suite "1115 of 1119" claim (trust-based; CI green corroborates) · author's clean-main reproduction of the 4 target-branch failures (claim is falsifiable as stated: ac4810c worktree, 115 run / 111 pass, same 4 fail).

💬 Advisory (non-blocking)

  • N1 (tag=disputed): valid-JSON wrong-shape file misses a refusal. src/workflow/steps/agent.mjs:289-294 — [{"conclusion":"blocked: x"}], {"data":{"conclusion":"blocked: x"}}, or {"conclusion":["blocked: x"]} parse successfully, push no candidate, and the raw scan only runs in the catch branch, so the step COMPLETES. Adjudicated Nit (Auditor challenge upheld): no documented contract shape is an array/nesting, and an agent trying to evade would simply write a non-blocked: conclusion — but the README's "counts even when the rest of the file breaks the rules" promise reads broader than the implementation. Suggestion: also run the CONCLUSION_IN_RAW scan when parsing yields no candidate (union, then prefix-match). Trivial, zero-risk hardening.
  • N2 (tag=disputed): refusal past the 64 KiB head slice is missed. agent.mjs:288 — only the first 64 KiB is scanned; ~64 KiB of prefix junk pushes a refusal out of the window while readStepOutput rejects the same file as too large. Adjudicated Nit: requires a pathological file no honest agent writes. Suggestion: scan a tail window too, or document the bound as fail-open-by-design.
  • N3 (tag=solo): profile.envVars secrets never reach any redactor. agent.mjs:221 redacts with {...process.env, ...runEnv}, but the agent child env is process.env + profile.envVars + runEnv (run.mjs:47-56) — runContextEnv carries no profile vars, so the exact-value leg misses profile-only secrets echoed in a conclusion. Same gap in redactRunDir/redactDeep defaults. Latent today (sole in-tree entry is non-secret GOOSE_MODE; pattern/userinfo redaction still applies), same class as iter-0 N6 which the author deferred. Suggestion: follow-up issue threading the agent's full env into the redact calls, incl. shell.mjs:127-128 which drops even the step's own env: secrets.
  • N4 (tag=disputed): shell step merges conclusion but ignores blocked:. shell.mjs:119-123 — same file lifecycle, same merged key, opposite outcome vs agent steps. Adjudicated Nit (Auditor challenge upheld): the #167 contract and every commit message scope this to agent (command/prompt) steps, and shell has no refusal convention — but the merged-but-inert key will mislead future readers. Suggestion: one README clause stating blocked: is agent-only, or share the helper (it already imports from agent.mjs).
  • N5 (tag=solo): inner/trailing Cf/bidi controls survive in the error. agent.mjs:221,300 — only leading [\s\p{Cf}] is stripped; U+202E, U+2066–U+2069, U+200B etc. persist into state.error → log → run_failed → notifier rendering (ESC/ANSI is dead — 0x1B is stripped — so this is bidi-spoofing/social-engineering only, same class as iter-0 N8). Suggestion: strip \p{Cf} everywhere in the error, not just leading.
  • N6 (tag=solo): question-budget error squats the blocked: namespace. agent.mjs:234 — operator-owned guard error shares the now agent-controlled prefix. No consumer matches on error text today (verified by grep), so no behavior impact; triage-confusion only. Same as iter-0 N10, kept for consistency.
  • N7 (tag=solo): CONCLUSION_IN_RAW comment omits truncation-tolerance. agent.mjs:265-267 — the missing closing-quote anchor is load-bearing (matches secrets split by the 64 KiB cut, per B9); one word would save the next reader a re-derivation. Optional.

No finding above blocks merge-readiness per REVIEW.md severity weights. Prior iter-0 advisories N1–N10: N1, N2, N3, N7, N9 fixed at 6b38ebf; N4–N6, N8, N10 intentionally left as-is by the author (documented in thread) and carried above where still applicable (N3, N5, N6).

Label stays validation: automated validation passed; a human code-owner's explicit approval is still required — this verdict never approves and never merges.

@itaior
itaior merged commit fb91c1e into main Nov 23, 2026
10 checks passed
itaior added a commit that referenced this pull request Nov 23, 2026
#118 (a step that concludes blocked: ends the run; adlc-workspace#167)
is on main, so the v2.15.1 tag ships it; list it in the 2.15.1 section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

validation Passed automated factory-review validation; awaiting human approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants