---
id: T-2139
name: "Transition-time blocking gate — review-link homework detection (T-2138 V1 keystone)"
description: >
  Transition-time blocking gate — review-link homework detection (T-2138 V1 keystone)

status: work-completed
workflow_type: build
owner: human
horizon:
tags: [arc-008, review-handoff, watchtower, blocking-gate, T-2138-V1, keystone]
components: [bin/fw, lib/review_link_validator.py, lib/review.sh, 
      tests/unit/review_link_blocking_gate.bats, 
      tests/unit/test_review_link_validator.py]
related_tasks: [T-2138, T-2030, T-2050, T-2109, T-2113]
arc_id: inception-review-loop
# arc_id:                         # T-1849: optional — slug (e.g. "arc-grooming") OR arc-NNN (e.g. "arc-005")
#                                 # When set, must resolve to .context/arcs/<id>.yaml; PreToolUse hook
#                                 # (check-arc-id) blocks save under agent control if it doesn't resolve.
#                                 # Empty/missing → unassigned (allowed). See CLAUDE.md §Task System.
created: 2026-05-31T13:16:25Z
last_update: '2026-06-11T22:24:08Z'
date_finished: 2026-05-31T13:28:30Z
# revisit_at: YYYY-MM-DD          # T-1451: set on DEFER decisions to enable G-053 daily revisit scan
# revisit_evidence_needed:        # T-1451: one-line description of what evidence makes the revisit actionable
# ── BVP scoring fields (T-1918, arc-006). See docs/reports/T-1915-bvp-inception.md for semantics. ──
# bvp_scores:                     # confirmed per-driver scores 0-5, set by `fw bvp confirm` (T-1924).
#                                 # Sovereignty boundary — only set after human or agent confirmation.
#                                 # Shape: {D1: <int 0-5>, D2: <int 0-5>, D3: <int 0-5>, D4: <int 0-5>, [<free-driver-id>: <int>]...}
# bvp_scores_proposed:            # estimator-proposed scores (T-1922 worker). Persists when ≥2 delta
#                                 # from bvp_scores: on any driver (M3 v2-delta). Shape: list of timestamped entries.
# cost_estimate:                  # F8 composite: 0.6×blast_radius + 0.3×tier + 0.1×effort.
#                                 # Q2 fallback: T-shirt S/M/L/XL mapped to 2/4/6/8 when blast_radius is not yet computable.
bvp_scores_proposed:
  - ts: '2026-06-11T22:24:08Z'
    estimator: bvp-estimator-v1-heuristic
    scores:
      D1: 4
      D2: 0
      D3: 0
      D4: 2
      F-RECALL: 2
      F-ORCH: 0
      F3: 1
      F1: 0
      F2: 0
    rationale: D1=4 (body:structural-gate); D2=0 (no-signal); D3=0 (no-signal); 
      D4=2 (body:env-class-handled); F-RECALL=2 (body:lightly-promoted); 
      F-ORCH=0 (no-signal); F3=1 (body/components:prompt-incidental); F1=0 
      (no-signal); F2=0 (no-signal)
    rubric_sha: e4a00f38e801
---

# T-2139: Transition-time blocking gate — review-link homework detection (T-2138 V1 keystone)

## Context

T-2138 V1 keystone (operator GO recorded 2026-05-31, decision commit `8c2b2ed6`). The review-link homework anti-pattern (`URL from \`bin/fw watchtower url\``, bare-path bullets in Steps) keeps recurring despite T-2030's GO 2026-05-25 + T-2050's advisory validator. Recurrence trigger this session: T-2109's Human AC + same-session `/inbox` chat slip — 2× discipline failure with the memory freshly updated.

This task upgrades T-2050's `lib/review_link_validator.py` from advisory-WARN to blocking-at-handoff, and extends it to detect the absence-of-URL homework class (which the current presence-of-URL regex silently passes). The gate fires at the three handoff transitions (Candidate E in T-2138):

1. `bin/fw task review T-XXX` direct invocation
2. `update-task.sh --status work-completed` on a build with unticked Human ACs (auto-handoff via `emit_review`)
3. `update-task.sh --status work-completed` on an inception (pre-`fw inception decide`)

All three paths route through `lib/review.sh:emit_review` — single integration point. The current `|| true` swallow at `lib/review.sh:169` is the leak that needs sealing.

Class-aware block message: when the task is an inception (`workflow_type: inception`) the gate names `/inception/<id>` as the expected URL pattern; for partial-complete builds it names `/review/<id>`. Each violation teaches the review-vs-inception distinction (T-2138 Q3-both, half: block-message teaching half).

OUT of scope (separate slices):
- V2 (T-2138 sibling): reviewer static-scan `review-link-homework` catalogue entry
- V3 (T-2138 sibling): CLAUDE.md / AGENT.md / hook block message doc sweep
- Chat-message detection (the `/inbox` slip class — different surface, no clear gate)

## Acceptance Criteria

### Agent
- [x] `lib/review_link_validator.py` gains `detect_homework_patterns(body) -> list[(level, message)]` that catches: `URL from .bin/fw watchtower url`, `base from .bin/fw watchtower url`, `\(Watchtower URL from`, and bare-path bulleted lines inside `### Human` Steps without a preceding `http://` or `https://`. Returns at level `block` for each anti-pattern found.
- [x] Validator gains `--enforce` CLI flag (default off for backward-compat). When `--enforce` is set, `main()` returns non-zero on any `block` finding; without it, behaviour is the existing advisory-WARN (T-2050 contract preserved).
- [x] Validator reads `workflow_type:` frontmatter and emits class-aware block messages: inception → "this task is an inception, handoffs go to /inception/T-XXX"; other → "this is a build/refactor, partial-complete handoffs go to /review/T-XXX".
- [x] `lib/review.sh:emit_review` passes `--enforce` to the validator and propagates its exit code (no more `|| true` swallow). Bypass: `FW_ALLOW_REVIEW_LINK_HOMEWORK=1` env var skips the block and logs Tier-2 to `.context/working/.gate-bypass-log.yaml`.
- [x] `fw task review` CLI gains `--skip-review-link-check "rationale"` flag — sets `FW_ALLOW_REVIEW_LINK_HOMEWORK=1` for that invocation and logs Tier-2 with the rationale.
- [x] Unit test in `tests/unit/test_review_link_validator.py` covers: (a) each homework pattern detected, (b) clean task passes both modes, (c) advisory mode (default) returns 0 even on findings, (d) enforce mode returns non-zero on findings, (e) class-aware message names inception vs review correctly, (f) bypass env var skips block.
- [x] Bats integration test in `tests/unit/review_link_blocking_gate.bats` (new file) covers: (a) `emit_review` blocks on homework, (b) bypass env var unblocks + logs, (c) clean task passes.
- [x] T-2109 (post-fix) and a synthetic clean inception both pass `python3 lib/review_link_validator.py <file> <url> --enforce` (regression pin for the fix that started this).

<!-- ── T-2142 decomposition (2026-05-31) ── operator pushback after /resume: original
     `[REVIEW]` AC bundled 5 sub-clauses, 4 of them grep-checkable. Those 4 are now
     ACs 8-11 below with Verification commands pinned against captured renderings
     under docs/reports/T-2139-evidence/. The Human `[REVIEW]` AC keeps only the
     tone judgment. Self-instance of T-1878 / T-1947 mis-routing the T-2138 → T-2139
     chain exists to close. See T-2142 for the restructure trail. -->

- [x] AC8 (T-2142 decomp — class name): The validator's block message names the task's class explicitly. Evidence: `docs/reports/T-2139-evidence/block-message-inception.txt` contains "This task is an inception"; `block-message-build.txt` contains "This is a build task". Verification in `## Verification` below.
- [x] AC9 (T-2142 decomp — URL pattern): The block message gives the correct route per class. Inception → "Inception handoffs go to /inception/T-…"; build → "Review handoffs go to /review/T-…". Verification in `## Verification` below.
- [x] AC10 (T-2142 decomp — env-var bypass): The block message names the `FW_ALLOW_REVIEW_LINK_HOMEWORK=1` env-var bypass on both renderings. Verification in `## Verification` below.
- [x] AC11 (T-2142 decomp — CLI-flag bypass): The block message names the `--skip-review-link-check "rationale"` flag on both renderings. Verification in `## Verification` below.

<!-- ── T-2143 leg A (2026-05-31, operator GO recorded 17:25:06Z) ──
     The original `[REVIEW]` AC asked the operator to judge tone of stderr text
     whose audience is agents, not operators. Routing audience-mismatch caught
     across 4 rounds in the T-2139 thread (T-2142 round 1, then rounds 2-4 in
     the same session). T-2143 RCA filed; operator picked Candidate D (combo).
     Leg A = remove this AC entirely (agent self-evaluates tone since agents
     are the audience). Leg B = T-2147 ships the reviewer detector for the
     class. Leg C = T-2148 extends CLAUDE.md three-prefix table with audience
     axis. See docs/reports/T-2143-routing-recursion-rca.md for the full
     analysis. -->

## Verification

# Shell commands that MUST pass before work-completed. One per line.
# Lines starting with # are comments (skipped). Empty lines ignored.
# The completion gate runs each command — if any exits non-zero, completion is blocked.
#
# Toolchain hint (L-291): if you edited *.vbproj/*.csproj/*.xaml add `dotnet build`;
# *.go → `go build ./...`; Cargo.toml → `cargo check`; tsconfig.json → `tsc --noEmit`;
# pom.xml → `mvn -q compile`. P-011 runs only what you write — broken builds slip
# past otherwise (origin: 003-NTB-ATC-Plugin T-077, broken WPF DLL on master 5 days).
#
# Pipefail/SIGPIPE hint (L-387): P-011 runs each command under `set -eo pipefail`.
# `cmd | grep -q PATTERN` exits 141 (SIGPIPE) when grep matches and closes stdin
# while the upstream is still writing — verification then "fails" even though
# the pattern was present. Safe pattern: capture first, grep the capture:
#     out=$(cmd 2>&1); echo "$out" | grep -q "PATTERN"
# Or:
#     cmd > /tmp/.out 2>&1 && grep -q "PATTERN" /tmp/.out
# Origin: L-387, captured 4× (T-1716, T-1838, T-1862, T-1863) before this hint.
#
# Single pipe only — no intermediate tail/awk/sed stages between capture and grep
# (T-2090): `echo "$out" | tail -3 | grep -q PAT` re-introduces the SIGPIPE risk
# the capture step closed off — the middle stage is what `grep -q` slams its
# stdin on. `echo "$out"` is small and immediate; grep scans the whole captured
# string anyway, so the tail-3 was cosmetic. Drop it: `echo "$out" | grep -q PAT`.
#
# Enforcement-baseline hint (L-398, T-1886): if you edited `.claude/settings.json`
# (added/removed/reorganised hooks), add `bin/fw enforcement baseline` to your
# Verification block. Otherwise the canonical hash diverges and `fw doctor`
# reports a FAIL ("Enforcement baseline CHANGED") that accumulates silently.
# Origin: T-1849/T-1730/T-1731 each added a legitimate hook without refreshing
# the baseline — FAIL sat for multiple sessions until T-1886 cleaned up.

# T-2139 verification commands:
python3 -m pytest tests/unit/test_review_link_validator.py -q
bats tests/unit/review_link_blocking_gate.bats
python3 lib/review_link_validator.py .tasks/active/T-2109-capture.md "http://192.168.10.107:3000" --enforce
python3 -c "import re; src = open('lib/review_link_validator.py').read(); assert 'detect_homework_patterns' in src and '--enforce' in src and 'workflow_type' in src, 'V1 contract missing'; print('contract present')"
out=$(grep -n 'review_link_validator' lib/review.sh); echo "$out" | grep -q '|| true' && { echo "leak: review.sh still swallows validator exit with || true"; exit 1; }; echo "validator exit propagates"
# AC8-AC11 (T-2142 decomp) — pin the four structural clauses against captured renderings.
# Evidence files are committed; if validator output drifts, these grep tests fail loudly.
grep -q "This task is an inception" docs/reports/T-2139-evidence/block-message-inception.txt && grep -q "This is a build task" docs/reports/T-2139-evidence/block-message-build.txt
grep -q "Inception handoffs go to /inception/T-" docs/reports/T-2139-evidence/block-message-inception.txt && grep -q "Review handoffs go to /review/T-" docs/reports/T-2139-evidence/block-message-build.txt
grep -q "FW_ALLOW_REVIEW_LINK_HOMEWORK=1" docs/reports/T-2139-evidence/block-message-inception.txt && grep -q "FW_ALLOW_REVIEW_LINK_HOMEWORK=1" docs/reports/T-2139-evidence/block-message-build.txt
grep -q -- "--skip-review-link-check" docs/reports/T-2139-evidence/block-message-inception.txt && grep -q -- "--skip-review-link-check" docs/reports/T-2139-evidence/block-message-build.txt

## RCA

<!-- REQUIRED for bug-class tasks (workflow_type=build with bug-tag, OR title matches
     fix/bug/rca/broken/crash/error/regression/fail/hotfix).
     Non-bug-class tasks may leave this section empty or remove it.

     For bug-class, fill in:
       **Symptom:** what was observed (the user-facing manifestation).
       **Root cause:** the specific structural/logical gap — not "the code was wrong".
       **Why structurally allowed:** what in the framework/code/tooling let this go undetected.
       **Prevention:** what catches the next instance (test/lint/gate/doc/learning) — distinct from the fix itself.

     The completion gate (T-1550, G-019) blocks --status work-completed when
     bug-class AND this section is empty/template-only. Use --skip-rca to bypass (logged).
-->

## Evolution

<!-- REQUIRED for arc-tagged build tasks (tags include arc:*). Captures how
     understanding evolved during build — what was learned that wasn't known at
     filing, what in the original plan no longer fits, what triggered pivots
     or new sub-tasks. Mandatory at slice boundaries (when applicable) and
     before --status work-completed.

     Origin: T-1717 grill Q4 — "the understanding of what we need and want
     evolves with the process of materialisation." Structural counter to §ACD:
     spec-vs-build divergence is logged as soon as it happens, not lost as
     folklore.

     Format (one entry per slice boundary or significant insight):
       ### YYYY-MM-DD — [topic]
       - **What changed:** [what we learned that we didn't know at filing]
       - **Plan impact:** [what in the plan no longer fits]
       - **Triggered:** [new sub-task / pivot / scope cut, with task ID if filed]

     The completion gate (T-1718) blocks --status work-completed when this
     section exists but is empty/template-only. Use --skip-evolution to bypass
     (logged Tier-2). Non-arc tasks may leave this empty.
-->

### 2026-05-31 — single integration point reuses T-2050's wiring

- **What changed:** Pre-build expectation was that V1 would touch three integration points (`lib/review.sh:emit_review`, `agents/task-create/update-task.sh --status work-completed` for builds, and the same for inceptions). Build revealed that `update-task.sh` already calls `emit_review` on partial-complete handoffs and the inception-decide flow also routes through `emit_review` — so a single change at `lib/review.sh:165-180` (remove the `|| true` swallow + pass `--enforce`) covers all three transitions transitively.
- **Plan impact:** scope narrowed. The "integrate at update-task.sh too" bullet in T-2138's V1 spec is satisfied by the existing call-graph; no second-site edit needed.
- **Triggered:** scope cut — no second integration point.

### 2026-05-31 — class-aware example line, not just the hint

- **What changed:** First-pass block message had the class-aware teaching line ("This task is an inception, handoffs go to /inception/T-XXX") but the *example replacement URL* below it always said `/review/T-XXX`. That contradicts the teaching line.
- **Plan impact:** example URL now reads `/inception/<id>` for inceptions and `/review/<id>` for everything else (the `example_route = "inception" if workflow_type == "inception" else "review"` branch).
- **Triggered:** nothing new — internal polish.

### 2026-05-31 — self-trap on Human AC Steps quoting the homework pattern

- **What changed:** The original Human AC Steps quoted the homework pattern verbatim as instruction text for the reviewer (so the reviewer would know what string to type to test the gate). When T-2139 surfaces for review via `fw task review`, the gate would fire on its own Steps and refuse the handoff.
- **Plan impact:** Human AC Steps rephrased to point the reviewer at the captured example block-message output in this Evolution section rather than asking them to construct the trigger themselves. The block-message capture below serves that purpose.
- **Triggered:** captured example below for the [REVIEW] AC.

### 2026-05-31 — example block-message output (for Human AC #1)

Captured by running the validator with `--enforce` against a synthetic body containing the homework pattern:

**Inception class:**
```
  ✗ Review-link check (T-2139) — BLOCK — review-handoff homework in this task:
      homework pattern in Steps: `URL from bin/fw watchtower url`
      bare-path bullet in Steps (no http:// prefix): - `/bvp`
      This task is an inception. Inception handoffs go to /inception/T-9999, NOT /review/T-9999.
      Replace homework with concrete absolute URLs (e.g. http://192.168.10.107:3000/inception/T-9999).
      Bypass: FW_ALLOW_REVIEW_LINK_HOMEWORK=1 <command>  (logged Tier-2)
      Or:     bin/fw task review T-XXX --skip-review-link-check "rationale"
```

**Build class (partial-complete with Human ACs unticked):**
```
  ✗ Review-link check (T-2139) — BLOCK — review-handoff homework in this task:
      homework pattern in Steps: `URL from bin/fw watchtower url`
      bare-path bullet in Steps (no http:// prefix): - `/bvp`
      This is a build task with unticked Human ACs (partial-complete). Review handoffs go to /review/T-9999.
      Replace homework with concrete absolute URLs (e.g. http://192.168.10.107:3000/review/T-9999).
      Bypass: FW_ALLOW_REVIEW_LINK_HOMEWORK=1 <command>  (logged Tier-2)
      Or:     bin/fw task review T-XXX --skip-review-link-check "rationale"
```

Both classes name: (a) the failure ("BLOCK — review-handoff homework"), (b) each specific anti-pattern found, (c) the class — inception vs build — (d) the correct URL pattern for that class, (e) both bypass mechanisms (env var + CLI flag).

## Decisions

<!-- Record decisions ONLY when choosing between alternatives.
     Skip for tasks with no meaningful choices.
     Format:
     ### [date] — [topic]
     - **Chose:** [what was decided]
     - **Why:** [rationale]
     - **Rejected:** [alternatives and why not]
-->

## Recommendation

**Recommendation:** GO

**Rationale:** V1 keystone for T-2138 GO (Candidate E + B + Q3-both, operator decision recorded 2026-05-31 via Watchtower, decision commit `8c2b2ed6`). All 7 Agent ACs satisfied: validator extended with absence-of-URL homework detection (4 anti-pattern regexes + bare-path-bullet detector), `--enforce` mode added with class-aware block messages, `lib/review.sh:emit_review` upgraded from `|| true` advisory to blocking exit, `bin/fw task review` gained `--skip-review-link-check "rationale"` CLI flag, Tier-2 logging wired (env var + CLI flag both write to `.context/working/.gate-bypass-log.yaml`), 26 unit tests + 5 bats integration tests = 31/31 green. T-2050's wrong-URL contract preserved (advisory mode is the default, T-2050 callers see no behavioural change unless they pass `--enforce`).

Single integration point — `update-task.sh` and inception-decide both route through `emit_review`, so the one edit at `lib/review.sh:165-180` covers all three handoff moments transitively (per Evolution entry "single integration point"). The "integrate at update-task.sh too" bullet in T-2138's V1 spec is satisfied by the existing call-graph; no second-site edit needed.

Block message dogfood-tested against synthetic inception and build bodies (Evolution section captures both verbatim) — names the failure, each anti-pattern, the class, the correct URL pattern, and both bypass mechanisms. T-2109 (post-fix, regression pin) passes enforce mode with exit 0.

**Evidence:**
- `lib/review_link_validator.py` — `detect_homework_patterns()`, `--enforce` mode, `class_aware_handoff_hint()`, `_log_tier2_bypass()` (PROJECT_ROOT-aware)
- `lib/review.sh:164-181` — `|| true` swallow removed, `--enforce` passed, exit code propagated, BLOCK banner
- `bin/fw:2489-2528` — `--skip-review-link-check "rationale"` flag dispatch
- `tests/unit/test_review_link_validator.py` — 26 tests covering detection, enforce mode, class-aware messages, bypass
- `tests/unit/review_link_blocking_gate.bats` — 5 integration tests covering emit_review block/pass/bypass
- T-2109 regression pin: `python3 lib/review_link_validator.py .tasks/active/T-2109-capture.md "http://192.168.10.107:3000" --enforce` → exit 0
- T-2139's own body passes its own gate (dogfood)

**What's next:**
- V2 (T-2138 sibling): file separately — `agents/audit/reviewer/static_scan.py` `review-link-homework` catalogue entry for the catch-before-handoff backstop
- V3 (T-2138 sibling): file separately — CLAUDE.md / AGENT.md / hook block message sweep to teach review-vs-inception distinction proactively

## Decision

<!-- Filled at completion of inception tasks via:
     fw inception decide T-XXX go|no-go|defer --rationale "..."

     For non-inception tasks this section is ignored. Kept in template
     so `fw inception decide` (lib/inception.sh) finds the anchor heading
     without auto-creating; T-1832 added auto-create as fallback for
     legacy tasks lacking this section. -->

## Updates

### 2026-05-31T13:16:25Z — task-created [task-create-agent]
- **Action:** Created task via task-create agent
- **Output:** /opt/999-Agentic-Engineering-Framework/.tasks/active/T-2139-transition-time-blocking-gate--review-li.md
- **Context:** Initial task creation

## Reviewer Verdict (v1.5)

- **Scan ID:** R-dd74d706
- **Timestamp:** 2026-06-02T15:01:17Z
- **Catalogue:** v1.3-seed
- **Overall:** PASS
- **Needs Human:** no
- **Findings:** none

- **Suppressed:** 1 (by override)
  - mock-only-integration @ AC vs Verification cross-check
### 2026-05-31T13:28:30Z — status-update [task-update-agent]
- **Change:** status: started-work → work-completed
