@qvac/harness 0.2.6 → 0.2.8

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 (174) hide show
  1. package/.claude/skills/gh-stack/SKILL.md +24 -24
  2. package/.claude/skills/gh-stack/references/commands.md +2 -2
  3. package/.claude/skills/js-house-style/SKILL.md +89 -68
  4. package/.claude/skills/kvcache/SKILL.md +7 -7
  5. package/.claude/skills/pr-create/SKILL.md +58 -15
  6. package/.claude/skills/pr-review/SKILL.md +307 -41
  7. package/CLAUDE.md +3 -0
  8. package/README.md +26 -4
  9. package/dist/harness.bundle +12 -10
  10. package/dist-lib/index.js +58 -58
  11. package/dist-lib/lib/audio-transcode-bare.js +2 -2
  12. package/dist-lib/lib/capabilities/completion.js +30 -30
  13. package/dist-lib/lib/capabilities/download.js +2 -2
  14. package/dist-lib/lib/capabilities/speech-text.js +1 -1
  15. package/dist-lib/lib/capabilities/tool-prompt-log.js +1 -1
  16. package/dist-lib/lib/capabilities/tool-selection.js +2 -2
  17. package/dist-lib/lib/capabilities/tool-turns.js +1 -1
  18. package/dist-lib/lib/capabilities/usage-breakdown.js +1 -1
  19. package/dist-lib/lib/capabilities/voice.js +3 -3
  20. package/dist-lib/lib/connect.js +11 -11
  21. package/dist-lib/lib/context-window.js +1 -1
  22. package/dist-lib/lib/docx/index.d.ts +5 -0
  23. package/dist-lib/lib/docx/index.js +49 -0
  24. package/dist-lib/lib/hardware/capability-probe.js +3 -3
  25. package/dist-lib/lib/hardware/gpu-probe-addon.js +2 -2
  26. package/dist-lib/lib/hardware/gpu-probe-entry.js +1 -1
  27. package/dist-lib/lib/helpers/markup-stream-filter.js +1 -1
  28. package/dist-lib/lib/helpers/run-outcome.js +1 -1
  29. package/dist-lib/lib/helpers/spawn-path.d.ts +1 -1
  30. package/dist-lib/lib/helpers/thinking.js +2 -2
  31. package/dist-lib/lib/helpers/tool-intent.js +1 -1
  32. package/dist-lib/lib/helpers/tool-label.js +3 -3
  33. package/dist-lib/lib/hooks/built-in/arg-repair.d.ts +1 -1
  34. package/dist-lib/lib/hooks/built-in/arg-repair.js +1 -1
  35. package/dist-lib/lib/hooks/built-in/egress.d.ts +1 -1
  36. package/dist-lib/lib/hooks/built-in/egress.js +2 -2
  37. package/dist-lib/lib/hooks/built-in/index.js +3 -3
  38. package/dist-lib/lib/hooks/built-in/skill-catalog.d.ts +1 -1
  39. package/dist-lib/lib/hooks/pipeline.js +4 -4
  40. package/dist-lib/lib/hooks/registry.js +1 -1
  41. package/dist-lib/lib/hooks/run.js +1 -1
  42. package/dist-lib/lib/models/model-catalog.js +4 -4
  43. package/dist-lib/lib/models/model-delete.js +1 -1
  44. package/dist-lib/lib/models/model-handle.js +1 -1
  45. package/dist-lib/lib/models/model-list.js +1 -1
  46. package/dist-lib/lib/models/model-pool.js +8 -8
  47. package/dist-lib/lib/models/model-source.js +1 -1
  48. package/dist-lib/lib/models/music-catalog.d.ts +1 -1
  49. package/dist-lib/lib/no-redirect-fetch-bare.js +3 -3
  50. package/dist-lib/lib/no-redirect-fetch-impl.js +1 -1
  51. package/dist-lib/lib/no-redirect-fetch-node.js +2 -2
  52. package/dist-lib/lib/resolution-detector.js +1 -1
  53. package/dist-lib/lib/sdk-loader.js +2 -2
  54. package/dist-lib/lib/sdk-storage.js +1 -1
  55. package/dist-lib/lib/serve.js +10 -10
  56. package/dist-lib/lib/spawn.js +3 -3
  57. package/dist-lib/lib/staging.js +1 -1
  58. package/dist-lib/lib/tools/catalog.js +1 -1
  59. package/dist-lib/lib/tools/create-documents.js +2 -2
  60. package/dist-lib/lib/tools/edit-documents.js +2 -2
  61. package/dist-lib/lib/tools/edit-image.js +2 -2
  62. package/dist-lib/lib/tools/exec/adapters/python/attachments.js +2 -2
  63. package/dist-lib/lib/tools/exec/adapters/python/create-effect.js +1 -1
  64. package/dist-lib/lib/tools/exec/adapters/python/loader.js +1 -1
  65. package/dist-lib/lib/tools/exec/adapters/python/memfs.js +2 -2
  66. package/dist-lib/lib/tools/exec/adapters/python/pyodide.js +8 -6
  67. package/dist-lib/lib/tools/exec/adapters/python/python-adapter.js +3 -3
  68. package/dist-lib/lib/tools/exec/adapters/python/run-session.js +5 -5
  69. package/dist-lib/lib/tools/exec/adapters/python/wheels.js +3 -2
  70. package/dist-lib/lib/tools/exec/adapters/python/worker/client.js +4 -4
  71. package/dist-lib/lib/tools/exec/adapters/python/worker/entry.js +4 -4
  72. package/dist-lib/lib/tools/exec/adapters/shell/shell-adapter.js +1 -1
  73. package/dist-lib/lib/tools/exec/obsidian/cli-process.js +2 -2
  74. package/dist-lib/lib/tools/exec/obsidian/cli.js +4 -4
  75. package/dist-lib/lib/tools/exec/obsidian/command.js +1 -1
  76. package/dist-lib/lib/tools/exec/obsidian/route.js +7 -7
  77. package/dist-lib/lib/tools/exec/obsidian/vault-create.js +2 -2
  78. package/dist-lib/lib/tools/exec/obsidian/vault-fs.js +6 -6
  79. package/dist-lib/lib/tools/exec/obsidian/vault-paths.js +2 -2
  80. package/dist-lib/lib/tools/exec/obsidian/vault-read.js +1 -1
  81. package/dist-lib/lib/tools/exec/obsidian/vault-write.js +2 -2
  82. package/dist-lib/lib/tools/exec/runner.js +1 -1
  83. package/dist-lib/lib/tools/exec.js +13 -13
  84. package/dist-lib/lib/tools/file-glob.js +3 -3
  85. package/dist-lib/lib/tools/fs/local.js +1 -1
  86. package/dist-lib/lib/tools/fs/remote.js +1 -1
  87. package/dist-lib/lib/tools/fs/walk.js +2 -2
  88. package/dist-lib/lib/tools/generate-image.js +4 -4
  89. package/dist-lib/lib/tools/generate-music.js +6 -6
  90. package/dist-lib/lib/tools/grep.js +6 -6
  91. package/dist-lib/lib/tools/http-request/truncate-response.js +1 -1
  92. package/dist-lib/lib/tools/http-request.js +9 -9
  93. package/dist-lib/lib/tools/mcp/utils.js +1 -1
  94. package/dist-lib/lib/tools/mcp-call.js +8 -8
  95. package/dist-lib/lib/tools/operations/builders.d.ts +1 -1
  96. package/dist-lib/lib/tools/operations/builders.js +1 -1
  97. package/dist-lib/lib/tools/operations/compile.js +1 -1
  98. package/dist-lib/lib/tools/operations/manifest.d.ts +16 -16
  99. package/dist-lib/lib/tools/operations/manifest.js +1 -1
  100. package/dist-lib/lib/tools/outbound-guard.js +1 -1
  101. package/dist-lib/lib/tools/rag-search.js +1 -1
  102. package/dist-lib/lib/tools/read-files.js +3 -3
  103. package/dist-lib/lib/tools/skill.js +8 -8
  104. package/dist-lib/lib/tools/skills/auth-resolver.js +2 -2
  105. package/dist-lib/lib/tools/skills/bin-check.js +1 -1
  106. package/dist-lib/lib/tools/skills/bundled-dir.js +2 -2
  107. package/dist-lib/lib/tools/skills/catalog.js +10 -10
  108. package/dist-lib/lib/tools/skills/cli-schema-check.js +1 -1
  109. package/dist-lib/lib/tools/skills/cli-schema-load.js +1 -1
  110. package/dist-lib/lib/tools/skills/cli-schema.js +4 -4
  111. package/dist-lib/lib/tools/skills/credential-check.js +3 -3
  112. package/dist-lib/lib/tools/skills/credential-grants.js +1 -1
  113. package/dist-lib/lib/tools/skills/credential-health.js +2 -2
  114. package/dist-lib/lib/tools/skills/frontmatter-parser.js +1 -1
  115. package/dist-lib/lib/tools/skills/index.js +5 -5
  116. package/dist-lib/lib/tools/skills/mention.js +1 -1
  117. package/dist-lib/lib/tools/skills/overlay-crud.js +1 -1
  118. package/dist-lib/lib/tools/skills/setup-routes.js +1 -1
  119. package/dist-lib/lib/tools/skills/skill-settings.js +1 -1
  120. package/dist-lib/lib/tools/skills/skill-state-constants.d.ts +8 -8
  121. package/dist-lib/lib/tools/skills/skill-state.js +9 -9
  122. package/dist-lib/lib/tools/toolsets.d.ts +1 -1
  123. package/dist-lib/lib/tools/url-guard.js +2 -2
  124. package/dist-lib/lib/tools/weather-lookup/place.d.ts +11 -0
  125. package/dist-lib/lib/tools/weather-lookup/place.js +152 -0
  126. package/dist-lib/lib/tools/weather-lookup/report.d.ts +37 -0
  127. package/dist-lib/lib/tools/weather-lookup/report.js +56 -0
  128. package/dist-lib/lib/tools/weather-lookup.d.ts +8 -0
  129. package/dist-lib/lib/tools/weather-lookup.js +110 -0
  130. package/dist-lib/lib/tools/web-fetch.js +10 -10
  131. package/dist-lib/lib/tools/web-search.js +2 -2
  132. package/dist-lib/lib/transport.js +1 -1
  133. package/dist-lib/lib/validating-lookup.js +1 -1
  134. package/dist-lib/lib/web-fetch/embedded-state.js +1 -1
  135. package/dist-lib/lib/web-fetch/extract.js +1 -1
  136. package/dist-lib/lib/web-fetch/images.js +1 -1
  137. package/dist-lib/lib/web-fetch/video.js +1 -1
  138. package/dist-lib/lib/web-search/engine-registry.js +7 -7
  139. package/dist-lib/lib/web-search/engines/aol.js +3 -3
  140. package/dist-lib/lib/web-search/engines/bing.js +4 -4
  141. package/dist-lib/lib/web-search/engines/brave.js +2 -2
  142. package/dist-lib/lib/web-search/engines/duckduckgo.js +3 -3
  143. package/dist-lib/lib/web-search/engines/google.js +4 -4
  144. package/dist-lib/lib/web-search/engines/wikipedia.js +2 -2
  145. package/dist-lib/lib/web-search/engines/yahoo.js +3 -3
  146. package/dist-lib/lib/web-search/fetch-html.js +1 -1
  147. package/dist-lib/lib/web-search/merge-results.js +1 -1
  148. package/dist-lib/lib/web-search/orchestrator.js +3 -3
  149. package/dist-lib/schema/baseline.js +1 -1
  150. package/dist-lib/schema/build.js +3 -3
  151. package/dist-lib/schema/release-tags.d.ts +2 -1
  152. package/dist-lib/schema/release-tags.js +9 -7
  153. package/docs/decisions/2026-05-29-kvcache-tool-turns.md +75 -0
  154. package/docs/decisions/2026-06-02-kvcache-tool-turns-reenabled.md +127 -0
  155. package/docs/decisions/2026-06-23-android-cpu-llm-defaults.md +126 -0
  156. package/docs/decisions/2026-07-29-assistant-owned-storage-layout.md +88 -0
  157. package/docs/decisions/2026-08-04-sidecar-orphan-reaping.md +79 -0
  158. package/docs/decisions/2026-08-11-pyodide-worker-thread.md +68 -0
  159. package/docs/decisions/2026-08-17-harness-hook-pipeline.md +84 -0
  160. package/docs/decisions/2026-08-17-harness-outbound-egress-guard.md +176 -0
  161. package/docs/decisions/2026-08-20-chat-prompt-prefix-is-stable.md +95 -0
  162. package/docs/decisions/2026-08-20-kvcache-static-placement.md +109 -0
  163. package/docs/decisions/2026-08-21-vendored-python-wheels.md +85 -0
  164. package/docs/decisions/2026-08-26-exec-is-not-gated-by-skills.md +64 -0
  165. package/docs/decisions/2026-08-27-writable-skills-overlay.md +56 -0
  166. package/docs/decisions/2026-09-01-skill-operation-manifests.md +53 -0
  167. package/docs/decisions/2026-09-01-usage-breakdown-is-measured.md +78 -0
  168. package/docs/decisions/2026-09-03-usage-breakdown-reported-by-the-harness.md +136 -0
  169. package/docs/decisions/2026-09-10-skill-wording-is-measured-offline.md +63 -0
  170. package/docs/decisions/2026-09-16-a-lookup-reports-the-place-it-resolved.md +70 -0
  171. package/docs/decisions/INDEX.md +40 -0
  172. package/docs/decisions/TEMPLATE.md +32 -0
  173. package/package.json +21 -4
  174. package/worker/harness-sidecar.mjs +2 -0
@@ -37,17 +37,17 @@ build chore ci docs style refactor perf test fix feat
37
37
  It is the line someone reads to decide whether to upgrade, so it claims real
38
38
  breakage in something already published.
39
39
 
40
- | The change | Type |
41
- | --- | --- |
42
- | Breaks a consumer on a published version | `fix` |
43
- | Repairs code that has never shipped (same release cycle) | `chore` |
40
+ | The change | Type |
41
+ | ----------------------------------------------------------- | -------------------------------------------------- |
42
+ | Breaks a consumer on a published version | `fix` |
43
+ | Repairs code that has never shipped (same release cycle) | `chore` |
44
44
  | Repairs the build, the bundle, or what lands in the tarball | `build` or `fix` if a published artifact was wrong |
45
- | Repairs CI, a workflow, an action pin | `ci` |
46
- | Repairs or adds a test | `test` |
47
- | Repairs a lint/type error | `chore` |
48
- | Pure move or rename, no behaviour change | `refactor` |
49
- | New capability, new export, new flag | `feat` |
50
- | README, comments, docs | `docs` |
45
+ | Repairs CI, a workflow, an action pin | `ci` |
46
+ | Repairs or adds a test | `test` |
47
+ | Repairs a lint/type error | `chore` |
48
+ | Pure move or rename, no behaviour change | `refactor` |
49
+ | New capability, new export, new flag | `feat` |
50
+ | README, comments, docs | `docs` |
51
51
 
52
52
  When a repair is on unreleased code, check the last release tag: if the bug was
53
53
  never in a published version, it is `chore`, not `fix`.
@@ -61,6 +61,45 @@ Optional, and taken from what the diff actually touches — `lib`, `worker`, `sc
61
61
  A scope that restates the type (`fix(fix)`) or names the whole repo adds
62
62
  nothing; leave it off.
63
63
 
64
+ ## Decision records
65
+
66
+ `docs/decisions/` holds the durable, non-obvious choices — why a boundary is
67
+ where it is, why an approach was rejected. They are reference for a future
68
+ reader, **not rules, and not to be loaded by default**.
69
+
70
+ Add one when this PR settles something a later reader would otherwise have to
71
+ reverse-engineer from the diff: a runtime or storage boundary, a wire-format or
72
+ schema choice, a build or publish constraint, a rejected alternative that will
73
+ look obvious later. Do not add one for a bug fix, a rename, or anything the code
74
+ already says plainly.
75
+
76
+ Copy `docs/decisions/TEMPLATE.md`, give it a `status`, list it once in
77
+ `INDEX.md`, and name it in the PR's Decisions section. `node
78
+ scripts/docs-audit.cjs` checks all of that, and CI runs it.
79
+
80
+ An **active** record may cite only paths that exist here; a path in another
81
+ repository is written `@qvac/harness → lib/x.ts` so the audit treats it as
82
+ context rather than a local file. A superseded record is exempt — it describes
83
+ how things used to be.
84
+
85
+ ### One PR, one type
86
+
87
+ The commits carry conventional-commit types, so the mix of types _is_ the scope
88
+ statement. `feat:`, `fix:` and `chore:` on one branch is not a well-rounded
89
+ change, it is three changes sharing a branch, and a reviewer has to hold all
90
+ three while judging any one of them.
91
+
92
+ List them before writing the body:
93
+
94
+ ```bash
95
+ git log --format='%s' main..HEAD | grep -oE '^[a-z]+' | sort -u
96
+ ```
97
+
98
+ - **One type** is the PR's type.
99
+ - **A dominant type plus its own tests or docs** (`feat` + `test`, `fix` +
100
+ `docs`) is fine; the dominant one wins.
101
+ - **Unrelated types** means split the PR, or stack it.
102
+
64
103
  ## Small PRs, stacked
65
104
 
66
105
  A PR is read by a human, so it has to fit in one head. Default to one concern.
@@ -71,7 +110,7 @@ stack them, so each step is reviewable alone and lands in order.
71
110
  - **Refactor commits never live inside a non-refactor branch.** A `feat/` branch
72
111
  that also reshuffles unrelated code is two PRs. Behaviour changes and pure
73
112
  moves are reviewed differently, and mixing them hides both.
74
- - A pure rename or move lands *before* the change that depends on it, as its own
113
+ - A pure rename or move lands _before_ the change that depends on it, as its own
75
114
  commit or its own PR in the stack.
76
115
 
77
116
  Branch names must never contain `codex`, `cursor`, or `claude` (case
@@ -79,8 +118,10 @@ insensitive). Use a neutral name before committing or pushing.
79
118
 
80
119
  ## Body
81
120
 
82
- No template is enforced. Use these four headings and drop any that would be
83
- empty — an absent section says more than a section saying "n/a".
121
+ `.github/pull_request_template.md` pre-fills the headings. Keep its shape, fill
122
+ what applies, and delete the sections that would be empty — an absent section
123
+ says more than one saying "n/a". The template's own order is Why, What, Testing,
124
+ Decisions; the expanded form below is what each should contain.
84
125
 
85
126
  ```markdown
86
127
  ## What
@@ -111,8 +152,10 @@ this is the only warning they get.
111
152
 
112
153
  1. Check the branch is not `main` and the name is neutral.
113
154
  2. `git log --oneline main..HEAD` — every commit is a conventional commit, and
114
- each one is a change you would defend on its own.
115
- 3. ``bun run lint`` and ``bun run test` (node, bare and addon lanes)` pass locally. CI runs the same lanes; a
155
+ each one is a change you would defend on its own. A trail of `wip`,
156
+ `fixup` or `address review` commits is not history; reshape it before
157
+ opening.
158
+ 3. `bun run lint` and ``bun run test` (node, bare and addon lanes)` pass locally. CI runs the same lanes; a
116
159
  red PR wastes a reviewer's round trip.
117
160
  4. Rebase on `main` rather than merging it in. A merge commit in the branch
118
161
  makes the diff unreadable.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pr-review
3
- description: Deep-dive review of a pull request in @qvac/harness, or of local uncommitted/branch changes when invoked with `local`. Checks CI, the commit type and title, code quality against the house style, contract and API mismatches, and missing tests. In PR mode it creates PENDING inline comments only after the user confirms them, and never submits the review event. In local mode it prints findings in chat and posts nothing. Use when reviewing a PR, given a PR link, or asked to review the working tree or current branch.
3
+ description: Deep-dive review of a pull request in @qvac/harness, or of local uncommitted/branch changes when invoked with `local`. Checks CI and the base branch, the commit type and title, correctness and state/derived-data bugs, contract and API mismatches, security, code quality against the house style, and missing tests. In PR mode it creates PENDING inline comments only after the user confirms them, and never submits the review event. In local mode it prints findings in chat and posts nothing. Use when reviewing a PR, given a PR link, or asked to review the working tree or current branch.
4
4
  ---
5
5
 
6
6
  # PR review
@@ -15,20 +15,44 @@ Reviews changes in `@qvac/harness`. Two modes.
15
15
  - **Local mode** (`local`, or "review my changes") — the overview in chat only.
16
16
  Posts nothing, anywhere.
17
17
 
18
+ ## Reviewing is read-only
19
+
20
+ This skill never writes to the working tree. Against the user's repo these are
21
+ forbidden, whatever the reason:
22
+
23
+ - `git switch`, `git checkout`, `git reset`, `git restore`, `git clean`
24
+ - `git stash`, in any form
25
+ - `git pull`, `git merge`, `git rebase`, `git cherry-pick`
26
+ - `gh pr checkout`
27
+ - any edit to a file
28
+
29
+ Local mode reads the diff with `git diff`, `git status` and `git ls-files`, and
30
+ nothing else. If the tree is dirty in a way that makes the diff hard to read, say
31
+ so and let the user decide; never tidy it yourself. A review that loses
32
+ uncommitted work is worse than no review.
33
+
34
+ PR mode needs no checkout at all: `gh pr diff` gives the patch, and
35
+ `gh api repos/{owner}/{repo}/contents/{path}?ref={sha}` gives any file at the PR
36
+ head.
37
+
18
38
  ## Gather
19
39
 
20
40
  PR mode:
21
41
 
22
42
  ```bash
23
43
  gh pr view <num> --repo tetherto/qvac-harness \
24
- --json title,body,author,headRefName,headRefOid,baseRefName,files,additions,deletions,state,isDraft,mergeable
44
+ --json title,body,author,headRefName,headRefOid,baseRefName,files,additions,deletions,state,isDraft,mergeable,statusCheckRollup \
45
+ > /tmp/pr-<num>.json
25
46
  gh pr diff <num> --repo tetherto/qvac-harness --patch > /tmp/pr-<num>.patch
26
47
  ```
27
48
 
28
- Read the patch from the file with Read/Grep rather than re-running `gh` — it is
29
- the same bytes every time and the file is greppable.
49
+ Two calls, then read both files with Read/Grep rather than re-running `gh` — it
50
+ is the same bytes every time and the files are greppable. `statusCheckRollup`
51
+ already carries every check, so **do not run `gh pr checks`**; it buys nothing
52
+ the JSON does not have.
30
53
 
31
- Local mode:
54
+ Local mode. The default scope is everything uncommitted — staged, unstaged and
55
+ untracked:
32
56
 
33
57
  ```bash
34
58
  git diff --staged > /tmp/local-staged.patch
@@ -37,8 +61,17 @@ git status --porcelain=v1
37
61
  git ls-files --others --exclude-standard # untracked, easy to miss
38
62
  ```
39
63
 
40
- For a branch rather than a working tree: `git diff main...HEAD` (three dots —
41
- the merge base, not the tip).
64
+ Scope overrides, when the user asks for one: `--staged` is `git diff --staged`
65
+ alone, `--unstaged` is `git diff` plus untracked, and `--branch [<base>]` is
66
+ `git diff <base>...HEAD` (three dots — the merge base, not the tip), with
67
+ `<base>` defaulting to `main`.
68
+
69
+ Untracked files are reviewed as wholly new content: read them from the working
70
+ tree, they appear in no patch.
71
+
72
+ **If the requested scope is empty, say so and stop.** An empty `--staged` is
73
+ not an invitation to review something else, and it is certainly not an
74
+ invitation to invent findings.
42
75
 
43
76
  ## CI
44
77
 
@@ -48,19 +81,21 @@ single `Lint & Tests` job. `publish.yml` runs on release, not on PRs.
48
81
  Its steps are each a separate way to fail, and the last three catch what a
49
82
  local `bun run test` does not:
50
83
 
51
- | Step | Command | Fails when |
52
- | --- | --- | --- |
53
- | Lint | `bun run lint` | prettier, lunte or `tsc --noEmit` |
54
- | Schema is regenerated | `bun run build:schema` | `spec/` is dirty after codegen — someone hand-edited it, or forgot to commit the regeneration |
55
- | Tests | `bun run test` | the node, bare and addon lanes |
56
- | Library surface compiles | `bun run build:lib` | the compiled export surface breaks |
57
- | Sidecar bundle builds | `bun run build:bundle` | the stowed bundle no longer assembles — a new bare import, or a missing addon external |
84
+ | Step | Command | Fails when |
85
+ | ------------------------ | ---------------------- | --------------------------------------------------------------------------------------------- |
86
+ | Lint | `bun run lint` | prettier, lunte or `tsc --noEmit` |
87
+ | Schema is regenerated | `bun run build:schema` | `spec/` is dirty after codegen — someone hand-edited it, or forgot to commit the regeneration |
88
+ | Tests | `bun run test` | the node, bare and addon lanes |
89
+ | Library surface compiles | `bun run build:lib` | the compiled export surface breaks |
90
+ | Sidecar bundle builds | `bun run build:bundle` | the stowed bundle no longer assembles — a new bare import, or a missing addon external |
58
91
 
59
92
  A PR that touches `schema/` and leaves `spec/` stale is the most common red
60
93
  here, and it looks nothing like a test failure.
61
94
 
95
+ Read the result from `statusCheckRollup` in `/tmp/pr-<num>.json`, and pull logs
96
+ only for a job that actually failed:
97
+
62
98
  ```bash
63
- gh pr checks <num> --repo tetherto/qvac-harness
64
99
  gh run view --repo tetherto/qvac-harness --log-failed --job <id> > /tmp/pr-<num>-<id>.log
65
100
  ```
66
101
 
@@ -68,6 +103,18 @@ A red `Integrate` is a blocking finding on its own. Read the failing job's log
68
103
  before writing a single line of review — half of what looks like a design
69
104
  problem is a lint rule.
70
105
 
106
+ ### Base branch
107
+
108
+ `baseRefName` is in the JSON you already fetched. Per CLAUDE.md a PR targets
109
+ `main`; the one exception is a stacked PR, which branches from the PR below it
110
+ and targets that branch.
111
+
112
+ So a base other than `main` is only a finding when the PR is **not** part of a
113
+ stack — check whether the base branch is itself an open PR before raising it.
114
+ If it is, the stack is correct and there is nothing to say. If it is not, that
115
+ is a `[P2]`: the diff will contain the base branch's commits and the PR cannot
116
+ merge as it stands.
117
+
71
118
  ## What to check, in order
72
119
 
73
120
  Stop at the first tier that produces findings worth the author's time; a review
@@ -78,7 +125,38 @@ end to end, including the error path. Look for: a promise not awaited, a
78
125
  listener never removed, a resource opened on one path and closed on another, an
79
126
  error swallowed into a default.
80
127
 
81
- **2. Contract and API.** This is a published package, so an exported signature
128
+ A **regression** belongs here too: a change that reads as additive but alters
129
+ what existing callers get — a signature widened, a default flipped, a branch
130
+ removed, a return value that is semantically different at the same type.
131
+
132
+ **2. State and derived data.** The class of bug a linter cannot see and a diff
133
+ skim misses. Walk any new stateful or arithmetic code against these four.
134
+
135
+ - **Two sources of truth.** The same value in two fields, or the same
136
+ expression computed twice, in one payload. Before writing the comment, read
137
+ the type declaration **and** the consumer: if the fields have distinct
138
+ documented meanings (per-item vs aggregate, raw vs normalised) and a reader
139
+ prefers one, this is a value written to the wrong channel — a contract
140
+ violation — not duplication. Say that, and cite the contract. Only call it
141
+ duplication when nothing distinguishes the fields. The two look identical in
142
+ a diff and have opposite fixes: one keeps both fields and moves a value, the
143
+ other deletes a field. Backwards, and you send the author to delete a channel
144
+ something depends on. `[P2]` either way.
145
+ - **Incremental accumulation.** A running total or offset advanced inside a
146
+ loop, where computing the whole table once would be correct by construction.
147
+ `[P2]` when a later edit could desynchronise it — and the fix shrinks the
148
+ code.
149
+ - **Closure over mutated state.** A callback capturing a variable a later step
150
+ reassigns, especially across an `await`. `[P1]` if a late or reordered
151
+ invocation yields a wrong value; say so plainly, because it will not
152
+ reproduce locally.
153
+ - **Laundered values.** `?? 0`, `|| 0`, `Math.max(x, 0)` turning an impossible
154
+ input into a plausible number instead of letting it fail. `[P2]` unless the
155
+ clamp buys a stated presentational guarantee. Watch an optional `uint` in
156
+ `schema/`: it decodes to `0`, not `null`, so `??` never sees the absent
157
+ value.
158
+
159
+ **3. Contract and API.** This is a published package, so an exported signature
82
160
  is a promise to a consumer.
83
161
 
84
162
  - Anything added to or changed in the export map, `index.ts`, `types/`, or
@@ -88,61 +166,249 @@ is a promise to a consumer.
88
166
  - Does the change match its own type declarations, and do callers in this repo
89
167
  still typecheck?
90
168
 
91
- **3. House style.** Run the changed files against **js-house-style** — that
92
- document, not your own taste. Layering, composition on primitives, module size
93
- and shape, no defensive programming, comment density.
169
+ **4. House style.** Load **js-house-style** and run the changed files against
170
+ it — that document, not your own taste or your memory of it. Layering,
171
+ composition on primitives, module size and shape, no defensive programming,
172
+ comment density. A style point the document does not back is not a finding.
94
173
 
95
- **4. Tests.** A behaviour change with no test is a finding. Name the missing
174
+ **5. Tests.** A behaviour change with no test is a finding. Name the missing
96
175
  case rather than asking for "more tests": the tests live under `test/`, run on
97
176
  both the node and bare lanes, and a fix without a regression guard will come
98
177
  back.
99
178
 
100
- **5. Commit type and title.** Per **pr-create**: is this really a `fix` (a
179
+ **6. Commit type and title.** Per **pr-create**: is this really a `fix` (a
101
180
  defect a consumer of a released version could hit), or is it `chore` on code
102
181
  that never shipped? Is the title imperative and specific? Does the branch name
103
182
  avoid `codex` / `cursor` / `claude`?
104
183
 
105
- **6. Scope.** Does the PR do one thing? A behaviour change mixed with an
184
+ **7. Scope.** Does the PR do one thing? A behaviour change mixed with an
106
185
  unrelated rename is two PRs — say so, and say which commit to split out.
107
186
 
187
+ **8. Security.** Not a sweep of the file — only what this diff introduces. An
188
+ API key, token or secret in code, a log line or an error message; a tool result,
189
+ a fetched page or a model completion treated as an instruction rather than as
190
+ data; a path or command assembled from something the model produced; unsafe
191
+ deserialization of an hrpc payload; a new dependency pulled in for something
192
+ small.
193
+
194
+ This package runs untrusted content by design — web fetches, Python in Pyodide,
195
+ MCP servers, the filesystem tool — so the question is never "could input be
196
+ hostile" but "what does this change let hostile input reach". Where it matters,
197
+ `[P1]`.
198
+
199
+ **9. Decision records.** Only when the diff **contradicts** a record in
200
+ `docs/decisions/` that you have actually read — then the record is updated or
201
+ superseded in the same PR rather than left to rot, and that is a `[P2]`.
202
+
203
+ A missing record is not a finding. Do not open `docs/decisions/INDEX.md`
204
+ looking for something to say, do not ask for an ADR because a change "feels
205
+ architectural", and never make "no decision record" the only thing a review
206
+ found. If you genuinely think a lasting choice went unrecorded, say it once in
207
+ the chat overview as a question, never inline.
208
+
209
+ ### Do not over-engineer the review
210
+
211
+ The most damaging thing a review can do is talk a good PR into a worse one. AI
212
+ review skews defensive: a guard here, an abstraction there, a layer to absorb a
213
+ hypothetical, each one permanent debt bolted to a problem that never happened.
214
+ That runs directly against the house style, which does not program defensively.
215
+
216
+ It compounds. Successive reviews each add a layer against a different
217
+ speculative case, one review's fix undoes another's, and the code ends up in a
218
+ corner nobody chose.
219
+
220
+ - **Only raise what is wrong now**, or has a concrete path to being wrong.
221
+ "Someone could later..." is not a finding.
222
+ - **Never propose a guard, wrapper, fallback or abstraction** whose only job is
223
+ to make a hypothetical safe. Let caller bugs crash; that is the contract.
224
+ - **Prefer the fix that deletes code.** If your suggestion makes the diff
225
+ bigger, be sure it earns it.
226
+ - **Simplification is a valid finding; speculative hardening is not.**
227
+ - When you cannot tell whether something is real, ask instead of requesting a
228
+ change, and be willing to land zero findings.
229
+
108
230
  ## Write the findings
109
231
 
110
232
  Each finding: the file and line, what breaks, and the concrete scenario that
111
233
  breaks it. No finding without a failure mode you can state.
112
234
 
113
- Drop anything you cannot defend as changing the code, the reviewer's decision,
114
- or a consumer's experience. Style opinions the house style does not back are
115
- noise. Say so plainly when the diff is clean — "no blocking findings" is a
116
- complete review.
235
+ Lead with the findings, ordered by severity.
236
+
237
+ ### Only raise what is worth the author's time
238
+
239
+ A review is not required to produce findings. **"Nothing to flag — the diff is
240
+ clean" is a complete, successful review**, and a good PR reviewed honestly is
241
+ the expected outcome most of the time. Never go hunting for something to say
242
+ because the output looks empty; an invented finding costs the author more than
243
+ a silent review ever could.
244
+
245
+ Every finding passes this bar before it is written down:
246
+
247
+ - You can name **what breaks**, and the concrete path that reaches it.
248
+ - Acting on it **changes the code, the reviewer's decision, or a consumer's
249
+ experience**.
250
+ - It is backed by the house style or a real contract, not your taste.
251
+
252
+ Drop everything else. Not "mention it as a `[P3]`" — **drop it**. A finding you
253
+ cannot defend at `[P2]` is not thereby a `[P3]`; it is noise wearing a smaller
254
+ tag. `[P3]` is for a real, small, correct observation, not a holding pen for
255
+ weak `[P1]`/`[P2]`s.
256
+
257
+ The failure mode this repo has actually seen: a clean PR comes back with four
258
+ `[P3]`s about naming, a speculative race nobody can reach, and a request for a
259
+ decision record. That review is worse than no review — it trains the author to
260
+ skim the next one, and the real finding gets skimmed with it.
261
+
262
+ ### Severity tags
263
+
264
+ Tag every finding `[P1]`, `[P2]` or `[P3]` **in the chat overview**, using the
265
+ tag rather than a word, so two reviews of the same repo rank things the same
266
+ way. The tag never appears on the PR — see "Comment style".
267
+
268
+ - `[P1]` — almost-certain bug, data corruption, security issue, CI breaker, or a
269
+ break of behaviour a consumer relies on. In the overview, and **proposed inline
270
+ by default**.
271
+ - `[P2]` — likely bug, non-obvious caveat, contract or API mismatch, subtle
272
+ behaviour change, missing test on a risky path. In the overview, and **proposed
273
+ inline by default**.
274
+ - `[P3]` — minor: a stale comment or doc, an ergonomic improvement, an optional
275
+ cleanup. In the overview when material, and **not proposed inline** unless the
276
+ user asks for them.
277
+
278
+ **Never silently put a `[P3]` in the inline payload.** A review that posts ten
279
+ nits inline teaches the author to skim the next one.
280
+
281
+ **Severity is what the code does today, not what it might do.** A finding whose
282
+ only support is a scenario nobody has hit is not a `[P2]`: either find the path
283
+ that reaches it, or drop it — do not park it at `[P3]` instead. Zero findings is
284
+ a legitimate result.
285
+
286
+ If the user says this is a re-review, say explicitly which earlier concerns are
287
+ resolved and which still stand.
288
+
289
+ ### The overview
117
290
 
118
- Distinguish clearly:
291
+ The user's checkout is usually on a different branch or commit than the PR, so
292
+ a bare line number is worth nothing to them. Every `[P1]` and `[P2]` in the
293
+ overview therefore carries two things: a **3–8 line excerpt read at the head
294
+ SHA**, and a **link to that line on the PR**.
119
295
 
120
- - **Blocking** — wrong behaviour, a broken contract, a missing test for a fix.
121
- - **Non-blocking** — a simplification, a naming improvement, a follow-up.
122
- - **Question** — you could not tell from the diff, and the author can.
296
+ The excerpt comes from
297
+ `gh api -H "Accept: application/vnd.github.raw" repos/tetherto/qvac-harness/contents/<path>?ref=<headRefOid>`,
298
+ never from the local tree. The link is the file-diff anchor:
299
+
300
+ `https://github.com/tetherto/qvac-harness/pull/<num>/files#diff-<sha256(path)>R<line>`
301
+
302
+ ```bash
303
+ printf '%s' 'lib/chat/compact.js' | shasum -a 256 | awk '{print $1}'
304
+ ```
305
+
306
+ If the anchor will not compute, fall back to
307
+ `https://github.com/tetherto/qvac-harness/blob/<headRefOid>/<path>#L<line>`.
308
+
309
+ ````markdown
310
+ ## PR #<num> — review overview
311
+
312
+ <one line: what this PR does>
313
+
314
+ ### CI / base
315
+
316
+ <one line; omit entirely when both are clean>
317
+
318
+ ### Findings
319
+
320
+ - **[P1]** <short title> — [`<path>:<line>`](link)
321
+
322
+ <one sentence, plus the repro when there is one>
323
+
324
+ ```js
325
+ <3-8 line excerpt at the head SHA>
326
+ ```
327
+
328
+ - **[P3]** <short title> — [`<path>:<line>`](link) — <one sentence, no excerpt>
329
+
330
+ ### Re-review delta
331
+
332
+ <only when the user said this is a re-review>
333
+
334
+ - Resolved: <…>
335
+ - Still open: <…>
336
+ ````
337
+
338
+ One sentence per finding here; the inline comment carries the reasoning. A
339
+ clean review is this same block with `Findings` reading "nothing to flag".
340
+
341
+ Local mode uses the same shape, headed `## Local review — <scope>`, with plain
342
+ `path:line` instead of links and the excerpt read from the working tree.
343
+
344
+ ## Comment style
345
+
346
+ Write like a colleague leaving a note, not a static analyser filing a report.
347
+ If a human reviewer would not say it out loud, do not write it.
348
+
349
+ - **Brief.** A few lines, one point per comment. If it takes three paragraphs
350
+ to justify, it probably is not a finding.
351
+ - **Ask, don't lecture.** "Can this reuse the existing helper?" beats a
352
+ paragraph on why the new one duplicates knowledge the store already owns.
353
+ - **Link what you refer to.** An existing function, type or rule you want
354
+ reused gets a line link — `[name](<url>#L120)`. A reference the author has to
355
+ hunt for is one they skip.
356
+ - **Show the change in code.** A short before/after, or a `suggestion` block
357
+ whenever the fix is mechanical enough to apply as-is.
358
+ - **Never put a severity marker in a comment body.** No `[P1]`/`[P2]`/`[P3]`,
359
+ no "blocker", no "nit:". Severity is how _you_ decided what to raise; it
360
+ lives in the chat overview and nowhere else. On the PR it reads as grading
361
+ the author and it ages badly once the code moves. If something is minor, say
362
+ it in plain words — "not urgent", "while you're in there".
363
+ - One concrete repro line for a `[P1]`/`[P2]` when one exists. Not a test plan.
364
+ - No praise padding, no "LGTM but…", no restating what the diff does.
365
+ - **Sign off every comment with 🤖 on its own last line**, so it is
366
+ unmistakable that the review came from an AI. Every inline comment, no
367
+ exceptions — the emoji alone, nothing else on the line.
123
368
 
124
369
  ## Posting (PR mode only)
125
370
 
126
- 1. Print every proposed comment in chat first: file, line, body.
371
+ 1. Print every proposed comment in chat first, as it will be posted: file,
372
+ line, then the verbatim body. Carry the severity in the chat line **outside**
373
+ the body. The default set is the `[P1]` and `[P2]` findings; name any `[P3]`
374
+ you are holding back so the user can pull it in. If there is nothing at
375
+ `[P1]`/`[P2]`, say so and stop — never assemble a payload out of `[P3]`s to
376
+ have something to post.
127
377
  2. Ask the user to confirm the exact set. Wait for a clear yes.
128
- 3. Create the review as **PENDING**, with no event:
378
+ 3. Write `/tmp/pr-<num>-review.json` from the confirmed set **only**. If the
379
+ confirmed set is empty, stop — never post an empty review.
380
+ 4. Pre-flight, before the POST:
381
+ - The comment count matches the confirmed set **exactly**. If it does not,
382
+ stop and reconcile; do not post the larger set and mention it after.
383
+ - Every `line` is a **post-PR line** — the `+` side of the patch, as
384
+ numbered in the file at the head SHA. A line the patch does not touch is a
385
+ `422` that rejects the whole review, so anchor to a touched line or move
386
+ the point to the chat overview.
387
+ - Every body ends with a `🤖` line, and none contains `[P1]`, `[P2]`, `[P3]`,
388
+ "nit" or "blocker". Fix the bodies yourself; do not ask the user.
389
+ - Show the bodies as **rendered Markdown**, one per `file:line`, never raw
390
+ JSON — the user is approving what the author will read.
391
+ 5. Create the review as **PENDING**, with no event:
129
392
 
130
393
  ```bash
131
394
  gh api repos/tetherto/qvac-harness/pulls/<num>/reviews \
132
- --method POST --input /tmp/review.json
395
+ --method POST --input /tmp/pr-<num>-review.json
133
396
  ```
134
397
 
135
- where `review.json` has `commit_id` (the `headRefOid` you fetched) and a
136
- `comments` array of `{path, line, side, body}`, and **no `event` field**. A body
137
- with `event` submits the review; leaving it out is what makes it pending.
398
+ where the payload has `commit_id` (the `headRefOid` you fetched) and a
399
+ `comments` array of `{path, line, side, body}`, and **no `event` field**. A
400
+ payload with `event` submits the review; leaving it out is what makes it
401
+ pending. No top-level `body` either, unless the user asks for one — the inline
402
+ comments are the review.
138
403
 
139
- 4. Hand the user the link and stop:
140
- `https://github.com/tetherto/qvac-harness/pull/<num>#pullrequestreview-<id>`
404
+ If the user edits the selection after the preview, rewrite the file before
405
+ running the command.
141
406
 
142
- If a line is not in the diff, GitHub rejects the comment. Anchor to a line the
143
- patch actually touches, or raise it in the chat overview instead.
407
+ 6. Hand the user the link and stop:
408
+ `https://github.com/tetherto/qvac-harness/pull/<num>#pullrequestreview-<id>`
144
409
 
145
410
  ## Sibling skills
146
411
 
147
412
  - Writing the PR being reviewed → **pr-create**.
148
- - The rules tier 3 reviews against → **js-house-style**.
413
+ - The rules tier 4 reviews against → **js-house-style**. Load it; do not review
414
+ from memory of it.
package/CLAUDE.md CHANGED
@@ -31,6 +31,9 @@ Runs on both Bare and Node. Anything that only works on one is a bug.
31
31
  never more. Most code needs none — do not narrate it.
32
32
  - **Commits read as if a human wrote them.** No `Co-Authored-By` trailer and no
33
33
  AI or agent attribution, in a commit message or a PR.
34
+ - **Durable decisions are in `docs/decisions/`.** Read `INDEX.md` when touching an
35
+ area it lists, and open a record only on a path or keyword match — they are
36
+ reference, not rules. Add one when a change makes a non-obvious lasting choice.
34
37
  - **Branch from `main`, and open the PR against `main`.** The one exception is a
35
38
  stacked PR, which branches from the PR below it and targets that branch.
36
39
  - **Branch names never contain `codex`, `cursor` or `claude`**, in any case.
package/README.md CHANGED
@@ -10,7 +10,7 @@ spawns and talks to over hrpc — crash isolation for free, death is the exit
10
10
  itself. See [bare-supervisor](https://github.com/tetherto/bare-supervisor) for
11
11
  the supervision contract.
12
12
 
13
- ## The npm artifact spawns; it does not import
13
+ ## The published package
14
14
 
15
15
  The published package ships the prebuilt engine and its runtime content, not
16
16
  the library source:
@@ -28,9 +28,9 @@ The `@qvac` inference addons and `pyodide` resolve from the host's real
28
28
  installs those alongside.
29
29
 
30
30
  The host-side library surface — `spawnHarness`/`harnessChild`, the transport,
31
- the model catalogs, the skill helpers — is consumed from this repository (git
32
- dependency) until a compiled surface ships. The tarball's export map points at
33
- files it intentionally omits: importing the npm artifact is an error by design.
31
+ model catalogs, skill helpers and DOCX extractor — ships as compiled JavaScript
32
+ and declarations in `dist-lib/`. The package exports resolve to that surface;
33
+ the TypeScript source stays in the repository.
34
34
 
35
35
  ## Spawning
36
36
 
@@ -48,6 +48,28 @@ dir, ...) are the ones `worker/harness-sidecar.mjs` documents in this repo. The
48
48
  in-house hosts don't call this directly — they use the repo's library surface
49
49
  (`harnessChild` under bare-supervisor), which owns that argv contract.
50
50
 
51
+ ## DOCX extraction
52
+
53
+ Hosts can supply the bundled Python extractor to their document pipeline:
54
+
55
+ Set `QVAC_PYODIDE_CACHE_DIR` to a writable directory before calling the API,
56
+ including from source and compiled-package consumers. The worker seeds this
57
+ cache from shipped wheels; without it, Pyodide can try downloading packages.
58
+
59
+ ```js
60
+ import { extractDocxText, closeDocxWorker } from '@qvac/harness/docx'
61
+
62
+ const text = await extractDocxText(bytes, 'notes.docx', { signal })
63
+ // At host shutdown, after outstanding extractions have settled:
64
+ await closeDocxWorker()
65
+ ```
66
+
67
+ The extractor preserves paragraph and table order, accepts up to 20 MiB, and
68
+ requires the shipped Python wheels. With the cache configured, extraction uses
69
+ those wheels offline. Bundled hosts also set `QVAC_PYODIDE_WORKER_ENTRY` and
70
+ `QVAC_PYTHON_WHEELS_DIR` to their staged worker and wheels paths.
71
+ Source checkouts prepare wheels with `bun run vendor:wheels`.
72
+
51
73
  ## Development
52
74
 
53
75
  ```