diff --git a/docs/reference/FEATURES.md b/docs/reference/FEATURES.md index 2c30f9d8a..61ae0a438 100644 --- a/docs/reference/FEATURES.md +++ b/docs/reference/FEATURES.md @@ -20,7 +20,7 @@ GENERATED , do not hand-edit. Regenerate: `bash lib/registry/feature-registry.sh | `/kit:design` | `[H/I]` | Opt-in interactive solution-design beat between /think and /spec. Use when the operator wants to shape HOW to build after the idea passed /… | SPEC-003, SPEC-004, SPEC-005 +162 | test-anomalies-advisor.sh, test-board-mirror-cleanup.sh, test-ceremony-fits-diff.sh +40 | | `/kit:devs-team` | `[H/I]` | Parallel multi-lens critique of a solution design (the active spec if present, else the decision brief). Dispatches 5 engineering lenses, m… | SPEC-016, SPEC-018, SPEC-019 +14 | test-gate-vocab-recording.sh, test-meta-review-verifiers.sh, test-meta-spec-depth.sh +1 | | `/kit:dispatch` | `[H/I]` | Fire several disjoint VALIDATED specs concurrently, each in its own worktree, then converge. Cross-goal fan-out behind a disjointness gate … | SPEC-002, SPEC-016, SPEC-017 +114 | test-advisor.sh, test-agent-effectiveness.sh, test-attempt-state-race.sh +52 | -| `/kit:docs` | `[H/I]` | Update all project documentation to match the current codebase. Cross-references the diff against every doc file and fixes drift. | SPEC-001, SPEC-002, SPEC-003 +292 | conform.sh, test-active-spec-pick.sh, test-adapters.sh +161 | +| `/kit:docs` | `[H/I]` | Update all project documentation to match the current codebase. Cross-references the diff against every doc file and fixes drift. | SPEC-001, SPEC-002, SPEC-003 +292 | conform.sh, test-active-spec-pick.sh, test-adapters.sh +162 | | `/kit:draft-agent` | `[H/I]` | Meta-agent agent-builder. From a one-line description, generates a new subagent definition OR a mega-goal sub-goal file and (by default) in… | SPEC-089, SPEC-108, SPEC-139 +1 | test-agent-effectiveness.sh, test-command-emit-sweep.sh, test-meta-agent.sh +1 | | `/kit:execute` | `[H/I]` | Whole-spec execution with verification. Dispatches one builder for the whole spec, verifies every task's criteria once at the end, retries … | SPEC-001, SPEC-003, SPEC-004 +82 | test-board-work.sh, test-break-it.sh, test-config-registry.sh +29 | | `/kit:explain` | `[H/I]` | Turn a merged change into a literate-diff explainer a human READS to understand: background -> goal + intuition -> a prose-ordered diff -> … | SPEC-050, SPEC-060, SPEC-094 +25 | test-boundary-lint.sh, test-clean-room.sh, test-command-emit-sweep.sh +13 | @@ -40,8 +40,8 @@ GENERATED , do not hand-edit. Regenerate: `bash lib/registry/feature-registry.sh | `/kit:review` | `[H/I]` | Paranoid code review. Security, architecture, regressions, missing tests, edge cases. Produces actionable TODOS. | SPEC-001, SPEC-002, SPEC-003 +155 | smoke.sh, test-adopt.sh, test-advisor.sh +90 | | `/kit:ship` | `[H/I]` | Ship: review gate, tests, version bump, changelog, conventional commit, docs update, PR. Complete pipeline from done to merged. | SPEC-001, SPEC-002, SPEC-003 +111 | test-active-spec-pick.sh, test-adopt.sh, test-board-mirror.sh +64 | | `/kit:spec-validate` | `[H/I]` | Adversarial review of a spec before implementation. 7 specialist lenses attack the spec from different angles (6 advisory, 1 blocking on th… | SPEC-002, SPEC-003, SPEC-004 +70 | test-command-emit-sweep.sh, test-design-record.sh, test-every-step-review.sh +10 | -| `/kit:spec` | `[H/I]` | Generate a development spec from a feature idea or decision brief. Creates docs/specs/ with structured requirements. | SPEC-001, SPEC-002, SPEC-003 +241 | test-active-spec-pick.sh, test-audit-verdict-grammar.sh, test-bin-forwarders.sh +109 | -| `/kit:start` | `[H/I]` | Detect project state and suggest the right next command. The entry point for any session. | SPEC-002, SPEC-003, SPEC-004 +94 | test-anomalies-advisor.sh, test-audit-cadence.sh, test-board-add.sh +95 | +| `/kit:spec` | `[H/I]` | Generate a development spec from a feature idea or decision brief. Creates docs/specs/ with structured requirements. | SPEC-001, SPEC-002, SPEC-003 +241 | test-active-spec-pick.sh, test-audit-verdict-grammar.sh, test-bin-forwarders.sh +110 | +| `/kit:start` | `[H/I]` | Detect project state and suggest the right next command. The entry point for any session. | SPEC-002, SPEC-003, SPEC-004 +94 | test-anomalies-advisor.sh, test-audit-cadence.sh, test-board-add.sh +96 | | `/kit:test-plan-review-team` | `[H/I]` | Parallel multi-lens adversarial critique of a spec's test plan (the ## Test plan section), with a bounded revise loop that tightens it. Dis… | SPEC-031, SPEC-052, SPEC-062 +14 | test-meta-docs-registry.sh, test-meta-review-verifiers.sh, test-meta-vmodel-dispatch.sh +3 | | `/kit:test-plan` | `[H/I]` | Derive a test-case coverage matrix from a spec's acceptance criteria before /kit:execute. Writes a `## Test plan` section into the active s… | SPEC-004, SPEC-016, SPEC-018 +38 | test-ceremony-lens.sh, test-e2e.sh, test-gate-ledger-inherit.sh +15 | | `/kit:test-write` | `[H/I]` | Turn a SOLID-verdict `## Test plan critique` into real, executing test code via `kit:test-writer`, one case per matrix row. Never dispatche… | SPEC-203, SPEC-227, SPEC-237 +2 | test-test-writer-contract.sh | @@ -153,7 +153,7 @@ GENERATED , do not hand-edit. Regenerate: `bash lib/registry/feature-registry.sh | `classify floor` | `[V]` | `lib/classify/lane-classify.sh` | the diff floor: full when changed paths hit a hard path, else the size floor for the chosen lane | SPEC-036, SPEC-044, SPEC-045 +77 | test-active-spec-pick.sh, test-ceremony-fits-diff.sh, test-clean-room.sh +48 | | `classify risk` | `[V]` | `lib/classify/lane-classify.sh` | risk verdict for a task and its files: full when the lane is full or a full-lane flag fires | SPEC-036, SPEC-044, SPEC-045 +77 | test-active-spec-pick.sh, test-ceremony-fits-diff.sh, test-clean-room.sh +48 | | `flick` | `[V]` | `lib/decide/flick.sh` | pick one of N through a decision API; shadow-only, fails open, always exit 0 | SPEC-381, SPEC-427 | test-bin-forwarders.sh, test-flick.sh, test-hooks.sh +2 | -| `lane data` | `[V]` | `lib/gate/lane-data.sh` | the one reader of lane data ([lane.] and [lanes] in kit.toml) for the gate ledger and the classifier | SPEC-044, SPEC-045, SPEC-048 +47 | test-active-spec-pick.sh, test-clean-room.sh, test-codex-hooks.sh +40 | +| `lane data` | `[V]` | `lib/gate/lane-data.sh` | the one reader of lane data ([lane.] and [lanes] in kit.toml) for the gate ledger and the classifier | SPEC-044, SPEC-045, SPEC-048 +47 | test-active-spec-pick.sh, test-clean-room.sh, test-codex-hooks.sh +41 | | `orchestrate --backend orca` | `[V]` | `lib/queue/orca-backend.sh` | opt-in Orca backend for the mega runner: sub-goals as Orca Tasks with supervised workers, state read live | SPEC-370 | test-orchestrate-orca.sh | | `push-refs` | `[V]` | `lib/gate/push-refs.sh` | fail-closed parser that names which refs a shell command pushes, used by the ship-gate | SPEC-044, SPEC-045, SPEC-048 +43 | test-active-spec-pick.sh, test-clean-room.sh, test-codex-hooks.sh +37 | | `recheck-sample decide` | `[V]` | `lib/gate/recheck-sample.sh` | decide and record whether an execute run rechecks its end-verifier PASSes, keyed on the rid | SPEC-369, SPEC-421 | test-whole-spec-dispatch.sh | diff --git a/docs/verification/l312-lane-prune.md b/docs/verification/l312-lane-prune.md new file mode 100644 index 000000000..bf9db56e1 --- /dev/null +++ b/docs/verification/l312-lane-prune.md @@ -0,0 +1,186 @@ +# Verification: l312-lane-prune + +Headless shell library fix (`lib/gate/lane-data.sh`, branch `l312-lane-prune`, off `origin/master` `e75b5b2d`): no visible surface. + +## Cause and baseline reproduction + +In `lib/gate/lane-data.sh` (`lane_effective`), the awk rule matching a `lane-lower` override row checked only `$2 == "GATE" && $3 == "lane-lower" && $4 == "override"`, ignoring the writer tag (`$NF == "via=lane-lower"`). On a run started in a lighter lane under a stricter spec `Lane:` header (for example `START lane=tiny` under `Lane: full`), a hand override (`gate-ledger.sh override lane-lower "full -> tiny: x"`, tagged `| via=hand`) followed by a plain `start --amend tiny` (which required no `--lower` because the ledger lane was already `tiny`) lowered the resolved check lane from `full` to `tiny`. Two adjacent parsing bugs sat on the same line: `split($5, p, " -> "); t = p[n]` broke when a sanctioned `--reason` contained `" -> "` and accepted rows with no arrow at all (`n == 1`), and an intervening non-amend row did not clear `pend`. + +Baseline red run of `tests/test-lane-lower-via.sh` on unchanged `origin/master` (`e75b5b2d`): + +```text +Command: bash tests/test-lane-lower-via.sh +Exit: 1 +Output: +=== hand override of lane-lower cannot lower check lane === + FAIL override lane-lower (via=hand) + start --amend tiny stays full (got 'tiny', want 'full') + FAIL override lane-lower with forged trailing via=lane-lower stays full (got 'tiny', want 'full') +=== non-lane-lower writer tags and tag-less rows cannot lower check lane === + FAIL lane-lower row with via=hand does not sanction amend (got 'tiny', want 'full') + FAIL lane-lower row with via=plan does not sanction amend (got 'tiny', want 'full') + FAIL lane-lower row with via=batch does not sanction amend (got 'tiny', want 'full') + FAIL lane-lower row with via=inherit does not sanction amend (got 'tiny', want 'full') + FAIL tag-less lane-lower row reads as hand and does not sanction amend (got 'tiny', want 'full') +=== adjacency and format checks on via=lane-lower rows === + FAIL intervening line clears pending lane-lower before START-AMEND (got 'tiny', want 'full') + FAIL lane-lower row without arrow does not sanction amend (got 'tiny', want 'full') + PASS lane-lower aimed at tiny does not sanction amend to normal +=== sanctioned start --amend --lower still lowers check lane === + PASS start --amend --lower --reason lowers full to tiny + FAIL reason containing ' -> ' still resolves target lane normal (got 'full', want 'normal') + PASS reason containing ' | ' still recognizes trailing via=lane-lower + PASS later non-lower amend after lowering restores stricter header full +=== direct lane_effective source check === + FAIL direct lane_effective rejects hand-bypass (got 'tiny', want 'full') + PASS direct lane_effective accepts sanctioned lowering +--- +PASS=5 FAIL=11 +Verdict: RED (reproduced on unchanged origin/master) +``` + +## Fix + +1. `lib/gate/lane-data.sh`: require `NF >= 6 && $NF == "via=lane-lower"` on `GATE | lane-lower | override` rows in `lane_effective`, parse the target lane from `p[2]` only when `split($5, p, " -> ")` yields `n >= 2`, clear `pend` on any non-matching intervening line, and remove the unused local variable `applies` in `_lane_resolve_layers` so `shellcheck -S warning` passes. +2. `tests/test-lane-lower-via.sh`: regression suite covering hand overrides, forged trailing `via=lane-lower`, other writer tags (`via=plan`, `via=batch`, `via=inherit`), tag-less legacy rows, intervening rows, arrow-less rows, target mismatch, reasons containing `" -> "` and `" | "`, subsequent non-lower amends, and direct `lane_effective` calls. +3. `docs/reference/FEATURES.md`: regenerated via `bash lib/registry/feature-registry.sh check --fix` to index the new test suite. + +## Green runs + +### 1. New regression suite on bash 5 and macOS bash 3.2, plus shellcheck + +```text +Command: shellcheck -S warning lib/gate/lane-data.sh tests/test-lane-lower-via.sh && bash tests/test-lane-lower-via.sh && /bin/bash tests/test-lane-lower-via.sh +Exit: 0 +Output: +=== hand override of lane-lower cannot lower check lane === + PASS override lane-lower (via=hand) + start --amend tiny stays full + PASS override lane-lower with forged trailing via=lane-lower stays full +=== non-lane-lower writer tags and tag-less rows cannot lower check lane === + PASS lane-lower row with via=hand does not sanction amend + PASS lane-lower row with via=plan does not sanction amend + PASS lane-lower row with via=batch does not sanction amend + PASS lane-lower row with via=inherit does not sanction amend + PASS tag-less lane-lower row reads as hand and does not sanction amend +=== adjacency and format checks on via=lane-lower rows === + PASS intervening line clears pending lane-lower before START-AMEND + PASS lane-lower row without arrow does not sanction amend + PASS lane-lower aimed at tiny does not sanction amend to normal +=== sanctioned start --amend --lower still lowers check lane === + PASS start --amend --lower --reason lowers full to tiny + PASS reason containing ' -> ' still resolves target lane normal + PASS reason containing ' | ' still recognizes trailing via=lane-lower + PASS later non-lower amend after lowering restores stricter header full +=== direct lane_effective source check === + PASS direct lane_effective rejects hand-bypass + PASS direct lane_effective accepts sanctioned lowering +--- +PASS=16 FAIL=0 +Verdict: PASS +``` + +### 2. Local gate-ledger suites + +```text +Command: bash tests/test-gate-ledger-amend.sh && bash tests/test-gate-ledger-override-via.sh && bash tests/test-gate-ledger-check-cache.sh +Exit: 0 +Output: +gate-ledger amend: 39/39 passed +passed 20, failed 0 +Passed: 48 / 48 +All gate-ledger check cache tests passed. +Verdict: PASS +``` + +### 3. Repo lints, contract checks, and feature registry + +```text +Command: bash tests/test-no-personal-paths.sh && bash tests/test-no-scattered-ids.sh && bash tests/test-operator-pin.sh && bash tests/test-kit-contract.sh && bash tests/test-boundary-lint.sh && bash tests/test-mktemp-template-guard.sh && bash tests/test-meta-docs-registry.sh && bash tests/test-meta-hard-claims.sh && bash scripts/secret-scan.sh && bash scripts/check-owners.sh +Exit: 0 +Output: +Passed: 3 / 3 +test-no-scattered-ids: all 9 passed +operator-pin: 4 passed, 0 failed +=== kit-contract: 33 passed, 0 failed === +=== 36/36 passed === +=== 11 passed, 0 failed === +Passed: 123 / 123 +Passed: 25 / 25 +secret-scan: 2317 tracked files, no secret found +owners: 14 paths, all have a row +Verdict: PASS +``` + +## Negative control + +### 1. Drop writer-tag check (`NF >= 6 && $NF == "via=lane-lower"`) + +```text +Command: bash scripts/negctl.sh "bash tests/test-lane-lower-via.sh" "perl -i -pe 's/ && NF >= 6 && \\\$NF == \"via=lane-lower\"//' lib/gate/lane-data.sh" +Exit: 0 +Output: +Command: bash tests/test-lane-lower-via.sh +Exit: 1 +Output: + FAIL tag-less lane-lower row reads as hand and does not sanction amend (got 'tiny', want 'full') +... + FAIL direct lane_effective rejects hand-bypass (got 'tiny', want 'full') + PASS direct lane_effective accepts sanctioned lowering +--- +PASS=8 FAIL=8 +Verdict: RED, as expected +``` + +Restored automatically by `scripts/negctl.sh` via `git checkout`; tree clean and post-restore check exited `0`. + +### 2. Revert target arrow index (`p[2]` back to `p[n]`) + +```text +Command: bash scripts/negctl.sh "bash tests/test-lane-lower-via.sh" "perl -i -pe 's/t = p\[2\]/t = p[n]/' lib/gate/lane-data.sh" +Exit: 0 +Output: +Command: bash tests/test-lane-lower-via.sh +Exit: 1 +Output: + PASS start --amend --lower --reason lowers full to tiny + FAIL reason containing ' -> ' still resolves target lane normal (got 'full', want 'normal') + PASS reason containing ' | ' still recognizes trailing via=lane-lower + PASS later non-lower amend after lowering restores stricter header full +--- +PASS=15 FAIL=1 +Verdict: RED, as expected +``` + +Restored automatically by `scripts/negctl.sh` via `git checkout`; tree clean and post-restore check exited `0`. + +### 3. Remove intervening-line pending clear (`{ pend = "" }`) + +```text +Command: bash scripts/negctl.sh "bash tests/test-lane-lower-via.sh" "perl -i -pe 's/\{ pend = \"\" \}//' lib/gate/lane-data.sh" +Exit: 0 +Output: +Command: bash tests/test-lane-lower-via.sh +Exit: 1 +Output: + FAIL intervening line clears pending lane-lower before START-AMEND (got 'tiny', want 'full') + PASS lane-lower row without arrow does not sanction amend + PASS lane-lower aimed at tiny does not sanction amend to normal +--- +PASS=15 FAIL=1 +Verdict: RED, as expected +``` + +Restored automatically by `scripts/negctl.sh` via `git checkout`; tree clean and post-restore check exited `0`. + +## Not proven locally + +- `tests/test-lane-effective.sh` and `tests/test-lanes-data.sh` run on CI only (local push-pattern suites are deferred to GitHub Actions macOS + Ubuntu). + +## Rollback + +Revert the branch commits to restore `lib/gate/lane-data.sh`, `tests/test-lane-lower-via.sh`, and `docs/reference/FEATURES.md` to `e75b5b2d`: + +```bash +git revert --no-edit +``` + +No ledger file format or on-disk state changes; `gate-ledger.sh start --amend --lower` already emits `| via=lane-lower`. diff --git a/lib/gate/lane-data.sh b/lib/gate/lane-data.sh index 32ea7b939..504f6d9f6 100644 --- a/lib/gate/lane-data.sh +++ b/lib/gate/lane-data.sh @@ -102,7 +102,7 @@ lane_spec_header() { # answers; ledgers are never rewritten. # Check lane (the ship check): the STRICTER of the spec header and the ledger lane, by lane_rank_of, so a # plain START cannot shed the header's gates. Two exceptions: an amend written through `--lower --reason` -# (it is preceded by its `lane-lower` override line) may go below the header, and a tie in rank keeps the +# (it is immediately preceded by its `lane-lower` override line tagged `via=lane-lower`) may go below the header, and a tie in rank keeps the # older winner (amend: the ledger lane; start: the header). A lane with no rank (a lanes.d overlay lane, or # an unknown header) never lowers a ranked one: an unranked ledger lane yields to a kit-lane header, and an # unranked header under a plain START still wins, as before, so check() fails closed on it. @@ -117,9 +117,12 @@ lane_effective() { IFS=$'\t' read -r lane src lowered < <(awk -F' [|] ' -v names=" $(lane_declared_names) " ' function lane_of(s) { if (match(s, /lane=[^ ]+/)) return substr(s, RSTART + 5, RLENGTH - 5); return "" } function ok(l) { return l != "" && index(names, " " l " ") > 0 } - $2 == "GATE" && $3 == "lane-lower" && $4 == "override" { n = split($5, p, " -> "); t = p[n]; sub(/:.*$/, "", t); pend = t; next } + $2 == "GATE" && $3 == "lane-lower" && $4 == "override" && NF >= 6 && $NF == "via=lane-lower" { + n = split($5, p, " -> "); if (n >= 2) { t = p[2]; sub(/:.*$/, "", t); pend = t } else pend = ""; next + } $2 == "START-AMEND" { l = lane_of($3); if (ok(l)) { a = l; low = (pend == l) } pend = ""; next } $2 == "START" && !seen { seen = 1; l = lane_of($3); if (ok(l)) first = l } + { pend = "" } END { if (a != "") print a "\tamend\t" (low ? 1 : 0); else if (first != "") print first "\tstart\t0" }' "$f") || true fi if [ -z "$lane" ] && [ -n "$hdr" ]; then lane="$hdr"; src=spec; fi @@ -186,7 +189,7 @@ lane_resolve() { return "$_ld_rc" } _lane_resolve_layers() { - local lane="$1" mode="${2:-}" layer f raw lraw ph known applies + local lane="$1" mode="${2:-}" layer f raw lraw ph known LANE_PHASES=""; LANE_LIGHT="" # Only the five kit lanes exist here. A committed `[lane.mega]` block must not make `mega` a # lane whose gate check passes; drop-in lanes answer `plan` only, through lanes.d. diff --git a/tests/test-lane-lower-via.sh b/tests/test-lane-lower-via.sh new file mode 100755 index 000000000..0b75e10f8 --- /dev/null +++ b/tests/test-lane-lower-via.sh @@ -0,0 +1,129 @@ +#!/usr/bin/env bash +# test-lane-lower-via.sh -- only `start --amend --lower` (`| via=lane-lower`) may sanction a +# START-AMEND below the spec's Lane: header in lib/gate/lane-data.sh (lane_effective). +# Hand overrides (`via=hand`), other override writers (`via=plan|batch|inherit`), tag-less rows, +# intervening ledger lines, and malformed arrows must not lower the check lane. +# +# Run: bash tests/test-lane-lower-via.sh (exit 0 = all green) + +set -uo pipefail +export KIT_CONFIG_OPERATOR="${TMPDIR:-/tmp}/kit-no-operator.$$" +KIT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +GL="$KIT_DIR/lib/gate/gate-ledger.sh" + +TMP_ROOT="$(mktemp -d "${TMPDIR:-/tmp}/kit.XXXXXX")" || exit 1 +trap 'rm -rf "$TMP_ROOT"' EXIT + +export HOME="$TMP_ROOT/home" +export XDG_CONFIG_HOME="$TMP_ROOT/xdg-config" +export XDG_STATE_HOME="$TMP_ROOT/xdg-state" +export XDG_CACHE_HOME="$TMP_ROOT/xdg-cache" +export XDG_DATA_HOME="$TMP_ROOT/xdg-data" +export GIT_CONFIG_GLOBAL="$TMP_ROOT/gitconfig" +export GIT_CONFIG_NOSYSTEM=1 +export DWARVES_KIT_LOG_DIR="$TMP_ROOT/logs" +mkdir -p "$HOME" "$XDG_CONFIG_HOME" "$XDG_STATE_HOME" "$XDG_CACHE_HOME" "$XDG_DATA_HOME" "$DWARVES_KIT_LOG_DIR/runs" + +RUNS="$DWARVES_KIT_LOG_DIR/runs" +SPECF="$TMP_ROOT/spec-full.md" +printf '# Spec: lane-lower-via\nStatus: DRAFT\nLane: full\n' > "$SPECF" + +PASS=0 +FAIL=0 +check() { + local label="$1" got="$2" want="$3" + if [ "$got" = "$want" ]; then + echo " PASS $label" + PASS=$((PASS + 1)) + else + echo " FAIL $label (got '$got', want '$want')" + FAIL=$((FAIL + 1)) + fi +} + +gl() { bash "$GL" "$@"; } +ck() { gl lane "$1" --spec "$SPECF" | cut -f4; } +legacy() { + local rid="$1" + shift + printf '%s\n' "$@" > "$RUNS/$rid.log" +} + +ST_FULL='2026-01-01T00:00:00Z | START | lane=full classified=full type=feature repo=r' +AM_TINY='2026-01-01T00:02:00Z | START-AMEND | lane=tiny classified=full type=feature repo=r' +AM_NORM='2026-01-01T00:02:00Z | START-AMEND | lane=normal classified=full type=feature repo=r' + +echo "=== hand override of lane-lower cannot lower check lane ===" +gl start hand-bypass tiny full feature feature r >/dev/null 2>&1 +gl override hand-bypass lane-lower "full -> tiny: hand override" >/dev/null 2>&1 +gl start --amend hand-bypass tiny full feature feature r >/dev/null 2>&1 +check "override lane-lower (via=hand) + start --amend tiny stays full" "$(ck hand-bypass)" "full" + +gl start hand-spoof tiny full feature feature r >/dev/null 2>&1 +gl override hand-spoof lane-lower "full -> tiny: spoof | via=lane-lower" >/dev/null 2>&1 +gl start --amend hand-spoof tiny full feature feature r >/dev/null 2>&1 +check "override lane-lower with forged trailing via=lane-lower stays full" "$(ck hand-spoof)" "full" + +echo "=== non-lane-lower writer tags and tag-less rows cannot lower check lane ===" +for tag in "via=hand" "via=plan" "via=batch" "via=inherit"; do + rid="tag-${tag#via=}" + legacy "$rid" \ + "$ST_FULL" \ + "2026-01-01T00:01:00Z | GATE | lane-lower | override | full -> tiny: x | $tag" \ + "$AM_TINY" + check "lane-lower row with $tag does not sanction amend" "$(ck "$rid")" "full" +done + +legacy tag-none \ + "$ST_FULL" \ + "2026-01-01T00:01:00Z | GATE | lane-lower | override | full -> tiny: x" \ + "$AM_TINY" +check "tag-less lane-lower row reads as hand and does not sanction amend" "$(ck tag-none)" "full" + +echo "=== adjacency and format checks on via=lane-lower rows ===" +legacy stale-gap \ + "$ST_FULL" \ + "2026-01-01T00:01:00Z | GATE | lane-lower | override | full -> tiny: x | via=lane-lower" \ + "2026-01-01T00:01:30Z | GATE | build | ran | ok" \ + "$AM_TINY" +check "intervening line clears pending lane-lower before START-AMEND" "$(ck stale-gap)" "full" + +legacy no-arrow \ + "$ST_FULL" \ + "2026-01-01T00:01:00Z | GATE | lane-lower | override | tiny: x | via=lane-lower" \ + "$AM_TINY" +check "lane-lower row without arrow does not sanction amend" "$(ck no-arrow)" "full" + +legacy wrong-target \ + "$ST_FULL" \ + "2026-01-01T00:01:00Z | GATE | lane-lower | override | full -> tiny: x | via=lane-lower" \ + "$AM_NORM" +check "lane-lower aimed at tiny does not sanction amend to normal" "$(ck wrong-target)" "full" + +echo "=== sanctioned start --amend --lower still lowers check lane ===" +gl start ok-lower full full feature feature r >/dev/null 2>&1 +gl start --amend --lower --reason "docs only" ok-lower tiny full feature feature r >/dev/null 2>&1 +check "start --amend --lower --reason lowers full to tiny" "$(ck ok-lower)" "tiny" + +gl start arrow-reason full full feature feature r >/dev/null 2>&1 +gl start --amend --lower --reason "moved scope -> tiny doc" arrow-reason normal full feature feature r >/dev/null 2>&1 +check "reason containing ' -> ' still resolves target lane normal" "$(ck arrow-reason)" "normal" + +gl start pipe-reason full full feature feature r >/dev/null 2>&1 +gl start --amend --lower --reason "doc only | no code" pipe-reason tiny full feature feature r >/dev/null 2>&1 +check "reason containing ' | ' still recognizes trailing via=lane-lower" "$(ck pipe-reason)" "tiny" + +gl start relift full full feature feature r >/dev/null 2>&1 +gl start --amend --lower --reason "narrowed" relift normal full feature feature r >/dev/null 2>&1 +gl start --amend relift bug full feature feature r >/dev/null 2>&1 +check "later non-lower amend after lowering restores stricter header full" "$(ck relift)" "full" + +echo "=== direct lane_effective source check ===" +DIRECT_BYPASS="$(bash -c 'source "$1/lib/gate/lane-data.sh"; lane_effective "$2" "$3" | cut -f4' _ "$KIT_DIR" "$RUNS/hand-bypass.log" "$SPECF")" +DIRECT_OK="$(bash -c 'source "$1/lib/gate/lane-data.sh"; lane_effective "$2" "$3" | cut -f4' _ "$KIT_DIR" "$RUNS/ok-lower.log" "$SPECF")" +check "direct lane_effective rejects hand-bypass" "$DIRECT_BYPASS" "full" +check "direct lane_effective accepts sanctioned lowering" "$DIRECT_OK" "tiny" + +echo "---" +echo "PASS=$PASS FAIL=$FAIL" +[ "$FAIL" -eq 0 ]