@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,38 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# DoD stop-gate: a turn may not end on "Verdict: DONE" unless the spec's
|
|
3
|
+
# verification report actually exists. Deterministic, no LLM judgment.
|
|
4
|
+
# Exit 0 = allow, exit 2 = block (reason on stderr).
|
|
5
|
+
#
|
|
6
|
+
# Claude-specific transcript extraction (JSONL, stop_hook_active guard) lives
|
|
7
|
+
# here; the actual DONE/verification-report decision is the sibling
|
|
8
|
+
# check-dod-core.sh, shared with every adapter.
|
|
9
|
+
#
|
|
10
|
+
# This wrapper and its core sit inside the plugin so `claude plugin install`
|
|
11
|
+
# (which copies only the plugin dir) ships them together. Resolve the core as
|
|
12
|
+
# a sibling only, never a climb out of the plugin: on a copied install nothing
|
|
13
|
+
# outside ${CLAUDE_PLUGIN_ROOT} exists.
|
|
14
|
+
set -u
|
|
15
|
+
|
|
16
|
+
CORE="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)/check-dod-core.sh"
|
|
17
|
+
|
|
18
|
+
input=$(cat)
|
|
19
|
+
command -v jq >/dev/null 2>&1 || exit 0
|
|
20
|
+
|
|
21
|
+
# Avoid blocking loops: if we already blocked once this stop, let it through.
|
|
22
|
+
[[ $(printf '%s' "$input" | jq -r '.stop_hook_active // false' 2>/dev/null) == "true" ]] && exit 0
|
|
23
|
+
|
|
24
|
+
# jq's own parse errors stay off stderr: on non-JSON stdin this hook allows, and
|
|
25
|
+
# a hook that allows must say nothing. Stderr from a gate reads as a gate reason.
|
|
26
|
+
transcript=$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null)
|
|
27
|
+
[[ -f "$transcript" ]] || exit 0
|
|
28
|
+
|
|
29
|
+
last=$(jq -rs '[.[] | select(.type=="assistant")] | last
|
|
30
|
+
| .message.content | map(select(.type=="text") | .text) | join("\n")' "$transcript" 2>/dev/null) || exit 0
|
|
31
|
+
|
|
32
|
+
[[ -x "$CORE" ]] || exit 0
|
|
33
|
+
tmp=$(mktemp)
|
|
34
|
+
printf '%s' "$last" > "$tmp"
|
|
35
|
+
"$CORE" "$tmp"
|
|
36
|
+
status=$?
|
|
37
|
+
rm -f "$tmp"
|
|
38
|
+
exit "$status"
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# check-handoff.sh: turn-end handoff gate for multi-role specs. In team mode,
|
|
3
|
+
# the active spec must record the handoff for the phase it has reached, every
|
|
4
|
+
# handoff line must name an artifact that exists, and every role in those lines
|
|
5
|
+
# must resolve to a member.
|
|
6
|
+
#
|
|
7
|
+
# Deterministic, no model call. Solo users no-op: absent,
|
|
8
|
+
# template-only, single-member, or unparseable members.md means no gate.
|
|
9
|
+
#
|
|
10
|
+
# Fail-open by construction (deliberately fail-open): this script exits
|
|
11
|
+
# non-zero for a policy decision and for nothing else. Every internal failure
|
|
12
|
+
# (no jq, unreadable root, malformed members file) allows.
|
|
13
|
+
#
|
|
14
|
+
# Usage: check-handoff.sh [project-root]
|
|
15
|
+
# Optional stdin: the harness's stop-hook payload. Read only for the loop
|
|
16
|
+
# guard, never required.
|
|
17
|
+
set -u
|
|
18
|
+
|
|
19
|
+
PROJECT_ROOT="${1:-.}"
|
|
20
|
+
cd "$PROJECT_ROOT" 2>/dev/null || exit 0
|
|
21
|
+
PROJECT_ROOT_REAL=$(pwd -P) || exit 0
|
|
22
|
+
|
|
23
|
+
# Resolve an existing path without relying on realpath, which is not available
|
|
24
|
+
# on every macOS installation. Canonicalize both the parent and any final
|
|
25
|
+
# symlink so containment checks see the actual artifact.
|
|
26
|
+
absolute_existing_path() {
|
|
27
|
+
local input="$1" dir current link hops=0
|
|
28
|
+
dir=$(cd "$(dirname "$input")" 2>/dev/null && pwd -P) || return 1
|
|
29
|
+
current="$dir/$(basename "$input")"
|
|
30
|
+
while [[ -L "$current" ]]; do
|
|
31
|
+
((hops++))
|
|
32
|
+
((hops <= 40)) || return 1
|
|
33
|
+
link=$(readlink "$current") || return 1
|
|
34
|
+
if [[ "$link" = /* ]]; then
|
|
35
|
+
current="$link"
|
|
36
|
+
else
|
|
37
|
+
current="$(dirname "$current")/$link"
|
|
38
|
+
fi
|
|
39
|
+
dir=$(cd "$(dirname "$current")" 2>/dev/null && pwd -P) || return 1
|
|
40
|
+
current="$dir/$(basename "$current")"
|
|
41
|
+
done
|
|
42
|
+
printf '%s\n' "$current"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# Loop guard. A stop-gate block the model cannot satisfy would block every
|
|
46
|
+
# subsequent stop forever, so honor the harness's own already-blocked-once
|
|
47
|
+
# signal and allow the second time through: `stop_hook_active` (Claude, Codex,
|
|
48
|
+
# Copilot). Never read a terminal, this script is also run by hand
|
|
49
|
+
# and from test-gates.sh with no stdin attached.
|
|
50
|
+
input=""
|
|
51
|
+
[[ -t 0 ]] || input=$(cat 2>/dev/null)
|
|
52
|
+
command -v jq >/dev/null 2>&1 || exit 0
|
|
53
|
+
if [[ -n "$input" ]]; then
|
|
54
|
+
guard=$(printf '%s' "$input" | jq -r '
|
|
55
|
+
if (.stop_hook_active // .stopHookActive // false) then "stop"
|
|
56
|
+
elif ((.loop_count // 0) >= 1) then "stop"
|
|
57
|
+
else "go" end' 2>/dev/null)
|
|
58
|
+
# "stop": already blocked once this turn chain. Anything other than a clean
|
|
59
|
+
# "go" means the payload did not parse, so the guard cannot be trusted, and
|
|
60
|
+
# a gate that cannot tell whether it already blocked must not block again.
|
|
61
|
+
[[ "$guard" == "go" ]] || exit 0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
MEMBERS="devos/team/members.md"
|
|
65
|
+
[[ -f "$MEMBERS" ]] || exit 0
|
|
66
|
+
|
|
67
|
+
# One member per line: `- @name: role: <role>, skills: [...]`. Three traps, all
|
|
68
|
+
# hit in practice:
|
|
69
|
+
# - skip fenced blocks: the template documents its own format inside one, and
|
|
70
|
+
# counting that line armed the team gate for a solo user.
|
|
71
|
+
# - an unrecognized role does not count as a member. A typo must fall back to
|
|
72
|
+
# solo (no gate), never arm a gate whose reason names a role that isn't real.
|
|
73
|
+
# - count with awk, never `grep -c ... || echo 0`, which prints "0\n0" on zero
|
|
74
|
+
# matches and made the arithmetic test below error out and fall THROUGH to
|
|
75
|
+
# the blocking path.
|
|
76
|
+
roster=$(awk '
|
|
77
|
+
/^```/ { fenced = !fenced; next }
|
|
78
|
+
fenced { next }
|
|
79
|
+
/^- @[A-Za-z0-9_-]+:[[:space:]]*role:/ && $0 !~ /@name:/ {
|
|
80
|
+
name = $0; sub(/^- @/, "", name); sub(/:.*$/, "", name)
|
|
81
|
+
role = $0; sub(/^.*role:[[:space:]]*/, "", role); sub(/[,[:space:]].*$/, "", role)
|
|
82
|
+
if (role ~ /^(po|architect|dev|qa)$/) print name "\t" role
|
|
83
|
+
}
|
|
84
|
+
' "$MEMBERS" 2>/dev/null)
|
|
85
|
+
|
|
86
|
+
member_count=$(printf '%s\n' "$roster" | awk 'NF' | wc -l | tr -d ' ')
|
|
87
|
+
(( member_count <= 1 )) && exit 0
|
|
88
|
+
|
|
89
|
+
# Active spec: the one the current branch names, else the newest that has
|
|
90
|
+
# started. Rule 19 already guarantees the branch: Phase B creates
|
|
91
|
+
# a `[spec-name]` branch before the first edit and never works on the default
|
|
92
|
+
# branch, so the checkout already knows which spec this turn belongs to and no
|
|
93
|
+
# state file is needed to ask it. Newest-wins remains the fallback for work
|
|
94
|
+
# that is not on a spec branch (an S route, a pre-rule-19 spec, a detached
|
|
95
|
+
# HEAD, or a non-git project root), which is exactly the old behaviour.
|
|
96
|
+
#
|
|
97
|
+
# Newest-wins alone was
|
|
98
|
+
# wrong for the one case the team surface exists to serve: with two specs open,
|
|
99
|
+
# the older one could reach any phase with no handoff recorded.
|
|
100
|
+
spec_dir=""
|
|
101
|
+
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)
|
|
102
|
+
if [[ -n "$branch" ]]; then
|
|
103
|
+
cand="devos/specs/$branch"
|
|
104
|
+
if [[ -f "$cand/spec.md" || -f "$cand/spec-functional.md" ]]; then
|
|
105
|
+
spec_dir="$cand/"
|
|
106
|
+
fi
|
|
107
|
+
fi
|
|
108
|
+
if [[ -z "$spec_dir" ]]; then
|
|
109
|
+
for d in devos/specs/*/; do
|
|
110
|
+
[[ "$d" == "devos/specs/archive/" ]] && continue
|
|
111
|
+
[[ -f "${d}spec.md" || -f "${d}spec-functional.md" ]] || continue
|
|
112
|
+
spec_dir="$d"
|
|
113
|
+
done
|
|
114
|
+
fi
|
|
115
|
+
[[ -n "$spec_dir" ]] || exit 0
|
|
116
|
+
|
|
117
|
+
# Phase from artifacts, newest artifact wins: the transition that just
|
|
118
|
+
# completed is the one needing a recorded handoff.
|
|
119
|
+
if [[ -f "${spec_dir}verifications/verification.md" ]]; then
|
|
120
|
+
phase="verification"
|
|
121
|
+
need="verification.md"
|
|
122
|
+
elif [[ -f "${spec_dir}spec.md" ]]; then
|
|
123
|
+
phase="planning/implementation"
|
|
124
|
+
need="spec.md"
|
|
125
|
+
else
|
|
126
|
+
phase="requirements"
|
|
127
|
+
need="spec-functional.md"
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
# The Handoff section lives in spec.md once planning has produced one, and in
|
|
131
|
+
# spec-functional.md before that (the requirements handoff has nowhere else to go).
|
|
132
|
+
if [[ -f "${spec_dir}spec.md" ]]; then
|
|
133
|
+
host="${spec_dir}spec.md"
|
|
134
|
+
else
|
|
135
|
+
host="${spec_dir}spec-functional.md"
|
|
136
|
+
fi
|
|
137
|
+
if [[ "$phase" == "verification" ]]; then
|
|
138
|
+
need_path=$(absolute_existing_path "${spec_dir}verifications/$need")
|
|
139
|
+
else
|
|
140
|
+
need_path=$(absolute_existing_path "$spec_dir$need")
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
roles_available=$(printf '%s\n' "$roster" | awk -F'\t' 'NF {printf "@%s (%s) ", $1, $2}')
|
|
144
|
+
|
|
145
|
+
# The reason goes to stderr: an exit-2 hook's block message is read from
|
|
146
|
+
# stderr, so printing it to stdout blocks the turn with no explanation of why.
|
|
147
|
+
block() {
|
|
148
|
+
echo "BLOCKED: handoff gate, $phase phase of $spec_dir" >&2
|
|
149
|
+
printf '%s\n' "$@" >&2
|
|
150
|
+
echo "Handoff format in $host: - @from → @to | artifact | acceptance" >&2
|
|
151
|
+
echo "Members: $roles_available" >&2
|
|
152
|
+
exit 2
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
section=$(awk '/^## Handoff/ { f = 1; next } f && /^## / { exit } f' "$host" 2>/dev/null)
|
|
156
|
+
if [[ -z "${section//[[:space:]]/}" ]]; then
|
|
157
|
+
block "$host has no ## Handoff section with entries." \
|
|
158
|
+
"The $phase phase produced $need; record who hands it to whom."
|
|
159
|
+
fi
|
|
160
|
+
|
|
161
|
+
found_phase_line=0
|
|
162
|
+
while IFS='|' read -r who artifact accept; do
|
|
163
|
+
[[ -n "${who//[[:space:]-]/}" ]] || continue
|
|
164
|
+
|
|
165
|
+
if [[ "$who" != *"→"* && "$who" != *"->"* ]]; then
|
|
166
|
+
block "Handoff line is not a transition: $(printf '%s' "$who" | sed -E 's/^[[:space:]]*-[[:space:]]*//')" \
|
|
167
|
+
"Every line needs both sides: @from → @to."
|
|
168
|
+
fi
|
|
169
|
+
|
|
170
|
+
from=$(printf '%s' "$who" | sed -E 's/^[[:space:]]*-[[:space:]]*@?//; s/[[:space:]]*(→|->).*$//; s/[[:space:]]*$//')
|
|
171
|
+
to=$(printf '%s' "$who" | sed -E 's/^.*(→|->)[[:space:]]*@?//; s/[[:space:]]*$//')
|
|
172
|
+
artifact="${artifact#"${artifact%%[![:space:]]*}"}"
|
|
173
|
+
artifact="${artifact%"${artifact##*[![:space:]]}"}"
|
|
174
|
+
|
|
175
|
+
if [[ -z "$from" || -z "$to" ]]; then
|
|
176
|
+
block "Handoff line is missing one side of the transition: $(printf '%s' "$who" | sed -E 's/^[[:space:]]*-[[:space:]]*//')"
|
|
177
|
+
fi
|
|
178
|
+
if [[ -z "$artifact" || -z "${accept//[[:space:]]/}" ]]; then
|
|
179
|
+
block "Handoff line '$from → $to' is missing its artifact or acceptance field."
|
|
180
|
+
fi
|
|
181
|
+
|
|
182
|
+
for role in "$from" "$to"; do
|
|
183
|
+
printf '%s\n' "$roster" | awk -F'\t' -v t="$role" '$1 == t || $2 == t { hit = 1 } END { exit !hit }' ||
|
|
184
|
+
block "Handoff line '$from → $to' names @$role, which is not a member or role in $MEMBERS."
|
|
185
|
+
done
|
|
186
|
+
|
|
187
|
+
# The artifact a handoff promises must exist: a handoff naming a
|
|
188
|
+
# verification report that was never written is the same unbacked claim the
|
|
189
|
+
# DoD gate exists to catch (verification-evidence discipline).
|
|
190
|
+
artifact_path=""
|
|
191
|
+
if [[ -e "${spec_dir}${artifact}" ]]; then
|
|
192
|
+
artifact_path=$(absolute_existing_path "${spec_dir}${artifact}")
|
|
193
|
+
elif [[ -e "$artifact" ]]; then
|
|
194
|
+
artifact_path=$(absolute_existing_path "$artifact")
|
|
195
|
+
fi
|
|
196
|
+
if [[ -z "$artifact_path" ]]; then
|
|
197
|
+
block "Handoff line '$from → $to' names artifact '$artifact', which does not exist." \
|
|
198
|
+
"Produce it before recording the handoff, or fix the path (relative to $spec_dir or the project root)."
|
|
199
|
+
fi
|
|
200
|
+
|
|
201
|
+
case "$artifact_path" in
|
|
202
|
+
"$PROJECT_ROOT_REAL"/*) ;;
|
|
203
|
+
*) block "Handoff line '$from → $to' names artifact '$artifact' outside the project root." \
|
|
204
|
+
"Use an artifact inside $PROJECT_ROOT_REAL." ;;
|
|
205
|
+
esac
|
|
206
|
+
|
|
207
|
+
[[ "$artifact_path" == "$need_path" ]] && found_phase_line=1
|
|
208
|
+
done < <(printf '%s\n' "$section" | grep -E '^[[:space:]]*(-[[:space:]]*)?@' || true)
|
|
209
|
+
|
|
210
|
+
if (( found_phase_line == 0 )); then
|
|
211
|
+
block "The $phase phase produced $need, but no handoff line in $host names it." \
|
|
212
|
+
"Add the transition that hands $need to the next role."
|
|
213
|
+
fi
|
|
214
|
+
|
|
215
|
+
exit 0
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Deny process metadata in project-owned implementation files.
|
|
3
|
+
# SC trace IDs, framework rules, and framework names belong in devos/ artifacts.
|
|
4
|
+
# Project source, tests, comments, fixtures, and strings use project language only.
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# check-implementation-boundary.sh --file <path> --old <old-file> --new <new-file>
|
|
8
|
+
# check-implementation-boundary.sh --write --file <path> --old <old-file> --new <new-file>
|
|
9
|
+
# check-implementation-boundary.sh --scan --file <path>
|
|
10
|
+
#
|
|
11
|
+
# Exit 0 = allow or an internal error, 2 = project output contains internal metadata.
|
|
12
|
+
set -u
|
|
13
|
+
|
|
14
|
+
file=""
|
|
15
|
+
old=""
|
|
16
|
+
new=""
|
|
17
|
+
scan=0
|
|
18
|
+
write=0
|
|
19
|
+
while [[ $# -gt 0 ]]; do
|
|
20
|
+
case "$1" in
|
|
21
|
+
--file) [[ $# -ge 2 ]] || exit 0; file="$2"; shift 2 ;;
|
|
22
|
+
--old) [[ $# -ge 2 ]] || exit 0; old="$2"; shift 2 ;;
|
|
23
|
+
--new) [[ $# -ge 2 ]] || exit 0; new="$2"; shift 2 ;;
|
|
24
|
+
--scan) scan=1; shift ;;
|
|
25
|
+
--write) write=1; shift ;;
|
|
26
|
+
*) shift ;;
|
|
27
|
+
esac
|
|
28
|
+
done
|
|
29
|
+
|
|
30
|
+
# A malformed hook payload must not brick an edit.
|
|
31
|
+
[[ -n "$file" ]] || exit 0
|
|
32
|
+
|
|
33
|
+
is_internal_path() {
|
|
34
|
+
local path="$1" dir base rooted root
|
|
35
|
+
if [[ "$path" == /* ]]; then
|
|
36
|
+
dir=$(dirname "$path")
|
|
37
|
+
base=$(basename "$path")
|
|
38
|
+
else
|
|
39
|
+
dir="$PWD/$(dirname "$path")"
|
|
40
|
+
base=$(basename "$path")
|
|
41
|
+
fi
|
|
42
|
+
[[ -d "$dir" ]] || return 1
|
|
43
|
+
dir=$(cd "$dir" 2>/dev/null && pwd -P) || return 1
|
|
44
|
+
root=$(cd "$PWD" 2>/dev/null && pwd -P) || return 1
|
|
45
|
+
rooted="$dir/$base"
|
|
46
|
+
case "$rooted" in
|
|
47
|
+
"$root/devos/"*) return 0 ;;
|
|
48
|
+
"$root/plugins/devos/"*)
|
|
49
|
+
# The framework checkout is allowed to edit its own plugin source.
|
|
50
|
+
[[ -f "$PWD/plugins/devos/skills/build/SKILL.md" && -f "$PWD/devos/product/codebase-map.md" ]] && return 0
|
|
51
|
+
;;
|
|
52
|
+
esac
|
|
53
|
+
return 1
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
is_code_path() {
|
|
57
|
+
local path="$1"
|
|
58
|
+
case "$path" in
|
|
59
|
+
*.js|*.jsx|*.mjs|*.cjs|*.ts|*.tsx|*.mts|*.cts|*.py|*.go|*.rs|*.java|*.kt|*.kts|*.swift|*.rb|*.php|*.cs|*.c|*.h|*.cc|*.cpp|*.hpp|*.scala|*.clj|*.ex|*.exs|*.erl|*.dart|*.lua|*.r|*.jl|*.sh|*.bash|*.zsh|*.fish|*.sql|*.html|*.css|*.scss|*.sass|*.less|*.vue|*.svelte|*.astro|*.graphql|*.gql|*.proto) return 0 ;;
|
|
60
|
+
src/*|*/src/*|lib/*|*/lib/*|app/*|*/app/*|packages/*|*/packages/*|components/*|*/components/*|server/*|*/server/*|client/*|*/client/*) return 0 ;;
|
|
61
|
+
test/*|*/test/*|tests/*|*/tests/*|__tests__/*|*/__tests__/*) return 0 ;;
|
|
62
|
+
esac
|
|
63
|
+
return 1
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
is_internal_path "$file" && exit 0
|
|
67
|
+
is_code_path "$file" || exit 0
|
|
68
|
+
|
|
69
|
+
if (( scan )); then
|
|
70
|
+
[[ -f "$file" ]] || exit 0
|
|
71
|
+
old_content=""
|
|
72
|
+
new_content=$(cat "$file" 2>/dev/null) || exit 0
|
|
73
|
+
else
|
|
74
|
+
[[ -f "$new" ]] || exit 0
|
|
75
|
+
old_content=""
|
|
76
|
+
if (( ! write )) && [[ -f "$old" ]]; then
|
|
77
|
+
old_content=$(cat "$old" 2>/dev/null)
|
|
78
|
+
fi
|
|
79
|
+
new_content=$(cat "$new" 2>/dev/null) || exit 0
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# A hyphen, space, or underscore joins the ID to a test name. The leading
|
|
83
|
+
# boundary keeps names such as disc3 out while still catching test_sc_3.
|
|
84
|
+
INTERNAL_RE='(^|[^[:alnum:]])SC[-_ ]?([0-9]+|X)([^[:alnum:]]|$)|devos'
|
|
85
|
+
hits=$(printf '%s\n' "$new_content" | grep -EIin "$INTERNAL_RE" 2>/dev/null || true)
|
|
86
|
+
|
|
87
|
+
while IFS= read -r hit; do
|
|
88
|
+
[[ -n "$hit" ]] || continue
|
|
89
|
+
lineno="${hit%%:*}"
|
|
90
|
+
line="${hit#*:}"
|
|
91
|
+
old_count=$(printf '%s\n' "$old_content" | grep -Fxc -- "$line" 2>/dev/null || true)
|
|
92
|
+
new_count=$(printf '%s\n' "$new_content" | grep -Fxc -- "$line" 2>/dev/null || true)
|
|
93
|
+
if (( new_count > old_count )); then
|
|
94
|
+
echo "Implementation output contains internal process metadata at $file:$lineno. Keep trace IDs and framework rules in devos artifacts." >&2
|
|
95
|
+
exit 2
|
|
96
|
+
fi
|
|
97
|
+
done <<<"$hits"
|
|
98
|
+
|
|
99
|
+
exit 0
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# check-port-source.sh: the tree a port reads is not the tree it writes.
|
|
3
|
+
#
|
|
4
|
+
# A port writes a new tree and leaves the tree it read alone, and the tree it
|
|
5
|
+
# read may be running in production. An edit to it is a deploy of code nobody
|
|
6
|
+
# reviewed, so the manifest's sources are off limits for the length of the
|
|
7
|
+
# port.
|
|
8
|
+
#
|
|
9
|
+
# The manifest is the contract: it names the source of every unit. The base
|
|
10
|
+
# is the commit that introduced the spec, because the spec is what the port
|
|
11
|
+
# reads, and everything after it is the port's own work. A spec that was never
|
|
12
|
+
# committed has no committed port work to compare against, so only the
|
|
13
|
+
# uncommitted changes are judged. A check that cannot say anything fails open:
|
|
14
|
+
# the hook's own trouble is never policy.
|
|
15
|
+
#
|
|
16
|
+
# Usage:
|
|
17
|
+
# check-port-source.sh --spec-dir DIR [--root DIR]
|
|
18
|
+
#
|
|
19
|
+
# Diagnostic envelope (shared by DevOS check scripts):
|
|
20
|
+
# FAIL <check>: <message>
|
|
21
|
+
# fix: <one actionable line>
|
|
22
|
+
# Exit 0 = nothing touched, 1 = a source path changed, 2 = usage.
|
|
23
|
+
set -u
|
|
24
|
+
SPEC_DIR=""
|
|
25
|
+
ROOT=""
|
|
26
|
+
while [[ $# -gt 0 ]]; do
|
|
27
|
+
case "$1" in
|
|
28
|
+
--spec-dir) SPEC_DIR="${2:-}"; shift 2 ;;
|
|
29
|
+
--root) ROOT="${2:-}"; shift 2 ;;
|
|
30
|
+
-h | --help) sed -n '2,22p' "$0"; exit 0 ;;
|
|
31
|
+
*) echo "FAIL check-port-source: unknown argument: $1" >&2; echo " fix: pass --spec-dir DIR" >&2; exit 2 ;;
|
|
32
|
+
esac
|
|
33
|
+
done
|
|
34
|
+
[[ -n "$SPEC_DIR" ]] || { echo "FAIL check-port-source: no spec dir given" >&2; echo " fix: pass --spec-dir DIR" >&2; exit 2; }
|
|
35
|
+
|
|
36
|
+
ROOT="${ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
|
|
37
|
+
[[ -d "$ROOT" ]] || exit 0
|
|
38
|
+
git -C "$ROOT" rev-parse --git-dir >/dev/null 2>&1 || exit 0
|
|
39
|
+
prefix=$(git -C "$ROOT" rev-parse --show-prefix 2>/dev/null || echo "")
|
|
40
|
+
|
|
41
|
+
# The spec dir is named relative to the caller, to the root, or absolutely, and
|
|
42
|
+
# a closed spec ends up under devos/specs/archive. Every path the check
|
|
43
|
+
# compares is repo-root relative, so the spec dir is converted to that first.
|
|
44
|
+
to_repo_path() {
|
|
45
|
+
local d="$1" abs
|
|
46
|
+
case "$d" in
|
|
47
|
+
/*) abs="$d" ;;
|
|
48
|
+
*) abs="$(cd "$d" 2>/dev/null && pwd)" || abs="" ;;
|
|
49
|
+
esac
|
|
50
|
+
[[ -n "$abs" && "$abs" == "$ROOT"/* ]] && { echo "${abs#"$ROOT"/}"; return; }
|
|
51
|
+
[[ -n "$abs" && "$abs" == "$ROOT" ]] && { echo "."; return; }
|
|
52
|
+
echo ""
|
|
53
|
+
}
|
|
54
|
+
spec_rel=$(to_repo_path "$SPEC_DIR")
|
|
55
|
+
if [[ -z "$spec_rel" || ! -d "$ROOT/$spec_rel" ]]; then
|
|
56
|
+
name=$(basename "$SPEC_DIR")
|
|
57
|
+
for c in "devos/specs/$name" "devos/specs/archive/$name"; do
|
|
58
|
+
[[ -d "$ROOT/$c" ]] && { spec_rel="$c"; break; }
|
|
59
|
+
done
|
|
60
|
+
fi
|
|
61
|
+
[[ -n "$spec_rel" && -d "$ROOT/$spec_rel" ]] || exit 0
|
|
62
|
+
|
|
63
|
+
manifest="$ROOT/$spec_rel/manifest.tsv"
|
|
64
|
+
[[ -f "$manifest" ]] || exit 0
|
|
65
|
+
|
|
66
|
+
sources=()
|
|
67
|
+
while IFS=$'\t' read -r src tgt; do
|
|
68
|
+
[[ "$src" == "source" ]] && continue
|
|
69
|
+
[[ -n "$src" ]] || continue
|
|
70
|
+
sources+=("${src%/}")
|
|
71
|
+
done <"$manifest"
|
|
72
|
+
[[ "${#sources[@]}" -gt 0 ]] || exit 0
|
|
73
|
+
|
|
74
|
+
# The protected set is the manifest's own paths plus the tree they share: a
|
|
75
|
+
# port that edits a legacy file the manifest never named is still editing the
|
|
76
|
+
# tree it reads. The shared prefix is only a tree when it is narrower than the
|
|
77
|
+
# repository, otherwise it names the whole checkout and protects everything.
|
|
78
|
+
protected=("${sources[@]}")
|
|
79
|
+
common_dir() {
|
|
80
|
+
local acc="$1" s="$2" a b
|
|
81
|
+
while :; do
|
|
82
|
+
a="${acc%/*}"
|
|
83
|
+
b="${s%/*}"
|
|
84
|
+
[[ "$a" == "$acc" && "$b" == "$s" ]] && break
|
|
85
|
+
acc="$a"
|
|
86
|
+
s="$b"
|
|
87
|
+
[[ -z "$acc" || -z "$s" ]] && { echo ""; return; }
|
|
88
|
+
done
|
|
89
|
+
echo "$acc"
|
|
90
|
+
}
|
|
91
|
+
prefix_dir="${sources[0]}"
|
|
92
|
+
for s in "${sources[@]}"; do
|
|
93
|
+
d=$(common_dir "$prefix_dir" "$s")
|
|
94
|
+
[[ -z "$d" ]] && { prefix_dir=""; break; }
|
|
95
|
+
prefix_dir="$d"
|
|
96
|
+
done
|
|
97
|
+
if [[ -n "$prefix_dir" && "$prefix_dir" != "." && "$prefix_dir" != "/" ]]; then
|
|
98
|
+
protected+=("$prefix_dir")
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
# The base is the commit that introduced the spec. The manifest is what the
|
|
102
|
+
# port reads, and the spec file is what the port answers to, so whichever
|
|
103
|
+
# landed first is the state the port started from.
|
|
104
|
+
base=""
|
|
105
|
+
for rel in "manifest.tsv" "spec-functional.md" "spec.md"; do
|
|
106
|
+
p="$spec_rel/$rel"
|
|
107
|
+
[[ -f "$ROOT/$p" ]] || continue
|
|
108
|
+
c=$(git -C "$ROOT" log --format=%H --diff-filter=A --follow -- "$p" 2>/dev/null | tail -1)
|
|
109
|
+
[[ -n "$c" ]] || continue
|
|
110
|
+
base="$c"
|
|
111
|
+
break
|
|
112
|
+
done
|
|
113
|
+
[[ -n "$base" ]] || exit 0
|
|
114
|
+
|
|
115
|
+
changed=$(git -C "$ROOT" diff --name-only "$base"..HEAD 2>/dev/null || true)
|
|
116
|
+
pending=$(git -C "$ROOT" status --porcelain 2>/dev/null | sed -E 's/^...//; s/.* -> //' || true)
|
|
117
|
+
|
|
118
|
+
hit=0
|
|
119
|
+
seen=" "
|
|
120
|
+
for file in $changed $pending; do
|
|
121
|
+
file="${file#./}"
|
|
122
|
+
[[ -n "$file" ]] || continue
|
|
123
|
+
case "$seen" in *" $file "*) continue ;; esac
|
|
124
|
+
for p in "${protected[@]}"; do
|
|
125
|
+
if [[ "$file" == "$p" || "$file" == "$p"/* ]]; then
|
|
126
|
+
seen="$seen$file "
|
|
127
|
+
echo "FAIL check-port-source: the port changed $file, and the tree it reads is not the tree it writes"
|
|
128
|
+
echo " fix: revert that change; the legacy tree keeps running while the port lands, and a port that edits it deploys code nobody reviewed"
|
|
129
|
+
hit=1
|
|
130
|
+
break
|
|
131
|
+
fi
|
|
132
|
+
done
|
|
133
|
+
done
|
|
134
|
+
exit $hit
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# check-report-locations.sh: reflection pass over a verification report.
|
|
3
|
+
# Deterministic, zero model calls.
|
|
4
|
+
#
|
|
5
|
+
# A verification report cites positions (`path:line`). The verifier writes them
|
|
6
|
+
# from memory or from a diff hunk, and until this script nothing checked a
|
|
7
|
+
# citation against the tree: a line past the end of its file, or a path that
|
|
8
|
+
# never existed, reads exactly like a real one. This re-derives every citation
|
|
9
|
+
# and reports the ones that do not survive contact, instead of trusting the
|
|
10
|
+
# report's account of where the problem is.
|
|
11
|
+
#
|
|
12
|
+
# Usage: check-report-locations.sh <spec-dir | verification.md> [--root DIR]
|
|
13
|
+
# <spec-dir> resolves to <spec-dir>/verifications/verification.md
|
|
14
|
+
# Exit 0 = every citation resolves, 1 = findings, 2 = usage/missing report.
|
|
15
|
+
set -u
|
|
16
|
+
|
|
17
|
+
target="${1:-}"
|
|
18
|
+
shift || true
|
|
19
|
+
root=""
|
|
20
|
+
while [[ $# -gt 0 ]]; do
|
|
21
|
+
case "$1" in
|
|
22
|
+
--root) root="${2:-}"; shift 2 ;;
|
|
23
|
+
*) shift ;;
|
|
24
|
+
esac
|
|
25
|
+
done
|
|
26
|
+
|
|
27
|
+
if [[ -z "$target" ]]; then
|
|
28
|
+
echo "usage: check-report-locations.sh <spec-dir | verification.md> [--root DIR]" >&2
|
|
29
|
+
exit 2
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
report=""
|
|
33
|
+
if [[ -d "$target" ]]; then
|
|
34
|
+
report="$target/verifications/verification.md"
|
|
35
|
+
elif [[ -f "$target" ]]; then
|
|
36
|
+
report="$target"
|
|
37
|
+
else
|
|
38
|
+
echo "FAIL check-report-locations: no report at '$target'" >&2
|
|
39
|
+
echo " fix: pass a spec folder (devos/specs/<name>) or a verification.md" >&2
|
|
40
|
+
exit 2
|
|
41
|
+
fi
|
|
42
|
+
if [[ ! -f "$report" ]]; then
|
|
43
|
+
echo "FAIL check-report-locations: $report does not exist" >&2
|
|
44
|
+
echo " fix: run the verifier before citing its report" >&2
|
|
45
|
+
exit 2
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# The project root is the ancestor holding devos/. Resolving it here keeps the
|
|
49
|
+
# call cwd-independent: a hook, the suite, and a human all pass the same
|
|
50
|
+
# relative report path and get the same answer.
|
|
51
|
+
if [[ -z "$root" ]]; then
|
|
52
|
+
d="$(cd "$(dirname "$report")" && pwd)"
|
|
53
|
+
while [[ "$d" != "/" ]]; do
|
|
54
|
+
if [[ -d "$d/devos" ]]; then root="$d"; break; fi
|
|
55
|
+
d="$(dirname "$d")"
|
|
56
|
+
done
|
|
57
|
+
[[ -n "$root" ]] || root="$(pwd)"
|
|
58
|
+
fi
|
|
59
|
+
report_dir="$(cd "$(dirname "$report")" && pwd)"
|
|
60
|
+
spec_dir="$(dirname "$report_dir")"
|
|
61
|
+
root_real=$(cd "$root" 2>/dev/null && pwd -P) || root_real="$root"
|
|
62
|
+
|
|
63
|
+
# Strip URLs first: `https://host:8080/a.js:9` carries a colon-number that is not
|
|
64
|
+
# a citation. Left in, every link in a report would be reported as a bad path.
|
|
65
|
+
body="$(sed -E 's#https?://[^ )>]*##g' "$report")"
|
|
66
|
+
|
|
67
|
+
refs="$(grep -oE '(\.[A-Za-z0-9_-]+|[A-Za-z0-9_./-][A-Za-z0-9_./-]*\.[A-Za-z0-9]+):[0-9]+(-[0-9]+)?' <<<"$body" | sort -u)"
|
|
68
|
+
[[ -z "$refs" ]] && { echo "PASS check-report-locations: $report cites no positions"; exit 0; }
|
|
69
|
+
|
|
70
|
+
fail=0
|
|
71
|
+
finding() { echo "FAIL check-report-locations: $1"; echo " fix: $2"; fail=1; }
|
|
72
|
+
|
|
73
|
+
canonicalize_candidate() {
|
|
74
|
+
local candidate="$1" candidate_dir current link hops=0
|
|
75
|
+
candidate_dir=$(cd "$(dirname "$candidate")" 2>/dev/null && pwd -P) || return 1
|
|
76
|
+
current="$candidate_dir/$(basename "$candidate")"
|
|
77
|
+
while [[ -L "$current" ]]; do
|
|
78
|
+
((hops++))
|
|
79
|
+
if ((hops > 40)); then
|
|
80
|
+
return 1
|
|
81
|
+
fi
|
|
82
|
+
link=$(readlink "$current") || return 1
|
|
83
|
+
if [[ "$link" = /* ]]; then
|
|
84
|
+
current="$link"
|
|
85
|
+
else
|
|
86
|
+
current="$(dirname "$current")/$link"
|
|
87
|
+
fi
|
|
88
|
+
candidate_dir=$(cd "$(dirname "$current")" 2>/dev/null && pwd -P) || return 1
|
|
89
|
+
current="$candidate_dir/$(basename "$current")"
|
|
90
|
+
done
|
|
91
|
+
printf '%s\n' "$current"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
while IFS= read -r ref; do
|
|
95
|
+
[[ -n "$ref" ]] || continue
|
|
96
|
+
path="${ref%%:*}"
|
|
97
|
+
rng="${ref#*:}"
|
|
98
|
+
start="${rng%%-*}"
|
|
99
|
+
end="${rng##*-}"
|
|
100
|
+
if [[ "$start" -lt 1 ]]; then
|
|
101
|
+
finding "$report cites $ref but source line numbers start at 1" \
|
|
102
|
+
"re-derive the citation from the first line of the file"
|
|
103
|
+
continue
|
|
104
|
+
fi
|
|
105
|
+
if [[ "$end" -lt "$start" ]]; then
|
|
106
|
+
finding "$report cites $ref but its range end $end is before start $start" \
|
|
107
|
+
"use an in-order range such as $start-$start or a later end line"
|
|
108
|
+
continue
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
f=""
|
|
112
|
+
escaped=0
|
|
113
|
+
for base in "$root" "$spec_dir" "$report_dir"; do
|
|
114
|
+
candidate="$base/$path"
|
|
115
|
+
candidate_real=$(canonicalize_candidate "$candidate") || continue
|
|
116
|
+
case "$candidate_real" in
|
|
117
|
+
"$root_real"/*) ;;
|
|
118
|
+
*) escaped=1; continue ;;
|
|
119
|
+
esac
|
|
120
|
+
if [[ -f "$candidate_real" ]]; then f="$candidate_real"; break; fi
|
|
121
|
+
done
|
|
122
|
+
if [[ -z "$f" && "$escaped" -eq 1 ]]; then
|
|
123
|
+
finding "$report cites $ref but the path resolves outside the project root" \
|
|
124
|
+
"cite a file contained by $root, or drop the citation"
|
|
125
|
+
continue
|
|
126
|
+
fi
|
|
127
|
+
if [[ -z "$f" ]]; then
|
|
128
|
+
finding "$report cites $ref but no such file exists under $root" \
|
|
129
|
+
"point the finding at a real path, or drop the citation"
|
|
130
|
+
continue
|
|
131
|
+
fi
|
|
132
|
+
|
|
133
|
+
total=$(awk 'END{print NR+0}' "$f")
|
|
134
|
+
if (( start > total )); then
|
|
135
|
+
finding "$report cites $ref but ${path} has only $total lines" \
|
|
136
|
+
"re-derive the line from the current file; the citation drifted"
|
|
137
|
+
continue
|
|
138
|
+
fi
|
|
139
|
+
if (( end > total )); then
|
|
140
|
+
finding "$report cites $ref but ${path} has only $total lines" \
|
|
141
|
+
"re-derive the range from the current file; the citation drifted"
|
|
142
|
+
fi
|
|
143
|
+
done <<<"$refs"
|
|
144
|
+
|
|
145
|
+
if (( fail == 0 )); then
|
|
146
|
+
echo "PASS check-report-locations: every citation in $report resolves"
|
|
147
|
+
fi
|
|
148
|
+
exit $fail
|