@tduyng/pi-devos 0.0.0-stage → 0.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1398 -0
- package/LICENSE +201 -0
- package/README.md +213 -2
- package/package.json +45 -4
- package/plugins/devos/agents/reader.md +27 -0
- package/plugins/devos/agents/verifier.md +181 -0
- package/plugins/devos/pi/extension/devos.ts +615 -0
- package/plugins/devos/scripts/check-evidence-router.sh +134 -0
- package/plugins/devos/scripts/evidence-router.py +252 -0
- package/plugins/devos/scripts/gates/check-dod-core.sh +283 -0
- package/plugins/devos/scripts/gates/check-dod.sh +38 -0
- package/plugins/devos/scripts/gates/check-handoff.sh +215 -0
- package/plugins/devos/scripts/gates/check-implementation-boundary.sh +99 -0
- package/plugins/devos/scripts/gates/check-port-source.sh +134 -0
- package/plugins/devos/scripts/gates/check-report-locations.sh +148 -0
- package/plugins/devos/scripts/gates/check-scenario-coverage.sh +102 -0
- package/plugins/devos/scripts/gates/gate-check.mjs +204 -0
- package/plugins/devos/scripts/gates/phase-gate.sh +208 -0
- package/plugins/devos/scripts/gates/plan-template-check.py +147 -0
- package/plugins/devos/scripts/gates/run-gate.sh +148 -0
- package/plugins/devos/scripts/gates/spec-template-check.py +165 -0
- package/plugins/devos/scripts/gates/test-gates.sh +4306 -0
- package/plugins/devos/scripts/gates/test-integrity-rubric.sh +152 -0
- package/plugins/devos/scripts/gates/test-phase-gate.sh +116 -0
- package/plugins/devos/skills/absorb/SKILL.md +75 -0
- package/plugins/devos/skills/absorb/references/distill.md +67 -0
- package/plugins/devos/skills/absorb/scripts/check-refs.sh +108 -0
- package/plugins/devos/skills/absorb/scripts/knowledge.py +258 -0
- package/plugins/devos/skills/build/SKILL.md +71 -0
- package/plugins/devos/skills/build/references/advanced-routing.md +19 -0
- package/plugins/devos/skills/build/references/defect.md +17 -0
- package/plugins/devos/skills/build/references/exposure.md +28 -0
- package/plugins/devos/skills/build/references/hard.md +39 -0
- package/plugins/devos/skills/build/references/refactor.md +66 -0
- package/plugins/devos/skills/build/references/routes.md +56 -0
- package/plugins/devos/skills/build/references/scale.md +84 -0
- package/plugins/devos/skills/build/references/spike.md +19 -0
- package/plugins/devos/skills/build/scripts/construct-census.py +204 -0
- package/plugins/devos/skills/build/scripts/dep-order.py +297 -0
- package/plugins/devos/skills/build/scripts/ledger.sh +228 -0
- package/plugins/devos/skills/build/scripts/route.sh +5 -0
- package/plugins/devos/skills/build/scripts/secret-scan.sh +121 -0
- package/plugins/devos/skills/build/scripts/toolchain-preflight.py +302 -0
- package/plugins/devos/skills/design-taste/SKILL.md +55 -0
- package/plugins/devos/skills/design-taste/references/tells.md +85 -0
- package/plugins/devos/skills/design-taste/scripts/slop-scan.py +305 -0
- package/plugins/devos/skills/docs/SKILL.md +22 -0
- package/plugins/devos/skills/docs/references/backfill.md +54 -0
- package/plugins/devos/skills/docs/references/init.md +43 -0
- package/plugins/devos/skills/docs/references/status.md +71 -0
- package/plugins/devos/skills/docs/references/update.md +80 -0
- package/plugins/devos/skills/explain/SKILL.md +45 -0
- package/plugins/devos/skills/explain/references/quiz.md +21 -0
- package/plugins/devos/skills/frame/SKILL.md +71 -0
- package/plugins/devos/skills/frame/references/boundaries.md +53 -0
- package/plugins/devos/skills/frame/references/decompose.md +96 -0
- package/plugins/devos/skills/frame/references/impact.md +43 -0
- package/plugins/devos/skills/frame/references/interrogate.md +68 -0
- package/plugins/devos/skills/frame/scripts/survey.sh +44 -0
- package/plugins/devos/skills/implement/SKILL.md +36 -0
- package/plugins/devos/skills/implement/references/conditional-plan.md +17 -0
- package/plugins/devos/skills/implement/references/debug-loop.md +7 -0
- package/plugins/devos/skills/implement/references/dod.md +32 -0
- package/plugins/devos/skills/implement/references/implement.md +52 -0
- package/plugins/devos/skills/implement/references/manual-gates.md +16 -0
- package/plugins/devos/skills/implement/references/plan.md +160 -0
- package/plugins/devos/skills/implement/references/resume.md +9 -0
- package/plugins/devos/skills/implement/references/scale.md +86 -0
- package/plugins/devos/skills/implement/references/verify-close.md +61 -0
- package/plugins/devos/skills/implement/references/visual-verification.md +7 -0
- package/plugins/devos/skills/implement/scripts/check-converge.sh +147 -0
- package/plugins/devos/skills/implement/scripts/equivalence-check.sh +140 -0
- package/plugins/devos/skills/implement/scripts/manifest-queue.sh +185 -0
- package/plugins/devos/skills/implement/scripts/ops-log.sh +58 -0
- package/plugins/devos/skills/implement/scripts/pilot-consistency.py +173 -0
- package/plugins/devos/skills/implement/scripts/validate-spec.sh +268 -0
- package/plugins/devos/skills/init/SKILL.md +100 -0
- package/plugins/devos/skills/init/references/archetype-sections.md +15 -0
- package/plugins/devos/skills/init/references/context.md +42 -0
- package/plugins/devos/skills/init/references/conventions-template.md +153 -0
- package/plugins/devos/skills/init/references/reverse-engineer.md +3 -0
- package/plugins/devos/skills/init/references/rule-format.md +58 -0
- package/plugins/devos/skills/init/references/shape-model.md +29 -0
- package/plugins/devos/skills/init/scripts/detect-archetype.py +461 -0
- package/plugins/devos/skills/init/scripts/render-rule.py +114 -0
- package/plugins/devos/skills/init/scripts/reverse-engineer.sh +162 -0
- package/plugins/devos/skills/learn/SKILL.md +29 -0
- package/plugins/devos/skills/learn/references/destinations.md +43 -0
- package/plugins/devos/skills/learn/references/scoring.md +26 -0
- package/plugins/devos/skills/product/SKILL.md +40 -0
- package/plugins/devos/skills/product/references/planner.md +54 -0
- package/plugins/devos/skills/review/SKILL.md +77 -0
- package/plugins/devos/skills/review/references/gaps.md +26 -0
- package/plugins/devos/skills/spec/SKILL.md +58 -0
- package/plugins/devos/skills/spec/references/prototype.md +21 -0
- package/plugins/devos/skills/spec/references/question-craft.md +47 -0
- package/plugins/devos/skills/spec/references/roadmap-link.md +5 -0
- package/plugins/devos/skills/spec/references/write-spec.md +143 -0
- package/plugins/devos/skills/spec/scripts/clarify.sh +173 -0
- package/plugins/devos/skills/status/SKILL.md +67 -0
- package/plugins/devos/skills/status/references/cost.md +38 -0
- package/plugins/devos/skills/status/scripts/artifact-budgets.sh +88 -0
- package/plugins/devos/skills/status/scripts/check-requires.py +556 -0
- package/plugins/devos/skills/status/scripts/context-cost.sh +89 -0
- package/plugins/devos/skills/status/scripts/convention-usage.sh +184 -0
- package/plugins/devos/skills/status/scripts/findings-summary.sh +112 -0
- package/plugins/devos/skills/status/scripts/quality-correlation.sh +282 -0
- package/plugins/devos/skills/status/scripts/sizing-calibration.sh +71 -0
- package/plugins/devos/skills/status/scripts/spec-diff.sh +137 -0
- package/plugins/devos/skills/surgical-diff/SKILL.md +23 -0
- package/plugins/devos/skills/test-integrity/SKILL.md +26 -0
- package/plugins/devos/skills/verification-evidence/SKILL.md +17 -0
- package/plugins/devos/workflows/common/backlog-file-structure.md +44 -0
- package/plugins/devos/workflows/common/category-file-structure.md +41 -0
- package/plugins/devos/workflows/common/feature-line-format.md +10 -0
- package/plugins/devos/workflows/common/roadmap-file-structure.md +51 -0
- package/plugins/devos/workflows/common/suggest-categories.md +76 -0
- package/plugins/devos/workflows/common/suggest-milestones.md +92 -0
- package/plugins/devos/workflows/doc/doc-health.md +137 -0
- package/plugins/devos/workflows/doc/doc-writer.md +44 -0
- package/plugins/devos/workflows/doc/init-documentation.md +196 -0
- package/plugins/devos/workflows/doc/retro-documentation.md +304 -0
- package/plugins/devos/workflows/doc/templates/library.md +58 -0
- package/plugins/devos/workflows/doc/templates/service.md +61 -0
- package/plugins/devos/workflows/doc/update-documentation.md +194 -0
- package/plugins/devos/workflows/doc/write-documentation.md +137 -0
- package/plugins/devos/workflows/product/create-product-mission.md +45 -0
- package/plugins/devos/workflows/product/create-product-roadmap.md +106 -0
- package/plugins/devos/workflows/product/create-product-tech-stack.md +19 -0
- package/plugins/devos/workflows/product/gather-product-info.md +25 -0
- package/plugins/devos/workflows/product/resume-detection.md +70 -0
- package/plugins/devos/workflows/product/reverse-backlog.md +118 -0
- package/plugins/devos/workflows/product/reverse-domain-model.md +86 -0
- package/plugins/devos/workflows/product/reverse-product-plan.md +81 -0
- package/plugins/devos/workflows/product/reverse-tech-stack.md +73 -0
- package/plugins/devos/workflows/product/scan-deep.md +113 -0
- package/plugins/devos/workflows/product/scan-git.md +122 -0
- package/plugins/devos/workflows/product/scan-light.md +154 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Deterministic tests for evidence-router.py, plain asserts, no framework,
|
|
3
|
+
# no model calls. Run via `just verify`.
|
|
4
|
+
set -u
|
|
5
|
+
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
6
|
+
ROUTER="$PWD/evidence-router.py"
|
|
7
|
+
REPO="$(cd ../../.. && pwd)"
|
|
8
|
+
|
|
9
|
+
pass=0 fail=0
|
|
10
|
+
|
|
11
|
+
check() { # check <name> <expected-exit> <actual-exit>
|
|
12
|
+
if [[ "$2" == "$3" ]]; then
|
|
13
|
+
pass=$((pass + 1))
|
|
14
|
+
else
|
|
15
|
+
echo "FAIL $1: expected exit $2, got $3" >&2
|
|
16
|
+
fail=$((fail + 1))
|
|
17
|
+
fi
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
has() { # has <name> <needle> <haystack>
|
|
21
|
+
if [[ "$3" == *"$2"* ]]; then
|
|
22
|
+
pass=$((pass + 1))
|
|
23
|
+
else
|
|
24
|
+
echo "FAIL $1: expected output to contain '$2'" >&2
|
|
25
|
+
fail=$((fail + 1))
|
|
26
|
+
fi
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
hasnt() { # hasnt <name> <needle> <haystack>
|
|
30
|
+
if [[ "$3" != *"$2"* ]]; then
|
|
31
|
+
pass=$((pass + 1))
|
|
32
|
+
else
|
|
33
|
+
echo "FAIL $1: expected output NOT to contain '$2'" >&2
|
|
34
|
+
fail=$((fail + 1))
|
|
35
|
+
fi
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
tmp=$(mktemp -d)
|
|
39
|
+
trap '[[ $BASH_SUBSHELL -eq 0 ]] && rm -rf "$tmp"' EXIT
|
|
40
|
+
|
|
41
|
+
# --- fixture project ------------------------------------------------------
|
|
42
|
+
proj="$tmp/proj"
|
|
43
|
+
mkdir -p "$proj/devos/standards/rules/01-api" "$proj/devos/product/behaviors"
|
|
44
|
+
cat > "$proj/devos/standards/conventions.md" <<'MD'
|
|
45
|
+
---
|
|
46
|
+
devos-contract: 1
|
|
47
|
+
---
|
|
48
|
+
# Project Conventions
|
|
49
|
+
|
|
50
|
+
Choices this project has made.
|
|
51
|
+
|
|
52
|
+
## Testing
|
|
53
|
+
|
|
54
|
+
Write tests for every gate script before it is wired anywhere. A test that
|
|
55
|
+
cannot fail is not a test.
|
|
56
|
+
|
|
57
|
+
## Commits
|
|
58
|
+
|
|
59
|
+
Conventional commits. One logical change per commit.
|
|
60
|
+
MD
|
|
61
|
+
cat > "$proj/devos/standards/rules/01-api/auth.md" <<'MD'
|
|
62
|
+
---
|
|
63
|
+
globs: src/api/**
|
|
64
|
+
---
|
|
65
|
+
# Auth
|
|
66
|
+
|
|
67
|
+
Every src/api route authenticates the request before it touches the store.
|
|
68
|
+
MD
|
|
69
|
+
cat > "$proj/devos/product/domain-model.md" <<'MD'
|
|
70
|
+
# Domain Model
|
|
71
|
+
|
|
72
|
+
## Invoice
|
|
73
|
+
|
|
74
|
+
An Invoice is a list of InvoiceLine amounts, summed to a total.
|
|
75
|
+
MD
|
|
76
|
+
cat > "$proj/devos/product/behaviors/invoice.md" <<'MD'
|
|
77
|
+
# Invoice behavior
|
|
78
|
+
|
|
79
|
+
Creating an invoice emits one `invoice.created` event.
|
|
80
|
+
MD
|
|
81
|
+
|
|
82
|
+
# --- 1. lexical selection keeps the relevant block, drops the rest --------
|
|
83
|
+
out=$(python3 "$ROUTER" --root "$proj" --task 'how should tests be named' --files src/x.ts)
|
|
84
|
+
check "lexical: exits 0" 0 $?
|
|
85
|
+
has "lexical: keeps the Testing block" "· Testing" "$out"
|
|
86
|
+
hasnt "lexical: drops the Commits block" "## Commits" "$out"
|
|
87
|
+
has "lexical: counts the candidates" "> kept 2 of 7 candidates" "$out"
|
|
88
|
+
has "lexical: quotes the block" "> Write tests for every gate script" "$out"
|
|
89
|
+
|
|
90
|
+
# --- 2. a rules file matching a touched file is mandatory -----------------
|
|
91
|
+
out=$(python3 "$ROUTER" --root "$proj" --task 'update the logging format' --files src/api/routes.ts)
|
|
92
|
+
has "rules: matched glob is mandatory" "mandatory rule" "$out"
|
|
93
|
+
has "rules: names the rule file" "01-api/auth.md" "$out"
|
|
94
|
+
|
|
95
|
+
out=$(python3 "$ROUTER" --root "$proj" --task 'update the logging format' --files src/cli/main.ts)
|
|
96
|
+
hasnt "rules: unmatched glob is not mandatory" "mandatory rule" "$out"
|
|
97
|
+
|
|
98
|
+
# --- 3. --keep caps the kept set and json parses --------------------------
|
|
99
|
+
n=$(python3 "$ROUTER" --root "$proj" --task 'conventions about tests and invoices and api auth' \
|
|
100
|
+
--files src/api/routes.ts --keep 3 --format json \
|
|
101
|
+
| python3 -c "import json,sys; d=json.load(sys.stdin); assert len(d['kept']) <= 3; assert 'dropped' in d; print('ok')")
|
|
102
|
+
check "keep: --keep 3 holds the cap" 0 $?
|
|
103
|
+
has "keep: json parses" "ok" "$n"
|
|
104
|
+
|
|
105
|
+
# --- 4. the selection has no model, server or setting in it ---------------
|
|
106
|
+
out=$(python3 "$ROUTER" --root "$proj" --task 'how should tests be named' --files src/x.ts)
|
|
107
|
+
hasnt "deterministic: no model vocabulary in the header" "systemone" "$out"
|
|
108
|
+
hasnt "deterministic: no transport note" "unavailable" "$out"
|
|
109
|
+
|
|
110
|
+
# The flags that reached a model are gone rather than ignored, so a stale script
|
|
111
|
+
# fails loudly instead of selecting quietly without the pass it asked for.
|
|
112
|
+
for flag in --systemone --no-systemone --shadow-log --export-eval --dataset-from-shadow --_systemone-resolve; do
|
|
113
|
+
python3 "$ROUTER" --root "$proj" --task 'anything' "$flag" x >/dev/null 2>&1
|
|
114
|
+
check "removed: $flag is a usage error" 2 $?
|
|
115
|
+
done
|
|
116
|
+
|
|
117
|
+
# --- 5. the real repository is indexable ----------------------------------
|
|
118
|
+
out=$(python3 "$ROUTER" --root "$REPO" --task 'gate script tests run against real repo content before wiring' \
|
|
119
|
+
--files plugins/devos/scripts/gates/test-gates.sh --format json)
|
|
120
|
+
check "real repo: exits 0" 0 $?
|
|
121
|
+
has "real repo: selects a conventions block" "devos/standards/conventions.md" "$out"
|
|
122
|
+
|
|
123
|
+
# --- 6. a project with no devos/ folder yields nothing, quietly -----------
|
|
124
|
+
mkdir -p "$tmp/empty"
|
|
125
|
+
out=$(python3 "$ROUTER" --root "$tmp/empty" --task 'anything at all' --files src/x.ts)
|
|
126
|
+
check "empty: exits 0" 0 $?
|
|
127
|
+
has "empty: reports zero candidates" "kept 0 of 0 candidates" "$out"
|
|
128
|
+
|
|
129
|
+
# --- 7. a missing task is a usage error ----------------------------------
|
|
130
|
+
python3 "$ROUTER" --root "$proj" --files src/x.ts >/dev/null 2>&1
|
|
131
|
+
check "usage: --task is required" 2 $?
|
|
132
|
+
|
|
133
|
+
echo "evidence-router: $pass passed, $fail failed"
|
|
134
|
+
[[ $fail -eq 0 ]]
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""evidence-router: pick the evidence blocks a DevOS stage should read.
|
|
3
|
+
|
|
4
|
+
Given a task and the files it touches, index the project's declared evidence
|
|
5
|
+
(devos/standards/conventions.md sections, devos/standards/rules/*.md,
|
|
6
|
+
devos/product/behaviors/*.md, devos/product/domain-model.md sections, and a spec
|
|
7
|
+
folder's spec-functional.md / spec.md sections), select the smallest set worth
|
|
8
|
+
loading, and print it quoted with file:line ranges.
|
|
9
|
+
|
|
10
|
+
Selection is deterministic: a rules file whose `globs:` matches a touched file is
|
|
11
|
+
mandatory, everything else ranks by lexical overlap between the task and the
|
|
12
|
+
block. There is no model call, no server and no setting: the same task and files
|
|
13
|
+
give the same list on every machine.
|
|
14
|
+
|
|
15
|
+
A block is ranked by heading hits at 3x plus body hits damped by the block's own
|
|
16
|
+
length, so a long file does not out-rank a short section on size alone. The
|
|
17
|
+
budget is `--keep`, clamped to 3-8, and the list never grows past it.
|
|
18
|
+
|
|
19
|
+
This chooses references. It never summarises or rewrites them and it is not a
|
|
20
|
+
gate: the reader decides what to read, and a block the router dropped still
|
|
21
|
+
becomes a finding when someone reads it. The plan capsule stays the source of
|
|
22
|
+
truth, so implementation reads spec.md as before.
|
|
23
|
+
|
|
24
|
+
Usage:
|
|
25
|
+
evidence-router.py --task "add PDF export" [--files a,b] [--spec devos/specs/name]
|
|
26
|
+
[--root DIR] [--keep N] [--format md|json]
|
|
27
|
+
"""
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
import argparse
|
|
31
|
+
import json
|
|
32
|
+
import re
|
|
33
|
+
import sys
|
|
34
|
+
from pathlib import Path
|
|
35
|
+
|
|
36
|
+
STOPWORDS = frozenset(
|
|
37
|
+
"a an the and or of to in for on with is are be this that it its as at by "
|
|
38
|
+
"from not no when what how you your any all each every add make use change "
|
|
39
|
+
"file files should must before after into over under".split()
|
|
40
|
+
)
|
|
41
|
+
MAX_BLOCK_LINES = 40
|
|
42
|
+
MAX_BLOCK_CHARS = 2000
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Candidate:
|
|
46
|
+
def __init__(self, path: Path, rel: str, heading: str, start: int, end: int, text: str):
|
|
47
|
+
self.path = path
|
|
48
|
+
self.rel = rel
|
|
49
|
+
self.heading = heading
|
|
50
|
+
self.start = start
|
|
51
|
+
self.end = end
|
|
52
|
+
self.text = text
|
|
53
|
+
self.glob_patterns: list[str] = []
|
|
54
|
+
self.score = 0
|
|
55
|
+
self.why = ""
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def id(self) -> str:
|
|
59
|
+
if self.heading and self.heading != self.rel:
|
|
60
|
+
return f"{self.rel}#{self.heading}"
|
|
61
|
+
return self.rel
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def tokens(text: str) -> set[str]:
|
|
65
|
+
return {t for t in re.findall(r"[a-z0-9]+", text.lower()) if t not in STOPWORDS}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def block_score(cand: Candidate, qtokens: set[str]) -> float:
|
|
69
|
+
"""Rank a block by how much of the query it carries, damped by its own size.
|
|
70
|
+
|
|
71
|
+
The body term is divided by sqrt(block tokens) rather than counted raw. A raw
|
|
72
|
+
count rewards a block for being long, and the artifacts are split unevenly:
|
|
73
|
+
a behavior file is one 100-token block while conventions.md is ten blocks of
|
|
74
|
+
15 to 80, so a long file out-scored every short relevant section on the
|
|
75
|
+
strength of its size alone. The sqrt term is the standard damping in
|
|
76
|
+
retrieval scoring: one more hit still counts, but a hit in a long block
|
|
77
|
+
counts for progressively less than the same hit in a short one. It has no
|
|
78
|
+
tuned constant, which matters because the only label available is a file
|
|
79
|
+
and a constant fitted to it would be the label wearing a score.
|
|
80
|
+
|
|
81
|
+
The heading stays at 3x undamped. A heading is a few tokens either way, so
|
|
82
|
+
it carries no size bias to correct.
|
|
83
|
+
"""
|
|
84
|
+
heading_hits = len(qtokens & tokens(cand.heading))
|
|
85
|
+
body_hits = len(qtokens & tokens(cand.text))
|
|
86
|
+
body_len = max(1, len(tokens(cand.text)))
|
|
87
|
+
return 3 * heading_hits + body_hits / body_len**0.5
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def sectionize(path: Path, rel: str) -> list[Candidate]:
|
|
91
|
+
"""Split a markdown file into blocks at '## ' headings (preamble included)."""
|
|
92
|
+
lines = path.read_text(errors="replace").splitlines()
|
|
93
|
+
starts = [i for i, l in enumerate(lines) if l.startswith("## ")]
|
|
94
|
+
bounds = starts + [len(lines)]
|
|
95
|
+
out: list[Candidate] = []
|
|
96
|
+
if not starts:
|
|
97
|
+
out.append(Candidate(path, rel, rel, 1, len(lines), "\n".join(lines)))
|
|
98
|
+
return out
|
|
99
|
+
if starts[0] > 0:
|
|
100
|
+
title = next((l.lstrip("# ").strip() for l in lines[: starts[0]] if l.startswith("# ")), rel)
|
|
101
|
+
out.append(Candidate(path, rel, title, 1, starts[0], "\n".join(lines[: starts[0]])))
|
|
102
|
+
for i in range(len(bounds) - 1):
|
|
103
|
+
s, e = bounds[i], bounds[i + 1]
|
|
104
|
+
heading = lines[s][3:].strip()
|
|
105
|
+
out.append(Candidate(path, rel, heading, s + 1, e, "\n".join(lines[s:e])))
|
|
106
|
+
return out
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def whole_file(path: Path, rel: str, root: Path) -> Candidate:
|
|
110
|
+
lines = path.read_text(errors="replace").splitlines()
|
|
111
|
+
return Candidate(path, rel, path.stem, 1, len(lines), "\n".join(lines))
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def parse_globs(path: Path) -> list[str]:
|
|
115
|
+
m = re.search(r"^globs:[ \t]*(.*)$", path.read_text(errors="replace"), re.M)
|
|
116
|
+
if not m:
|
|
117
|
+
return []
|
|
118
|
+
return [p.strip() for p in m.group(1).split(",") if p.strip()]
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def glob_match(pattern: str, rel: str) -> bool:
|
|
122
|
+
rx = ""
|
|
123
|
+
i = 0
|
|
124
|
+
while i < len(pattern):
|
|
125
|
+
c = pattern[i]
|
|
126
|
+
if pattern.startswith("**/", i):
|
|
127
|
+
rx += "(?:.*/)?"
|
|
128
|
+
i += 3
|
|
129
|
+
elif pattern.startswith("**", i):
|
|
130
|
+
rx += ".*"
|
|
131
|
+
i += 2
|
|
132
|
+
elif c == "*":
|
|
133
|
+
rx += "[^/]*"
|
|
134
|
+
i += 1
|
|
135
|
+
elif c == "?":
|
|
136
|
+
rx += "[^/]"
|
|
137
|
+
i += 1
|
|
138
|
+
else:
|
|
139
|
+
rx += re.escape(c)
|
|
140
|
+
i += 1
|
|
141
|
+
return re.fullmatch(rx, rel) is not None
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def collect(root: Path, spec: Path | None) -> list[Candidate]:
|
|
145
|
+
cands: list[Candidate] = []
|
|
146
|
+
for rel in ("devos/standards/conventions.md", "devos/product/domain-model.md"):
|
|
147
|
+
p = root / rel
|
|
148
|
+
if p.is_file():
|
|
149
|
+
cands += sectionize(p, rel)
|
|
150
|
+
rules = root / "devos/standards/rules"
|
|
151
|
+
if rules.is_dir():
|
|
152
|
+
for p in sorted(rules.rglob("*.md")):
|
|
153
|
+
rel = p.relative_to(root).as_posix()
|
|
154
|
+
c = whole_file(p, rel, root)
|
|
155
|
+
c.glob_patterns = parse_globs(p)
|
|
156
|
+
cands.append(c)
|
|
157
|
+
behaviors = root / "devos/product/behaviors"
|
|
158
|
+
if behaviors.is_dir():
|
|
159
|
+
for p in sorted(behaviors.glob("*.md")):
|
|
160
|
+
cands.append(whole_file(p, p.relative_to(root).as_posix(), root))
|
|
161
|
+
if spec:
|
|
162
|
+
for name in ("spec-functional.md", "spec.md"):
|
|
163
|
+
p = spec / name
|
|
164
|
+
if p.is_file():
|
|
165
|
+
cands += sectionize(p, p.relative_to(root).as_posix() if p.is_relative_to(root) else str(p))
|
|
166
|
+
return cands
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def select_lexical(cands: list[Candidate], qtokens: set[str], files: list[str], keep: int) -> list[Candidate]:
|
|
170
|
+
mandatory = []
|
|
171
|
+
for c in cands:
|
|
172
|
+
if c.glob_patterns and any(glob_match(g, f) for g in c.glob_patterns for f in files):
|
|
173
|
+
c.why = "mandatory rule"
|
|
174
|
+
mandatory.append(c)
|
|
175
|
+
ranked = [c for c in cands if c not in mandatory]
|
|
176
|
+
for c in ranked:
|
|
177
|
+
c.score = block_score(c, qtokens)
|
|
178
|
+
ranked = [c for c in ranked if c.score > 0]
|
|
179
|
+
ranked.sort(key=lambda c: (-c.score, c.rel, c.start))
|
|
180
|
+
for c in ranked:
|
|
181
|
+
c.why = f"lexical score {c.score:.2f}"
|
|
182
|
+
return mandatory + ranked[: max(0, keep - len(mandatory))]
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def quote_block(cand: Candidate) -> str:
|
|
186
|
+
lines = cand.text.splitlines()
|
|
187
|
+
out, chars = [], 0
|
|
188
|
+
for line in lines:
|
|
189
|
+
if len(out) >= MAX_BLOCK_LINES or chars + len(line) > MAX_BLOCK_CHARS:
|
|
190
|
+
out.append("…")
|
|
191
|
+
break
|
|
192
|
+
out.append("> " + line)
|
|
193
|
+
chars += len(line)
|
|
194
|
+
return "\n".join(out)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def emit_md(kept: list[Candidate], total: int, task: str) -> None:
|
|
198
|
+
print(f"> kept {len(kept)} of {total} candidates | task: {task[:80]}")
|
|
199
|
+
for c in kept:
|
|
200
|
+
print(f"\n## {c.rel}:{c.start}-{c.end} · {c.heading} [{c.why}]")
|
|
201
|
+
print(quote_block(c))
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def main() -> int:
|
|
205
|
+
ap = argparse.ArgumentParser(prog="evidence-router", description="select the evidence blocks a DevOS stage should read")
|
|
206
|
+
ap.add_argument("--task")
|
|
207
|
+
ap.add_argument("--task-file")
|
|
208
|
+
ap.add_argument("--files", default="")
|
|
209
|
+
ap.add_argument("--spec")
|
|
210
|
+
ap.add_argument("--root", default=".")
|
|
211
|
+
ap.add_argument("--keep", type=int, default=6, help="blocks to keep, clamped to 3-8")
|
|
212
|
+
ap.add_argument("--format", choices=("md", "json"), default="md")
|
|
213
|
+
args = ap.parse_args()
|
|
214
|
+
|
|
215
|
+
if args.task:
|
|
216
|
+
task = args.task
|
|
217
|
+
elif args.task_file:
|
|
218
|
+
task = sys.stdin.read() if args.task_file == "-" else Path(args.task_file).read_text()
|
|
219
|
+
else:
|
|
220
|
+
ap.error("one of --task or --task-file is required")
|
|
221
|
+
root = Path(args.root).resolve()
|
|
222
|
+
files = [f.strip() for f in args.files.split(",") if f.strip()]
|
|
223
|
+
spec = None
|
|
224
|
+
if args.spec:
|
|
225
|
+
spec = Path(args.spec)
|
|
226
|
+
spec = spec if spec.is_absolute() else (spec if "/" in args.spec else root / "devos/specs" / args.spec)
|
|
227
|
+
spec = spec.resolve()
|
|
228
|
+
keep = max(3, min(8, args.keep))
|
|
229
|
+
|
|
230
|
+
cands = collect(root, spec)
|
|
231
|
+
qtokens = tokens(task) | {t for f in files for t in tokens(f.replace("/", " ").replace(".", " ").replace("-", " ").replace("_", " "))}
|
|
232
|
+
kept = select_lexical(cands, qtokens, files, keep)
|
|
233
|
+
|
|
234
|
+
if args.format == "json":
|
|
235
|
+
print(json.dumps({
|
|
236
|
+
"task": task.strip()[:200],
|
|
237
|
+
"files": files,
|
|
238
|
+
"keep": keep,
|
|
239
|
+
"candidates": len(cands),
|
|
240
|
+
"kept": [{
|
|
241
|
+
"id": c.id, "path": c.rel, "start": c.start, "end": c.end,
|
|
242
|
+
"heading": c.heading, "why": c.why, "score": c.score,
|
|
243
|
+
} for c in kept],
|
|
244
|
+
"dropped": [c.id for c in cands if c not in kept],
|
|
245
|
+
}, indent=2))
|
|
246
|
+
else:
|
|
247
|
+
emit_md(kept, len(cands), task.strip())
|
|
248
|
+
return 0
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
if __name__ == "__main__":
|
|
252
|
+
sys.exit(main())
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# DoD check core: given a transcript file, decide allow/block.
|
|
3
|
+
# Deterministic: no LLM judgment. Shared by every harness adapter that
|
|
4
|
+
# has transcript access at its stop/end-of-turn event (Claude, Copilot CLI,
|
|
5
|
+
# Codex).
|
|
6
|
+
#
|
|
7
|
+
# Usage: check-dod-core.sh <transcript-file>
|
|
8
|
+
# <transcript-file> must already be a plain-text or JSONL dump containing
|
|
9
|
+
# the assistant's messages; callers extract it from their own transcript
|
|
10
|
+
# format before calling this.
|
|
11
|
+
#
|
|
12
|
+
# Exit 0 = allow (no DONE claim, or DONE claim with a report that concludes
|
|
13
|
+
# Completeness CLEAN and Quality PASS).
|
|
14
|
+
# Exit 2 = block. Reason on stderr. A report that exists but concludes FAIL,
|
|
15
|
+
# HAS ISSUES, or states no verdict at all blocks exactly like a
|
|
16
|
+
# missing report.
|
|
17
|
+
set -u
|
|
18
|
+
|
|
19
|
+
GATES="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
|
|
20
|
+
transcript="${1:-}"
|
|
21
|
+
[[ -f "$transcript" ]] || exit 0
|
|
22
|
+
|
|
23
|
+
last=$(cat "$transcript")
|
|
24
|
+
|
|
25
|
+
# More than one line can start `Verdict: DONE`, and the last is not always the
|
|
26
|
+
# verdict: this gate's own message names the format as `Verdict: DONE:
|
|
27
|
+
# devos/specs/[name]`, so a model that echoes the reminder after emitting the
|
|
28
|
+
# real verdict used to have the reminder read instead and get blocked for
|
|
29
|
+
# repeating the gate's words. Scan every matching line and keep the last that
|
|
30
|
+
# yields a valid spec; block only when none does.
|
|
31
|
+
spec=""
|
|
32
|
+
found=0
|
|
33
|
+
while IFS= read -r verdict_line; do
|
|
34
|
+
found=1
|
|
35
|
+
# A valid spec name is exactly one path segment after devos/specs[/archive].
|
|
36
|
+
# A bare directory (no name), a literal `...` placeholder, or a report path
|
|
37
|
+
# pasted as the spec (last segment `verifications`, which would make the gate
|
|
38
|
+
# append verifications/verification.md twice) name no spec, so a later valid
|
|
39
|
+
# line can still supply one.
|
|
40
|
+
s=$(printf '%s' "$verdict_line" | grep -Eo 'devos/specs/(archive/)?[A-Za-z0-9._-]+' | head -1)
|
|
41
|
+
case "$s" in
|
|
42
|
+
devos/specs|devos/specs/archive|*'...'*|*/verifications) s="" ;;
|
|
43
|
+
esac
|
|
44
|
+
[[ -n "$s" ]] && spec="$s"
|
|
45
|
+
done < <(printf '%s' "$last" | grep -E 'Verdict: *DONE')
|
|
46
|
+
[[ $found -eq 0 ]] && exit 0
|
|
47
|
+
|
|
48
|
+
# The checkout already knows which spec this turn belongs to: the pipeline
|
|
49
|
+
# creates a `[spec-name]` branch before the first edit, so the branch is
|
|
50
|
+
# a deterministic resolver and the model should not have to transcribe a path.
|
|
51
|
+
# When no line names a spec, or the one it names has no report (a placeholder
|
|
52
|
+
# like `devos/specs/x`), the branch's spec stands in. Off a spec branch nothing
|
|
53
|
+
# changes: naming is still the only signal, and its absence still blocks.
|
|
54
|
+
if [[ -z "$spec" || ! -f "$spec/verifications/verification.md" ]]; then
|
|
55
|
+
branch=$(git symbolic-ref --short HEAD 2>/dev/null || true)
|
|
56
|
+
bspec="devos/specs/${branch:-}"
|
|
57
|
+
[[ -n "$branch" && -f "$bspec/verifications/verification.md" ]] && spec="$bspec"
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
if [[ -z "$spec" ]]; then
|
|
61
|
+
echo "'Verdict: DONE' must name the spec on the same line (format: 'Verdict: DONE: devos/specs/[name]') so the gate can check its verification report." >&2
|
|
62
|
+
exit 2
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
report="$spec/verifications/verification.md"
|
|
66
|
+
if [[ ! -f "$report" ]]; then
|
|
67
|
+
echo "'Verdict: DONE' claimed but $report does not exist. Run the verifier before declaring DONE." >&2
|
|
68
|
+
exit 2
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# The plan is the artifact of record for what this spec delivered: its
|
|
72
|
+
# `**Files:**` lines are the file list the checks below read.
|
|
73
|
+
plan="$spec/spec.md"
|
|
74
|
+
planned=""
|
|
75
|
+
if [[ -f "$plan" ]]; then
|
|
76
|
+
planned=$(grep -oE '^\*\*Files:\*\*.*' "$plan" | grep -oE '`[^`]+`' | tr -d '`' || true)
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
if ! grep -qE 'Completeness:[[:space:]]*(\*\*)?CLEAN(\*\*)?([[:space:]]*(\||$))' "$report" \
|
|
80
|
+
|| ! grep -qE 'Quality:[[:space:]]*(\*\*)?PASS(\*\*)?([[:space:]]*(\||$))' "$report"; then
|
|
81
|
+
echo "'Verdict: DONE' claimed but $report does not conclude Completeness CLEAN + Quality PASS. Fix the findings and re-run the verifier before declaring DONE." >&2
|
|
82
|
+
exit 2
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
# A verdict is about code, and code moves. The report records the commit it read
|
|
86
|
+
# (`> <date> | commit: <sha> | Completeness: ...`), because nothing re-runs the
|
|
87
|
+
# verifier when a later edit lands: without it, a report that concluded CLEAN
|
|
88
|
+
# outlives the code it was true of, and every green report reads the same whether
|
|
89
|
+
# it still holds. That is the one thing a green report cannot tell its reader.
|
|
90
|
+
#
|
|
91
|
+
# Scoped to the files the plan names, not the whole tree: the close protocol
|
|
92
|
+
# writes the behavior files, the archive, the changelog and the roadmap after the
|
|
93
|
+
# verifier has run, and a verification gate that fires on its own pipeline's
|
|
94
|
+
# paperwork is a bottleneck with no failure behind it. A delivered file whose
|
|
95
|
+
# content changed after the verdict is the unarguable case this catches. A report
|
|
96
|
+
# with no marker predates the field and passes, and git's absence fails open like
|
|
97
|
+
# every other environment-dependent check here.
|
|
98
|
+
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
99
|
+
judged=$(grep -oE '^>.*commit: *[0-9a-f]{7,40}' "$report" 2>/dev/null | head -1 | sed 's/.*commit: *//')
|
|
100
|
+
if [[ -n "$judged" ]] && ! git cat-file -e "${judged}^{commit}" 2>/dev/null; then
|
|
101
|
+
echo "$report names commit '$judged', which does not exist in this repository, so its verdict is about no tree here. Re-run the verifier and record the commit it read." >&2
|
|
102
|
+
exit 2
|
|
103
|
+
fi
|
|
104
|
+
top=$(git rev-parse --show-toplevel 2>/dev/null || true)
|
|
105
|
+
planned_files=()
|
|
106
|
+
while IFS= read -r f; do [[ -n "$f" ]] && planned_files+=("$f"); done <<<"$planned"
|
|
107
|
+
if [[ -n "$judged" && -n "$top" && ${#planned_files[@]} -gt 0 ]]; then
|
|
108
|
+
# Only a real difference blocks: a pathspec or shallow-clone error is the
|
|
109
|
+
# gate's own limitation, never the implementer's problem.
|
|
110
|
+
git -C "$top" diff --quiet "$judged" -- "${planned_files[@]}" 2>/dev/null
|
|
111
|
+
drift=$?
|
|
112
|
+
if [[ $drift -eq 1 ]]; then
|
|
113
|
+
echo "$report concluded CLEAN + PASS on $judged, and a file the plan delivered has changed since. A verdict holds for the commit it judged: re-run the verifier on the current code before declaring DONE." >&2
|
|
114
|
+
exit 2
|
|
115
|
+
fi
|
|
116
|
+
fi
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
# A failure called pre-existing has to be shown, not asserted. The DoD's own
|
|
120
|
+
# rationalization table already answers "the 2 failures are unrelated" with
|
|
121
|
+
# "then prove it: show they fail on the base branch too", and until Phase B
|
|
122
|
+
# started recording that run there was nothing to point at. baseline.md is that
|
|
123
|
+
# record; a report leaning on the claim without it is blocked here.
|
|
124
|
+
#
|
|
125
|
+
# The claim is what triggers the requirement, so a report that never makes it
|
|
126
|
+
# needs no baseline: this cannot block a project whose commands do not run.
|
|
127
|
+
preexisting_claim=$(awk '
|
|
128
|
+
{
|
|
129
|
+
line = $0
|
|
130
|
+
gsub(/[.!?;,]|[[:space:]]+(but|however|although)[[:space:]]+/, "\n", line)
|
|
131
|
+
n = split(line, clauses, "\n")
|
|
132
|
+
for (i = 1; i <= n; i++) {
|
|
133
|
+
text = tolower(clauses[i])
|
|
134
|
+
if (text ~ /pre-?existing|already failing|unrelated failure|fails on the base|failed before/ \
|
|
135
|
+
&& text !~ /(^|[^[:alnum:]])(no|not|never|without|zero)[[:space:]]/) {
|
|
136
|
+
print clauses[i]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}' "$report")
|
|
140
|
+
if [[ -n "$preexisting_claim" ]] && [[ ! -f "$spec/verifications/baseline.md" ]]; then
|
|
141
|
+
echo "$report calls a failure pre-existing, but $spec/verifications/baseline.md does not exist, so nothing shows it failing before this implementation. Capture the baseline (Phase B step 3) and re-run the verifier, or drop the claim." >&2
|
|
142
|
+
exit 2
|
|
143
|
+
fi
|
|
144
|
+
|
|
145
|
+
# An implementation that delivered nothing verifies CLEAN: the verifier scopes
|
|
146
|
+
# to the diff, and an empty diff has no placeholders in it. The plan's own
|
|
147
|
+
# `**Files:**` lines say what was meant to exist, so requiring one of them to be
|
|
148
|
+
# real is the crude version of the check nothing enforced.
|
|
149
|
+
#
|
|
150
|
+
# One file, not all of them: a plan whose file list was amended mid-flight is
|
|
151
|
+
# normal, and a gate that blocks legitimate work is worse than one that catches
|
|
152
|
+
# only the unarguable case. Paths under devos/ count like any other, because a
|
|
153
|
+
# spec whose whole job is to write a standards file delivered what it planned.
|
|
154
|
+
# Silent when the plan names no files (an M-route inline spec may not), same
|
|
155
|
+
# "validated only if present" posture as below.
|
|
156
|
+
if [[ -n "$planned" ]]; then
|
|
157
|
+
delivered=0
|
|
158
|
+
while IFS= read -r f; do
|
|
159
|
+
[[ -e "$f" ]] && { delivered=1; break; }
|
|
160
|
+
done <<<"$planned"
|
|
161
|
+
if [[ "$delivered" == 0 ]]; then
|
|
162
|
+
echo "'Verdict: DONE' claimed but not one file named in $plan's Implementation Plan exists. Nothing was delivered, which the verifier reads as a clean diff rather than as missing work." >&2
|
|
163
|
+
exit 2
|
|
164
|
+
fi
|
|
165
|
+
fi
|
|
166
|
+
|
|
167
|
+
# The edit hooks cover normal writes. This final pass catches files produced by
|
|
168
|
+
# a shell command or written before a hook loaded. The plan is the authoritative
|
|
169
|
+
# file list, and the boundary helper applies the same project-owned-code rule.
|
|
170
|
+
if [[ -f "$plan" && -x "$GATES/check-implementation-boundary.sh" ]]; then
|
|
171
|
+
# This repository's eval corpus is framework input, not target project output.
|
|
172
|
+
framework_repo=0
|
|
173
|
+
[[ -d "$PWD/plugins/devos/skills" && -d "$PWD/evals" ]] && framework_repo=1
|
|
174
|
+
while IFS= read -r f; do
|
|
175
|
+
[[ -e "$f" ]] || continue
|
|
176
|
+
if (( framework_repo )); then
|
|
177
|
+
case "$f" in
|
|
178
|
+
evals/*) continue ;;
|
|
179
|
+
esac
|
|
180
|
+
fi
|
|
181
|
+
boundary_reason=$("$GATES/check-implementation-boundary.sh" --scan --file "$f" 2>&1 >/dev/null)
|
|
182
|
+
boundary_status=$?
|
|
183
|
+
if [[ "$boundary_status" -eq 2 ]]; then
|
|
184
|
+
echo "'Verdict: DONE' claimed but $f contains internal process metadata. Keep trace IDs and framework rules in devos artifacts." >&2
|
|
185
|
+
[[ -n "$boundary_reason" ]] && echo "$boundary_reason" >&2
|
|
186
|
+
exit 2
|
|
187
|
+
fi
|
|
188
|
+
done <<<"$planned"
|
|
189
|
+
fi
|
|
190
|
+
|
|
191
|
+
# Temporary instrumentation, tagged per the B route's convention
|
|
192
|
+
# (`[DEBUG-xxxx]`, 4 hex digits), must be gone before DONE. Tracked files only:
|
|
193
|
+
# an untracked scratch script was never shipped. Scoped to the tag shape on
|
|
194
|
+
# purpose, so prose that documents the convention with the literal `xxxx`
|
|
195
|
+
# placeholder does not match itself. Fails open outside a git repo.
|
|
196
|
+
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
197
|
+
debug_hits=$(git grep -nE '\[DEBUG-[0-9a-f]{4}\]' 2>/dev/null | head -5)
|
|
198
|
+
if [[ -n "$debug_hits" ]]; then
|
|
199
|
+
echo "'Verdict: DONE' claimed but tagged debug instrumentation is still in tracked files. Remove it before declaring DONE:" >&2
|
|
200
|
+
echo "$debug_hits" >&2
|
|
201
|
+
exit 2
|
|
202
|
+
fi
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
# The Behavior delta names capabilities this spec changes; Completion step 1
|
|
206
|
+
# (references/verify-close.md) merges each into
|
|
207
|
+
# devos/product/behaviors/<capability>.md before the verdict is declared.
|
|
208
|
+
# Silent when no Behavior delta section exists at all: pre-v0.4.0 specs,
|
|
209
|
+
# M-route inline specs, and a delta with nothing changed are all legitimate
|
|
210
|
+
#.
|
|
211
|
+
sf="$spec/spec-functional.md"
|
|
212
|
+
if [[ -f "$sf" ]] && grep -qiE '^#+ .*behavior delta' "$sf"; then
|
|
213
|
+
spec_name="$(basename "$spec")"
|
|
214
|
+
while IFS= read -r line; do
|
|
215
|
+
marker=$(printf '%s' "$line" | grep -oE '\*\*(Added|Modified|Removed)\*\*')
|
|
216
|
+
cap=$(printf '%s' "$line" | grep -oE 'capability: *`[A-Za-z0-9-]+`' | tr -d '`' | sed 's/^capability: *//')
|
|
217
|
+
[[ -z "$cap" ]] && continue
|
|
218
|
+
bf="devos/product/behaviors/$cap.md"
|
|
219
|
+
if [[ "$marker" == "**Removed**" ]]; then
|
|
220
|
+
# A removal leaves a ## History tombstone, not necessarily a fresh
|
|
221
|
+
# last-spec header (nothing else about the file may have changed).
|
|
222
|
+
if [[ ! -f "$bf" ]] || ! grep -qE '^## History' "$bf" || ! grep -qF "$spec_name" "$bf"; then
|
|
223
|
+
echo "'Verdict: DONE' claimed but the Behavior delta's Removed entry for capability '$cap' has no History tombstone naming this spec in $bf. Merge the Behavior delta (Completion step 1) before declaring DONE." >&2
|
|
224
|
+
exit 2
|
|
225
|
+
fi
|
|
226
|
+
else
|
|
227
|
+
if [[ ! -f "$bf" ]] || ! grep -qF "last spec: $spec_name" "$bf"; then
|
|
228
|
+
echo "'Verdict: DONE' claimed but the Behavior delta names capability '$cap' ($marker), and $bf does not exist or its 'last spec:' header does not name this spec. Merge the Behavior delta (Completion step 1) before declaring DONE." >&2
|
|
229
|
+
exit 2
|
|
230
|
+
fi
|
|
231
|
+
fi
|
|
232
|
+
done < <(grep -E '\*\*(Added|Modified|Removed)\*\*.*capability:' "$sf")
|
|
233
|
+
fi
|
|
234
|
+
|
|
235
|
+
# Every `path:line` the report cites is re-derived from the tree. A finding's
|
|
236
|
+
# position is the part of it a candidate can get right in prose and wrong in
|
|
237
|
+
# fact, and until this pass nothing read it back: a citation past the end of its
|
|
238
|
+
# file blocked nothing and looked like every other line. The reflection lives in
|
|
239
|
+
# a sibling script so it is testable alone and any caller holding a report can
|
|
240
|
+
# run it; a missing or broken script fails open (a hook's own error is never
|
|
241
|
+
# policy), a reported finding blocks.
|
|
242
|
+
loc_out=$(bash "$(dirname "${BASH_SOURCE[0]}")/check-report-locations.sh" "$report" 2>&1)
|
|
243
|
+
loc_rc=$?
|
|
244
|
+
if [[ $loc_rc -eq 1 ]]; then
|
|
245
|
+
echo "'Verdict: DONE' claimed but $report cites positions that do not resolve:" >&2
|
|
246
|
+
echo "$loc_out" >&2
|
|
247
|
+
exit 2
|
|
248
|
+
fi
|
|
249
|
+
|
|
250
|
+
# The other half of the same reflection: the citation pass catches a row that
|
|
251
|
+
# points nowhere, this catches the row that was never written. The verifier is
|
|
252
|
+
# told to record every SC-n from spec-functional.md, and an omitted scenario is
|
|
253
|
+
# invisible exactly where the report reads cleanest. A missing or broken script
|
|
254
|
+
# fails open, a missing ID blocks, the same contract as the pass above.
|
|
255
|
+
cov_out=$(bash "$(dirname "${BASH_SOURCE[0]}")/check-scenario-coverage.sh" "$spec" 2>&1)
|
|
256
|
+
cov_rc=$?
|
|
257
|
+
if [[ $cov_rc -eq 1 ]]; then
|
|
258
|
+
echo "'Verdict: DONE' claimed but $report does not account for every scenario the functional spec declares:" >&2
|
|
259
|
+
echo "$cov_out" >&2
|
|
260
|
+
exit 2
|
|
261
|
+
fi
|
|
262
|
+
|
|
263
|
+
# A port reads one tree and writes another, and the tree it reads may be
|
|
264
|
+
# running in production. The manifest names the sources, so the sources are
|
|
265
|
+
# checked against the branch: an edit to one is a deploy of code nobody
|
|
266
|
+
# reviewed. The check lives in a sibling script so it is testable alone; a
|
|
267
|
+
# missing or broken script fails open, a reported finding blocks.
|
|
268
|
+
if [[ -f "$spec/manifest.tsv" ]]; then
|
|
269
|
+
src_out=$(bash "$(dirname "${BASH_SOURCE[0]}")/check-port-source.sh" --spec-dir "$spec" 2>&1)
|
|
270
|
+
src_rc=$?
|
|
271
|
+
if [[ $src_rc -eq 1 ]]; then
|
|
272
|
+
echo "'Verdict: DONE' claimed but the port touched the tree it reads:" >&2
|
|
273
|
+
echo "$src_out" >&2
|
|
274
|
+
exit 2
|
|
275
|
+
fi
|
|
276
|
+
fi
|
|
277
|
+
|
|
278
|
+
# Per-task acceptance gates (SPEC_DIR/gates.md) stay OUT of this gate on
|
|
279
|
+
# purpose: gate-check.mjs is the single parser of that format, and
|
|
280
|
+
# no spec has used one yet. Wire enforcement in only after a real spec has
|
|
281
|
+
# run with gates and the format has survived contact.
|
|
282
|
+
|
|
283
|
+
exit 0
|