@greenrenge/skills 0.0.0-stage → 0.2.0

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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +99 -2
  3. package/bin/cli.mjs +525 -0
  4. package/bin/lib/onboard.mjs +1168 -0
  5. package/bin/lib/probe.mjs +631 -0
  6. package/catalog.json +590 -0
  7. package/package.json +50 -4
  8. package/skills/deck-story/SKILL.md +258 -0
  9. package/skills/deck-story/check-svg-text.mjs +94 -0
  10. package/skills/deck-story/check.mjs +348 -0
  11. package/skills/diagram-router/LICENSE +21 -0
  12. package/skills/diagram-router/SKILL.md +193 -0
  13. package/skills/diagram-router/THIRD_PARTY_NOTICES.md +15 -0
  14. package/skills/diagram-router/references/channels.md +213 -0
  15. package/skills/diagram-router/references/evals.md +85 -0
  16. package/skills/diagram-router/references/gathering.md +101 -0
  17. package/skills/diagram-router/references/prior-art.md +65 -0
  18. package/skills/diagram-router/references/routing.md +166 -0
  19. package/skills/diagram-router/skill-release.json +17 -0
  20. package/skills/frontend-design/SKILL.md +443 -0
  21. package/skills/frontend-design/references/rtl.md +72 -0
  22. package/skills/frontend-design/scripts/.upstream-sha +1 -0
  23. package/skills/frontend-design/scripts/LICENSE +21 -0
  24. package/skills/frontend-design/scripts/README.md +24 -0
  25. package/skills/frontend-design/scripts/gates.md +243 -0
  26. package/skills/frontend-design/scripts/sloplint-render.mjs +1283 -0
  27. package/skills/frontend-design/scripts/sloplint.mjs +4426 -0
  28. package/skills/open-code-review-rules/SKILL.md +59 -0
  29. package/skills/open-code-review-rules/references/ocr-allowlists.json +161 -0
  30. package/skills/open-code-review-rules/references/ocr-rule-semantics.md +39 -0
  31. package/skills/open-code-review-rules/scripts/verify_ocr_rules.py +836 -0
  32. package/skills/plain-english-mode/SKILL.md +41 -0
  33. package/skills/pr-diagram-portfolio/SKILL.md +75 -0
  34. package/skills/pr-diagram-portfolio/references/angle-framework.md +124 -0
  35. package/skills/pr-diagram-portfolio/references/portfolio-delivery.md +79 -0
  36. package/skills/pr-diagram-portfolio/scripts/restore_still_css.py +180 -0
  37. package/skills/pr-lens/LICENSE-upstream +21 -0
  38. package/skills/pr-lens/SKILL.md +99 -0
  39. package/skills/pr-lens/VENDOR.md +47 -0
  40. package/skills/pr-lens/package-lock.json +91 -0
  41. package/skills/pr-lens/package.json +9 -0
  42. package/skills/pr-lens/references/config.md +90 -0
  43. package/skills/pr-lens/references/example.graph.json +580 -0
  44. package/skills/pr-lens/references/graph-document.md +233 -0
  45. package/skills/pr-lens/skill-release.json +16 -0
  46. package/skills/security-remediation-epic/SKILL.md +316 -0
  47. package/skills/security-remediation-epic/prompt-template.md +33 -0
  48. package/skills/skill-maintainer/SKILL.md +99 -0
  49. package/skills/skill-maintainer/references/placement-and-coupling.md +43 -0
  50. package/skills/skill-maintainer/scripts/audit_skills.py +297 -0
  51. package/skills/t3-successor-handoff/SKILL.md +141 -0
  52. package/skills/t3-thread-bridge/SKILL.md +175 -0
  53. package/skills/t3-thread-bridge/references/launch-recipes.md +123 -0
  54. package/skills/t3-thread-bridge/references/ping-back.md +108 -0
  55. package/skills/t3-thread-bridge/scripts/thread_ledger.py +203 -0
  56. package/skills/t3-ticket-orchestrator/SKILL.md +304 -0
  57. package/skills/t3-ticket-orchestrator/references/proving-the-gates.md +63 -0
  58. package/skills/ticket-scheme/SKILL.md +144 -0
  59. package/skills/ulw-plan/SKILL.md +98 -0
  60. package/skills/ulw-plan/references/full-workflow.md +255 -0
  61. package/skills/ulw-plan/references/intent-clear.md +44 -0
  62. package/skills/ulw-plan/references/intent-unclear.md +44 -0
  63. package/skills/ulw-plan/scripts/plan-templates.mjs +180 -0
  64. package/skills/ulw-plan/scripts/scaffold-plan.mjs +187 -0
@@ -0,0 +1,233 @@
1
+ # Authoring a graph document
2
+
3
+ This page is the whole shape, and what a schema cannot tell you besides: which parts matter, and where documents actually go wrong. `references/example.graph.json` is one document that validates, if you would rather read than be told.
4
+
5
+ The validator enforces the same thing from a JSON Schema, published at `https://unpkg.com/@coldtea/pr-lens-schema/json-schema/graph-doc.schema.json` if you want it machine-readable.
6
+
7
+ Every schema here is **strict**: an unknown key is a rejection, not a warning. A field with a default may be left out.
8
+
9
+ ## The document
10
+
11
+ ```json
12
+ {
13
+ "schemaVersion": "0.1.0",
14
+ "kind": "graph",
15
+ "title": "Batch broadcast sending through Postmark",
16
+ "summary": "One paragraph answering: what does this change do?",
17
+ "lenses": ["architecture", "data-flow"],
18
+ "provenance": { "repo": { "owner": "…", "name": "…" }, "base": { "sha": "…" }, "head": { "sha": "…" } },
19
+ "lanes": [],
20
+ "nodes": [],
21
+ "edges": [],
22
+ "flows": [],
23
+ "stats": {},
24
+ "views": []
25
+ }
26
+ ```
27
+
28
+ `lenses` declares what the document carries enough detail to draw: `architecture`, `data-flow`, or both. A document carrying flows must declare `data-flow`.
29
+
30
+ `provenance` is where the document came from: the repository, the base and head commit shas (lowercase hex, 7-40 characters), optionally the pull request and the generator. When you produce a document through the CLI these are filled in from the repository, so do not invent them.
31
+
32
+ ## Ids
33
+
34
+ `^[A-Za-z0-9][A-Za-z0-9._:/-]*$`, at most 128 characters, unique within their own collection. Use readable kebab-case: `broadcast-sender`, not `n1`. An id ends up in an SVG id, a URL fragment and a comment anchor, so nothing else is allowed through.
35
+
36
+ ## Deltas
37
+
38
+ Every node, edge, flow and flow step declares one: `added`, `modified`, `removed`, `unchanged`.
39
+
40
+ `unchanged` is not padding. It is the neighbouring code the change touches, and it is what turns a diagram into a blast radius. A document whose every element is `added` describes a change nobody can place.
41
+
42
+ ## Lanes
43
+
44
+ 1 to 16. Every node belongs to exactly one.
45
+
46
+ ```json
47
+ { "id": "functions", "label": "Cloud Functions", "subtitle": "Node 20", "order": 1 }
48
+ ```
49
+
50
+ `order` (0-64) places lanes left to right; ties fall back to array order. Give a lane a `delta` only when the lane itself is new or gone.
51
+
52
+ ## Nodes
53
+
54
+ 1 to 256.
55
+
56
+ ```json
57
+ {
58
+ "id": "send-broadcast-bulk",
59
+ "label": "sendBroadcastBulk",
60
+ "kind": "function",
61
+ "delta": "added",
62
+ "lane": "functions",
63
+ "group": "broadcast-lib",
64
+ "subtitle": "(broadcastId) => Promise<void>",
65
+ "summary": "Claims the broadcast, builds one bulk payload and posts it.",
66
+ "files": [{ "path": "functions/src/broadcast/sendBroadcastBulk.ts", "startLine": 1, "endLine": 142 }],
67
+ "badges": ["retry"]
68
+ }
69
+ ```
70
+
71
+ `kind` is one of `service app module function route job queue datastore cache external ui config test package other`. It drives the card's icon and shape and nothing else; when in doubt, `other` still renders.
72
+
73
+ `group` clusters nodes inside a lane: a package, a folder that means something. `files` (up to 64) become diff permalinks. `badges` (up to 6) are extra chips; the delta badge is drawn for you, so do not restate it.
74
+
75
+ ## Edges
76
+
77
+ Up to 512.
78
+
79
+ ```json
80
+ {
81
+ "id": "bulk-to-postmark",
82
+ "from": "send-broadcast-bulk",
83
+ "to": "postmark",
84
+ "kind": "http",
85
+ "delta": "added",
86
+ "label": "POST /email/bulk",
87
+ "emphasis": "hero",
88
+ "animated": true
89
+ }
90
+ ```
91
+
92
+ `kind` is one of `call http rpc event queue data dependency render other`. `emphasis` is `normal` (default), `hero` or `muted`. More than one or two heroes and the emphasis stops meaning anything. `from` and `to` must be node ids you declared. This is the single most common failure.
93
+
94
+ ## Flows
95
+
96
+ Up to 16, for the data-flow lens.
97
+
98
+ ```json
99
+ {
100
+ "id": "send-pipeline",
101
+ "title": "Sending a broadcast",
102
+ "delta": "modified",
103
+ "participants": [{ "node": "queue-route" }, { "node": "send-broadcast-bulk" }, { "node": "postmark" }],
104
+ "messages": [
105
+ { "id": "enqueue", "from": "queue-route", "to": "send-broadcast-bulk", "label": "enqueue job", "kind": "async", "delta": "modified" },
106
+ { "id": "send", "from": "send-broadcast-bulk", "to": "postmark", "label": "POST /email/bulk", "kind": "sync", "delta": "added", "repeat": 4 },
107
+ { "id": "accepted", "from": "postmark", "to": "send-broadcast-bulk", "label": "200 Accepted", "kind": "return", "delta": "added" }
108
+ ]
109
+ }
110
+ ```
111
+
112
+ - 2 to 12 participants, ordered by array position; each names a node id.
113
+ - 1 to 64 messages. **Step order is array order**: there is no step number field, so a document cannot disagree with its own animation.
114
+ - `kind` is `sync`, `async`, `return` or `self`. `self` requires `from === to`, and no other kind may have them equal.
115
+ - Both endpoints must be participants of that flow, not merely nodes of the document.
116
+ - `repeat` says a step happens more than once per run, e.g. 4 batched requests.
117
+
118
+ ## Stats
119
+
120
+ ```json
121
+ { "filesChanged": 27, "additions": 1979, "deletions": 1370, "chips": [{ "label": "Postmark calls", "value": "500x fewer", "tone": "hero" }] }
122
+ ```
123
+
124
+ Up to 8 chips, `tone` one of `neutral added modified removed hero`. Per-delta element counts are deliberately absent from the schema: they are derivable from the document, and a stored copy can only go stale.
125
+
126
+ ## Views
127
+
128
+ The drill-down tree in the comment: up to 32 at the root, nesting up to 32 children each. A document with no views renders as one picture and nothing else.
129
+
130
+ ```json
131
+ {
132
+ "id": "the-new-path",
133
+ "title": "The new batch path",
134
+ "lens": "architecture",
135
+ "summary": "What replaced the per-recipient loop.",
136
+ "defaultOpen": false,
137
+ "scope": { "kind": "selection", "nodes": ["send-broadcast-bulk", "postmark"] },
138
+ "children": []
139
+ }
140
+ ```
141
+
142
+ `scope` is either `{ "kind": "all" }` (the default) or a selection naming at least one lane, node, edge or flow. The two are distinct states on purpose: removing the last element a view pointed at can never quietly turn it into a view of everything. A view's `lens` must be one the document declares.
143
+
144
+ ### Choosing architecture views
145
+
146
+ Treat the architecture tree as a set of decisions, not a quota:
147
+
148
+ 1. Ask whether the change affects a user, an external system or a system boundary. If it does, start with a system-context view. If it does not, leave that level out.
149
+ 2. Show affected applications, services, jobs, data stores and runtimes in a container view. Make it the root when there is no useful context view; otherwise make it a child of that context.
150
+ 3. Add a component child only when the internals of an affected container matter to the change. Components may be modules, routes or functions, but the view should explain their responsibilities and relationships rather than mirror folders.
151
+ 4. Stop at components unless someone explicitly asks for code-level detail.
152
+
153
+ One architecture view may be the right answer for a small change. Each child must move down exactly one level and cover a materially narrower scope. Skip a level when it would be empty, speculative or a repeat of its parent. Do not create two views with substantially the same nodes and edges, and do not infer a boundary from a folder name alone. Keep unchanged direct neighbours when they make the blast radius clear.
154
+
155
+ Set `defaultOpen: true` on the highest useful architecture view. Lower levels should normally stay collapsed. A data-flow view describes an ordered sequence, so keep it as a separate root instead of placing it inside the architecture hierarchy.
156
+
157
+ This compact fragment shows the shape. The selected ids refer to elements declared elsewhere in the document:
158
+
159
+ ```json
160
+ {
161
+ "views": [
162
+ {
163
+ "id": "checkout-context",
164
+ "title": "Checkout in its environment",
165
+ "lens": "architecture",
166
+ "defaultOpen": true,
167
+ "scope": {
168
+ "kind": "selection",
169
+ "nodes": ["shopper", "commerce-platform", "payment-provider", "fulfilment-system"],
170
+ "edges": ["shopper-to-commerce", "commerce-to-payment", "commerce-to-fulfilment"]
171
+ },
172
+ "children": [
173
+ {
174
+ "id": "checkout-containers",
175
+ "title": "Checkout containers",
176
+ "lens": "architecture",
177
+ "scope": {
178
+ "kind": "selection",
179
+ "nodes": ["storefront", "checkout-api", "orders-db", "payment-provider"],
180
+ "edges": ["storefront-to-checkout", "checkout-to-orders", "checkout-to-payment"]
181
+ },
182
+ "children": [
183
+ {
184
+ "id": "checkout-components",
185
+ "title": "Checkout API components",
186
+ "lens": "architecture",
187
+ "scope": {
188
+ "kind": "selection",
189
+ "nodes": ["checkout-route", "order-service", "payment-client"],
190
+ "edges": ["route-to-orders", "orders-to-payment-client"]
191
+ }
192
+ }
193
+ ]
194
+ }
195
+ ]
196
+ },
197
+ {
198
+ "id": "place-order-flow",
199
+ "title": "Placing an order",
200
+ "lens": "data-flow",
201
+ "scope": { "kind": "selection", "flows": ["place-order"] }
202
+ }
203
+ ]
204
+ }
205
+ ```
206
+
207
+ ## Layout
208
+
209
+ ```json
210
+ { "direction": "right", "laneOrder": ["api", "functions", "external"], "rank": { "send-broadcast-bulk": 2 } }
211
+ ```
212
+
213
+ Hints, not instructions: the renderer owns final placement, so a diagram stays deterministic and a stale hint cannot break it. Absolute coordinates are not expressible. Omitting `layout` entirely is normal.
214
+
215
+ ## File references
216
+
217
+ ```json
218
+ { "path": "functions/src/broadcast/sendBroadcastBulk.ts", "startLine": 1, "endLine": 142, "revision": "head" }
219
+ ```
220
+
221
+ Repository-relative POSIX paths: no leading `/`, no drive letter, no backslash, no `..` segment. Lines are 1-based, `endLine` requires `startLine` and may not precede it. `revision` defaults to `head`; use `base` on elements the change removes.
222
+
223
+ ## Length limits
224
+
225
+ Labels 120 characters, summaries 2000, chip values 32. They are display fields: a label that needs 120 characters is a label the diagram cannot draw.
226
+
227
+ ## Then validate
228
+
229
+ ```bash
230
+ npx @coldtea/pr-lens-cli validate .pr-lens/graph.json
231
+ ```
232
+
233
+ Every problem is reported at once, with a path into the document. Fix them all and run it again until it is clean.
@@ -0,0 +1,16 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "skillId": "pr-lens",
4
+ "channel": "vendored",
5
+ "version": "1.0.0",
6
+ "source": {
7
+ "repository": "https://github.com/coldteadotai/pr-lens",
8
+ "npm": {
9
+ "@coldtea/pr-lens-agent-skill": "0.1.5",
10
+ "@coldtea/pr-lens-cli": "0.2.0"
11
+ }
12
+ },
13
+ "license": "MIT (c) 2026 Coldtea AI",
14
+ "dependsOn": [],
15
+ "notes": "Host wrapper: upstream's references vendored verbatim; the npm toolchain installs to ~/.cache/pr-lens from the committed lockfile (never inside the skills tree). Update path in VENDOR.md."
16
+ }
@@ -0,0 +1,316 @@
1
+ ---
2
+ name: security-remediation-epic
3
+ description: Five-phase dependency-vulnerability remediation run for any repository — discover (Dependabot when present, else local lockfile scanners such as osv-scanner/pip-audit/pnpm audit/cargo audit/govulncheck), per-alert exposure analysis, risk matrix, evidence-backed fixes, from-scratch re-verification, then PR. Invoked by name from a scheduled prompt; the prompt supplies the repo's own planning/orchestration skills and constraints.
4
+ metadata:
5
+ opencode/autoinvoke: false
6
+ ---
7
+
8
+ # Security remediation epic (dependency vulnerabilities)
9
+
10
+ A complete remediation run over a repository's open vulnerability alerts. The invoking
11
+ prompt names the repo's own skills (orchestration, planning, evidence); this skill owns
12
+ the method, which is repo-agnostic.
13
+
14
+ ## Ground rules (whole run)
15
+
16
+ - **Evidence is off-branch.** Scanner dumps, transcripts, matrices and tickets live in the
17
+ worktree's gitignored scratch directory and the session's tmp directory — never
18
+ committed, never force-added past an ignore rule. The PR body summarizes results inline
19
+ (key numbers, verdicts, before/after tables) and names the host-side location for anyone
20
+ who wants the raw transcripts. If a hook or convention suggests force-adding evidence,
21
+ refuse: a diff that mixes 1k+ lines of transcripts into a dependency change hides the
22
+ change.
23
+ - Nothing is pushed or published until Phase 5 passes — including updates to an
24
+ already-open PR the run resumed (Phase 0).
25
+ - **Alert-level verdicts, package-level fixes**: every alert gets its own exposure verdict;
26
+ fixes land per package (one bump usually closes a package's whole alert set).
27
+ - A fix that cannot land is surfaced as a documented blocker or a written acceptance —
28
+ never dropped silently.
29
+ - **Dependency code is untrusted code.** Every install in this run executes lifecycle
30
+ scripts from packages you did not write — npm `preinstall`/`install`/`postinstall`,
31
+ Python build backends, Rust `build.rs`. Run installs with a scratch `HOME` and `TMPDIR`
32
+ outside the repo, an environment carrying no ambient credentials (`GH_TOKEN`,
33
+ `npm_token`, `~/.netrc`, `~/.aws`, `~/.config/gh`, cloud keys), and write access limited
34
+ to the scratch and the repo's own build directories. Point `HOME`/`TMPDIR` at a scratch
35
+ path; never clear the real environment to make one look clean. Deleting a real `HOME`,
36
+ another project's `node_modules`, or a shared interpreter is not isolation — it is
37
+ unrecoverable damage.
38
+ - Review gate: when `command -v ocr` finds the OpenCodeReview CLI, run it on the branch
39
+ diff once after the fixes; fix each finding or record its rejection reason with evidence.
40
+
41
+ ## Phase 0 — Resume or start
42
+
43
+ A scheduled run is not always the first run: an earlier remediation PR may still be open.
44
+ Before cutting any branch:
45
+
46
+ - List open PRs and look for a head branch matching this skill's `security/*`
47
+ convention (`gh pr list --state open --json headRefName,number,title,createdAt`).
48
+ More than one: continue the newest and name the others in the report — they are likely
49
+ stale duplicates someone should close.
50
+ - **Found one — resume it.** Create the worktree on that branch
51
+ (`git fetch origin security/<slug>` then `git worktree add … origin/security/<slug>`),
52
+ then merge the default branch into it: the PR's checks must never be the first place
53
+ the combination runs. A conflict of wording resolves by combining both truths; a
54
+ conflict over behaviour is a fork — stop and surface it, never pick a side silently.
55
+ - **None — start fresh** on a new `security/<short-slug>` branch from `origin/<default>`.
56
+
57
+ Phase 1 always computes its baseline from the working branch's lockfiles. An alert
58
+ source that reports the default branch (Dependabot) is a cross-check against that view:
59
+ an alert whose package the branch already carries at or above first-patched is
60
+ already-fixed — it closes when the PR merges — not rework. Local scanners over the
61
+ branch's own locks give this view directly, which is why they stay the instrument of
62
+ record even when Dependabot supplied the alerts.
63
+
64
+ ## Phase 1 — Discover
65
+
66
+ Find the repo's vulnerability source — Dependabot is one source, never the assumption:
67
+
68
+ - **GitHub with Dependabot enabled**: the alert record plus the inventory —
69
+ `gh api 'repos/{owner}/{repo}/dependabot/alerts?state=open&per_page=100' --paginate`
70
+ and `gh api repos/{owner}/{repo}/dependency-graph/sbom`.
71
+ - **No Dependabot, not on GitHub, or alerts stale**: the lockfiles are the inventory —
72
+ scan them locally. Any ecosystem: `osv-scanner` (reads uv.lock, pnpm-lock.yaml,
73
+ package-lock.json, Cargo.lock, go.mod, …). Per ecosystem: `pip-audit` over an export of
74
+ the Python lock, `pnpm audit` / `npm audit`, `cargo audit`, `govulncheck ./...`.
75
+ - **Both, when available**: Dependabot supplies the alert record (GHSA/CVE, vulnerable
76
+ ranges, first patched version); the local scanner is the before/after instrument Phase 4
77
+ reuses — scanner-of-record discovered with, scanner-of-record verified against.
78
+
79
+ **The scanner's inventory is the floor, not the ceiling.** Every scanner answers one
80
+ question: which *published* advisories match this lockfile. None of them answers whether
81
+ the lockfile is trustworthy — a package with no advisory at all, a typosquat one character
82
+ away from a popular name, a maintainer release taken over and republished, an install
83
+ script that fetches a payload. Keep every claim this run makes inside what the scanner
84
+ proves, and say so in the PR body: a clean scan means "no known advisory matches", never
85
+ "no known vulnerable package".
86
+
87
+ Record per alert: package, ecosystem, vulnerable range, first patched version, CVE/GHSA,
88
+ severity, manifest path, direct/transitive relationship, locked version (the lockfile
89
+ states it directly when there is no API). Roll alerts up to unique packages and compute
90
+ each package's highest required patched version (the fix target).
91
+
92
+ Done when: every alert is in a table, and every package has installed → target versions.
93
+
94
+ ## Phase 2 — Exposure analysis
95
+
96
+ Per package (verdicts applied to each of its alerts):
97
+
98
+ - Parent chain for transitives: `uv tree --invert --package X`, `pnpm why -r X`,
99
+ `npm ls X`, `cargo tree -i X`, `go mod why m` — whatever the ecosystem offers.
100
+ - Shipping scope: read the Dockerfiles and CI manifests to learn which images sync which
101
+ locks/extras; a package only present in dev tooling is a different exposure class from
102
+ one inside a deployed service.
103
+ - Call sites: grep the imports and the functions the CVEs touch.
104
+ - **Client–image skew**: when the same software exists both as a library dependency and as
105
+ a pinned deployed image in the repo (tracking server, worker, database), a client bump
106
+ alone can leave the vulnerable *server* running. Patch the image pin in the same change
107
+ or write why the skew is safe.
108
+
109
+ Verdicts: **Exploitable** (attacker-controlled input reaches the vulnerable code in a
110
+ shipped path), **Conditionally exploitable** (runs in a deployed image or behind an auth
111
+ boundary; needs a precondition), **Not reachable / tooling** (build-time, dev-only, or no
112
+ attacker input path), **Undetermined** (the repo does not settle reachability — the call
113
+ path runs through a vendored fork, a plugin host, a generated binding, or a runtime
114
+ configuration the repo does not own). Each verdict carries a one-paragraph justification
115
+ citing file paths and lines.
116
+
117
+ **A verdict is a hypothesis, and the agent that read the call path must not grade it.**
118
+ Before a *Not reachable* verdict is allowed to exclude an alert from the fix set, hand
119
+ that verdict to a **fresh reader whose only job is to disprove it**: show the
120
+ attacker-controlled input reaching the vulnerable code, or show the shipped path the
121
+ first reader missed. The fresh reader re-reads the cited lines itself and is not given
122
+ the first reader's conclusion as a premise — handing over a conclusion and asking for a
123
+ second opinion is how a wrong verdict survives two rounds.
124
+
125
+ - Disproof fails → the verdict stands, and the disproof attempt is recorded as its
126
+ justification.
127
+ - Disproof succeeds → the alert moves to *Exploitable* or *Conditionally exploitable*,
128
+ and the first justification is replaced, not appended to.
129
+
130
+ Exploitable and Conditionally exploitable verdicts are **not** re-graded. A wrong
131
+ "exploitable" costs work; a wrong "not reachable" ships the vulnerability, so the gate
132
+ belongs only on the verdict that can silently drop one.
133
+
134
+ **Undetermined carries no severity and is never an acceptance.** Name the exact missing
135
+ fact, the bounded check that would settle it, and who can run that check (deployment
136
+ config, a live service, the vendor). An Undetermined alert enters the PR body as an open
137
+ item with its blocker. It does not enter the risk matrix, and it does not satisfy the
138
+ "accepted below the line" rule — a question nobody answered is not a low-severity
139
+ finding.
140
+
141
+ **Cost bound.** Exposure analysis is the expensive phase and its scope is the number of
142
+ alerts, which the scanner sets and you do not. Count the alerts before analysing, work
143
+ them in severity order (Critical, High, Medium, then Low), and stop when the bound is
144
+ spent. Record every alert the run did not analyse — package, advisory, severity, and the
145
+ fact that it was not reached — and name that gap in the PR body and the run's summary. An
146
+ unreached alert is a gap you state, never one you drop; a scanner that keeps reporting it
147
+ next run is the signal that the bound was wrong.
148
+
149
+ Done when: every alert carries a verdict with evidence, and every *Not reachable* verdict
150
+ carries a recorded disproof attempt.
151
+
152
+ ## Phase 3 — Risk assessment
153
+
154
+ Risk matrix severity × exposure with every **decided** alert placed in it. Policy:
155
+ **every alert rated Medium or higher after exposure analysis must be fixed**; anything
156
+ accepted below that line needs written justification. *Undetermined* alerts are not
157
+ decided — they sit beside the matrix with their blocker, unresolved and unaccepted, and
158
+ they are not silently folded into "below the line".
159
+
160
+ Done when: every decided alert has an action — fix, mitigate, or accept — with rationale,
161
+ and every Undetermined alert is listed as open with its missing fact named.
162
+
163
+ ## Phase 4 — Fix, evidence-based only
164
+
165
+ Resolution preference, cheapest first:
166
+
167
+ 1. Natural lock resolution (`uv lock --upgrade-package X`, lockfile refresh) — no manifest
168
+ edits.
169
+ 2. Direct-pin bumps in manifests where the repo pins deterministically.
170
+ 3. Scoped, exactly-pinned overrides (`pnpm-workspace.yaml` overrides in pnpm ≥10,
171
+ `[tool.uv] override-dependencies`) — scoped to the dependent's subtree so they die with
172
+ its own fix; exact pins so a re-lock ships nothing unreviewed.
173
+
174
+ Before forcing a major-version override on a parent that declares an older line, audit the
175
+ older line's latest release — if it clears the advisory, the in-range floor wins; only a
176
+ verified-still-vulnerable older line justifies the major. Record the audit either way.
177
+
178
+ **A scoped override is a refusal — name who legitimately uses the refused range before
179
+ you recommend it.** The override tells every consumer in that subtree "you may not have
180
+ a newer version of this package". Account for them explicitly: the other packages in the
181
+ subtree, the workspace members that pin it directly, the plugins and extra groups that
182
+ share the lockfile. For each, state why the refused range is acceptable for it — it is
183
+ unaffected by the advisory, it never reaches the vulnerable code, it pins its own newer
184
+ copy. An override with no such accounting is not a scoped override; it is a
185
+ repository-wide downgrade wearing a scoped one's name. The proof that the refusal did not
186
+ take legitimate behaviour with it is the Phase 4 behaviour comparison below: the same
187
+ inputs through the old stack and the new stack must produce the same answers. That check
188
+ is what catches the case where one change closed the advisory and closed a working
189
+ feature in the same move.
190
+
191
+ A forced major can resolve cleanly and still break the consumer: the fixed line may
192
+ drop an API the consumer calls on a path the verify line never exercises. Gate every
193
+ cross-major pin on the consumer's own imports, in the pin's own stack: list the
194
+ symbols it calls into the overridden package (`grep -rn '<pkg>\.' node_modules/<consumer>/dist`,
195
+ `grep -rnE '(from|import) <pkg>' <consumer>/src`), assert each exists at the forced
196
+ version (`node -p "Object.keys(require('<pkg>'))"`,
197
+ `python -c "import <pkg> as m; assert hasattr(m, '<symbol>')"`); compiled stacks
198
+ (Rust, Go, Swift) surface the same break at build. Exercise each call site with one
199
+ live command shaped like the repo's real invocations — flags and pattern filters
200
+ included; when the stack cannot run on this host (iOS needs a Mac, GPU extras a GPU),
201
+ the existence check plus a compile where possible is the gate, and the report names
202
+ CI's first build of that surface as the tripwire. A missing symbol is a documented
203
+ blocker before the lock is touched.
204
+
205
+ Evidence per fix, captured verbatim to the off-branch bundle:
206
+
207
+ 1. **Before**: the vulnerability present in scanner output (the ecosystem's local audit
208
+ over an export of the lock: pip-audit, pnpm/npm audit, cargo audit, govulncheck).
209
+ 2. **After**: the same scanner, reporting no advisory for the package the fix targeted.
210
+ 3. **Regression**: the repo's own verify line (lint, tests, build) green, plus a behavior
211
+ comparison — the same inputs through the old stack and the new stack must produce the
212
+ same answers (identical outputs/verdicts is the strongest possible dep-bump proof).
213
+
214
+ Done when: the scanner reports no alert the fix set was supposed to close (or the gap
215
+ is a documented blocker) and regression passes. Alerts the run **accepted** or left
216
+ **Undetermined** are expected to still appear in the scan — that is the standing record
217
+ of why they were not fixed, not a failed fix.
218
+
219
+ ## Phase 5 — Orchestrator re-verification
220
+
221
+ Re-run from scratch, trusting nothing from Phase 4's environment:
222
+
223
+ - Fresh install from the new locks: delete and reinstall `node_modules`, rebuild the
224
+ Python env with the repo's canonical bootstrap (workspace-wide, not member-scoped) —
225
+ under the ground rule on dependency code: scratch `HOME`/`TMPDIR` outside the repo, no
226
+ ambient credentials in the environment, writes limited to the scratch and the repo's own
227
+ build directories.
228
+ - The full verify line; the app boots and one representative flow behaves as before.
229
+ Cross-major pins bring their Phase 4 consumer-exercise commands into this re-run.
230
+ - Both scanners re-run on the fresh state and report no alert the fix set was supposed
231
+ to close. Alerts the run accepted or left Undetermined are expected to still appear —
232
+ that is the standing record of why they were not fixed, and the next run's Phase 1 sees
233
+ them again. The scan is not "clean" when it is empty; it is clean when every remaining
234
+ report is one the run named.
235
+
236
+ Only after this passes: push. Resuming — push the existing branch; the open PR picks it
237
+ up, no new PR, and its body gains an incremental note (which alerts this round fixed
238
+ versus what the PR already carried). Fresh start — push the branch and open the PR
239
+ (label and format per the invoking prompt's repo conventions).
240
+
241
+ ## PR body
242
+
243
+ Summary; the risk matrix; a per-package table (alerts, severity split, version →, action
244
+ + rationale) with the full per-alert matrix named as host-side material; a flow-by-flow
245
+ human verification guide (what changed and why it matters, affected flow, exact manual
246
+ steps with expected result, pointer to the evidence); rollback notes; an honest "what this
247
+ does not prove" section (e.g. an alert source that re-scans on its own schedule —
248
+ Dependabot re-scans the default branch only, so its zero-alert confirmation lands
249
+ post-merge; a local scanner's clean run is the pre-merge truth; a clean scan means "no
250
+ known advisory matches", not "no known vulnerable package").
251
+
252
+ The body names every alert the run did not analyse (the cost bound's gap) and every
253
+ Undetermined alert (the missing fact and who can settle it), each as an open item —
254
+ neither list is optional, and neither is summarised away.
255
+
256
+ ## End of run — no human waits
257
+
258
+ The run's own work ends at the review bot, not at a human's merge decision.
259
+
260
+ ### Harness adapter: T3 Code (when `watch_pull_request` / `t3_thread_organize` are available)
261
+
262
+ - Watch the PR after it opens (`watch_pull_request`). On each wake, handle the bot's
263
+ existing comments first; small findings are fixed as **one batched commit per review
264
+ round** (verify line green before the push — each push spends one of the bot's review
265
+ turns), rejections are replied in their threads with evidence.
266
+ - **Termination — settle when the round is answered**: the bot's latest review carries no
267
+ unanswered finding (fixed or replied), required checks are green, no conflicts. Then
268
+ `unwatch_pull_request`, settle the thread (`t3_thread_organize`, action `settle`), and
269
+ close with a final report naming the PR, its state, and where the evidence lives. The
270
+ human merge decision needs no babysitter.
271
+ - **Blocked states end the run too, settled**: the bot's turn budget is exhausted, or a
272
+ finding is a genuine behaviour fork — settle with the blocker documented in the final
273
+ report instead of idling active. Never merge or close the PR yourself unless the
274
+ invoking prompt says so.
275
+
276
+ ### Harness fallback (non-T3 harnesses)
277
+
278
+ - Open or push the PR, verify CI checks, summarize findings and host-side evidence paths
279
+ in the final report, and hand back without polling.
280
+
281
+ ## Traps measured in real runs
282
+
283
+ - **A copied/cloned virtualenv keeps the source checkout's interpreter shebangs in
284
+ `bin/*` and its `.pth` files.** Script entry points (pytest, linters) then execute the
285
+ *source* checkout's interpreter and code while `python -c "import …"` looks perfectly
286
+ healthy. After any venv copy: rewrite both, then prove it with a script entry point, not
287
+ a `python -c` probe.
288
+ - **A member-scoped sync prunes sibling members' packages** in uv/pnpm workspaces (syncing
289
+ one member's extras uninstalls another member's deps). Sync at the workspace root or run
290
+ the full bootstrap before the final verify.
291
+ - **Local evidence stacks collide with tests that bind loopback ports.** If the verify
292
+ line fails exactly and only around port-binding tests, check what your own stack holds
293
+ before debugging the code; re-run those tests with the stack down.
294
+ - **Directory-only ignore patterns (`dir/`) do not match the bare name** passed as a file
295
+ path — probe a path inside the directory before concluding something isn't ignored.
296
+ - Pre-commit hooks that re-stage formatted files cannot re-stage force-added ignored
297
+ paths — one more reason evidence stays off-branch.
298
+ - **A green verify line can be vacuous: the change's own diff short-circuits the very
299
+ path it broke.** A dependency-lock diff puts every project into nx's affected set, so
300
+ `--exclude=<name>` matched by project name and never reached the glob compiler — the
301
+ one code path the forced minimatch 11 major broke (`makeRe` removed; nx calls it on
302
+ every name-miss). The remediation PR's own verification and its merge CI were
303
+ genuinely green, and the first content-scoped merge crashed main. When regression
304
+ proof rides on filter or pattern behavior, run both shapes: a pattern that hits by
305
+ name, and one that misses.
306
+ - **An agent told to isolate an environment will sometimes clear the real one.** "Isolate
307
+ the build" read as "delete the old `HOME`" has destroyed a user's tool config, installed
308
+ skills, SSH keys and a shared Python install — permanently, and with the transcript that
309
+ would have shown the command already gone. Isolate by pointing `HOME`/`TMPDIR` at a
310
+ scratch path and running under the ground rule above; never by removing the real
311
+ directories, and never as a way to "make the environment look clean".
312
+ - **A verdict nobody argued with is a verdict nobody checked.** The cheapest way to ship
313
+ a known CVE is to classify it as unreachable and move on — the scanner still reports
314
+ it, so the run looks busy, but the fix set never contains it. A "not reachable" call
315
+ that was never challenged is a claim, not a finding. The disproof pass in Phase 2 is
316
+ what separates the two, and it is the one step whose absence no later phase catches.
@@ -0,0 +1,33 @@
1
+ # Scheduling prompt — security remediation epic
2
+
3
+ Paste into T3 Code scheduling, filling `{owner}/{repo}`. The host skill
4
+ `security-remediation-epic` owns the method; this prompt carries the repo-specific
5
+ layer on top of it.
6
+
7
+ ---
8
+
9
+ # Task: Security remediation epic (dependency vulnerabilities) — {owner}/{repo}
10
+
11
+ ## Skills and workflow
12
+ - Use the `security-remediation-epic` host skill for the run's method (phases, exposure classes, evidence rules, traps) — follow it.
13
+ - Use the `orchestrator` and `ai-passport-scheme` repo skills for planning, delegation and PR format conventions — local mode, no GitHub issues created (tickets as local files in the gitignored scratch).
14
+ - Work in a new git worktree on a branch named `security/<short-slug>` (use `security/` where those skills would use `epic/`).
15
+ - Do NOT push or publish anything to GitHub until Phase 5 verification passes.
16
+ - Evidence is off-branch: scanner dumps, transcripts, matrices and tickets stay in the gitignored scratch and session tmp — never committed, never force-added. The PR body summarizes results inline and names the host-side location for raw material.
17
+ - Dependency code is untrusted code: every install runs lifecycle scripts from packages you did not write. Scratch `HOME`/`TMPDIR` outside the repo, no ambient credentials in the environment, writes limited to the scratch and the repo's build dirs. Point `HOME` at a scratch path; never clear the real environment to make one look clean.
18
+
19
+ ## Phases (mechanics per the skill)
20
+ 0. **Resume or start** — check for an open `security/*` PR first. If one exists: worktree on its branch, merge the default branch in, continue there (no new PR — later phases push to the same branch). Only start a fresh `security/<short-slug>` branch when none exists. Discovery is baselined against the working branch's locks, so alerts already fixed by the open PR are not reworked.
21
+ 1. **Discover** — from the repo's vulnerability source: Dependabot alerts + dependency-graph SBOM when on GitHub with Dependabot enabled; otherwise local lockfile scanners (osv-scanner, or pip-audit / pnpm audit / npm audit / cargo audit / govulncheck per ecosystem) — the lockfiles are the inventory. All severities collected, Critical/High triaged first. The scanner's inventory is the floor, not the ceiling: a clean scan means "no known advisory matches", never "no known vulnerable package".
22
+ 2. **Exposure analysis per alert** — direct/transitive + parent chain, runtime/build/dev scope, call-site reachability, attacker-controlled input paths; verdict (Exploitable / Conditionally exploitable / Not reachable / **Undetermined**) with file:line justification. Include the client–image skew check. **Every *Not reachable* verdict is handed to a fresh reader whose only job is to disprove it** — it re-reads the cited lines itself and is not given the first reader's conclusion as a premise; a failed disproof is recorded as the verdict's justification, a successful one re-classifies the alert. Exploitable/Conditionally exploitable verdicts are not re-graded. Undetermined carries no severity, is never an acceptance, and is listed as an open item with its missing fact. Bound the phase: count alerts, work Critical→High→Medium→Low, stop at the bound, and record every alert not analysed as a named gap.
23
+ 3. **Risk assessment** — severity × exposure matrix over the **decided** alerts; action per alert. Policy: every alert rated Medium or higher after exposure analysis MUST be fixed; anything accepted below that line needs written justification. Undetermined alerts sit beside the matrix as open, unresolved, unaccepted — never folded into "below the line".
24
+ 4. **Fix, evidence-based only** — before/after scanner output plus regression proof (repo verify line green; the same inputs through old and new stack give the same answers; the app boots and affected flows behave as before). No self-reported success. Blockers are surfaced, never hidden. **A scoped override is a refusal**: name who legitimately uses the refused version range (other packages in the subtree, workspace members pinning it directly, plugins and extra groups sharing the lockfile) and why the refusal is acceptable for each, before recommending it.
25
+ 5. **Final verification (orchestrator)** — independently re-run from scratch: fresh install from the new locks (isolated per the ground rule above), full build, tests, app startup, re-scan. The scan is clean when it reports no alert the fix set was supposed to close — accepted and Undetermined alerts are expected to still appear, and naming them is the point. Only after this passes, push — to the resumed PR's branch when continuing (no new PR, incremental note in its body), or branch + PR when the run started fresh.
26
+ 6. **End of run — no human waits** — per the skill's end-of-run rule: watch the PR, answer every bot-review round (one batched push per round, verify line green before pushing), and when the round is answered with required checks green, unwatch and **settle the thread** — the human merge decision is not waited on. Blocked states (bot turn budget exhausted, behaviour fork) also settle, with the blocker documented. Never merge or close the PR yourself.
27
+
28
+ ## PR body requirements
29
+ - Summary and the risk matrix.
30
+ - Table of alerts: fixed / mitigated / accepted, with rationale.
31
+ - **Every alert the run did not analyse** (the cost bound's gap) and **every Undetermined alert** (the missing fact and who can settle it), each listed as an open item — neither list is optional and neither is summarised away.
32
+ - Flow-by-flow human verification guide — for each changed package or impacted flow: what changed and why it matters; which user-facing or system flow is affected; exact manual steps with expected result; pointer to the automated evidence (inline key numbers; raw transcripts live on the run host).
33
+ - Rollback notes.