@qvac/harness 0.2.5 → 0.2.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/.claude/skills/asana/SKILL.md +86 -0
- package/.claude/skills/gh-stack/SKILL.md +181 -0
- package/.claude/skills/gh-stack/references/commands.md +177 -0
- package/.claude/skills/gh-stack/references/stack-design.md +97 -0
- package/.claude/skills/gh-stack/references/troubleshooting.md +159 -0
- package/.claude/skills/js-house-style/SKILL.md +650 -0
- package/.claude/skills/kvcache/SKILL.md +171 -0
- package/.claude/skills/pr-create/SKILL.md +137 -0
- package/.claude/skills/pr-review/SKILL.md +148 -0
- package/CLAUDE.md +36 -0
- package/dist/harness.bundle +5 -58
- package/dist/prebuilds-manifest.json +0 -8
- package/dist-lib/index.d.ts +4 -1
- package/dist-lib/index.js +23 -7
- package/dist-lib/lib/models/model-pool.d.ts +1 -1
- package/dist-lib/lib/models/model-pool.js +3 -2
- package/dist-lib/lib/spawn.d.ts +1 -0
- package/dist-lib/schema/generate.d.ts +6 -2
- package/dist-lib/schema/generate.js +10 -5
- package/docs/kvcache-reference.md +655 -0
- package/package.json +1 -1
- package/worker/harness-sidecar.mjs +3 -2
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kvcache
|
|
3
|
+
description: Reason about the QVAC SDK KV cache, the context window and ContextOverflow in @qvac/harness — including why the sliding window (n_discarded) and dynamic tools (toolsMode) were retired. Use when touching prompt-cache keys, the overflow ladder, TTFT regressions, context-overflow errors, cache invalidation on retry/regenerate, or when debugging "the model forgot the conversation". Read this BEFORE proposing any caller-side history eviction.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# KV cache + context window
|
|
7
|
+
|
|
8
|
+
Read **[docs/kvcache-reference.md](../../../docs/kvcache-reference.md)** — how it
|
|
9
|
+
works and the rules for using it. The summary below is just enough to stop the
|
|
10
|
+
common wrong turns.
|
|
11
|
+
|
|
12
|
+
This repo owns the cache: `lib/capabilities/completion.ts` (the `kvCache` key,
|
|
13
|
+
the round loop, the overflow ladder), `lib/context-window.ts`,
|
|
14
|
+
`lib/models/kv-cache.ts` and `lib/models/model-pool.ts`. The *prompt* side —
|
|
15
|
+
folding a chat's history so it fits — is `@qvac/core`'s `lib/compaction.ts`;
|
|
16
|
+
see its **compaction** skill before proposing anything that shrinks history.
|
|
17
|
+
|
|
18
|
+
## The one thing to internalise
|
|
19
|
+
|
|
20
|
+
Three state sets exist and are **never reconciled**:
|
|
21
|
+
|
|
22
|
+
| Layer | State | Keyed by |
|
|
23
|
+
| --- | --- | --- |
|
|
24
|
+
| caller (`@qvac/core`) | message **list** (shrinks only on an overflow retry) | chat |
|
|
25
|
+
| SDK | message **count** (`savedCount`) | cache file path |
|
|
26
|
+
| addon | token **positions** (`nPast`) + the on-disk `.bin` | cache key |
|
|
27
|
+
|
|
28
|
+
Almost every bug here is drift between those three, not context pressure.
|
|
29
|
+
`savedCount` means "already sent", never "still resident": nothing below the
|
|
30
|
+
SDK reports what it evicted. That is what made the retired sliding window and
|
|
31
|
+
dynamic-tools trim fatal, and it is the test for any new eviction idea.
|
|
32
|
+
|
|
33
|
+
## The knobs (two)
|
|
34
|
+
|
|
35
|
+
- `history`: the full history goes to `completion()`; the SDK computes the delta.
|
|
36
|
+
- `cacheKey: 'chat-<chatId>'` — set by the caller, consumed here at
|
|
37
|
+
[lib/capabilities/completion.ts](../../../lib/capabilities/completion.ts).
|
|
38
|
+
An accepted diagram repair primes under a child of it (`chat-<chatId>/r<n>`),
|
|
39
|
+
so deleting the chat key reclaims every generation.
|
|
40
|
+
|
|
41
|
+
Nothing else. `n_discarded` and `toolsMode` are gone from the stack, not just
|
|
42
|
+
unset.
|
|
43
|
+
|
|
44
|
+
**No client-side token math, ever.** Use the SDK's real `cacheTokens` /
|
|
45
|
+
`promptTokens` / `generatedTokens` from `completion()` stats, and react to the
|
|
46
|
+
typed `ContextOverflowError`. Never estimate chars-per-token, never reserve a
|
|
47
|
+
response budget. To A/B the cache, drop `cacheKey` locally.
|
|
48
|
+
|
|
49
|
+
If you encounter `RESERVED_FOR_RESPONSE`, a chars-per-token estimator,
|
|
50
|
+
`windowHistoryToFit`, or `toolsThatFit` anywhere, that is retired code — not the
|
|
51
|
+
shipping path, and none of it should come back.
|
|
52
|
+
|
|
53
|
+
## Retired knobs
|
|
54
|
+
|
|
55
|
+
Both were dropped on 2026-08-20 and have since been deleted upstream. Kept here
|
|
56
|
+
as bug shapes, not as options.
|
|
57
|
+
|
|
58
|
+
- **Sliding window (`n_discarded`).** SDK 0.19 dropped it from the `loadModel`
|
|
59
|
+
schema (rejected at validation) and addon 0.48 removed sliding outright. Why
|
|
60
|
+
it had to go: a slide was invisible to the SDK — it recorded the turn's full
|
|
61
|
+
message count and next sent `history.slice(savedCount)`, so the discarded span
|
|
62
|
+
was gone from the KV, never re-sent, and the model silently lost the middle of
|
|
63
|
+
the chat. While sliding was possible the tool block also travelled with every
|
|
64
|
+
turn (`toolBlockEvictable`, ~331 tokens for a 4-tool agent). A full window is
|
|
65
|
+
now a normal end state, recovered by the ladder and by the caller's fold.
|
|
66
|
+
- **Dynamic tools (`toolsMode: 'dynamic'`).** SDK 0.18 deleted the key (its
|
|
67
|
+
parser rejects it); the addon dropped `tools_compact` after 0.39.4. It was a
|
|
68
|
+
no-op on every shipped model — the addon gate is exact-arch `qwen3`, ours are
|
|
69
|
+
`qwen35`/`qwen36` — while the SDK still sliced as-if-dynamic: the previous
|
|
70
|
+
answer was duplicated into the KV every turn and, on a cold cache, only the
|
|
71
|
+
last exchange was sent instead of overflowing. Static placement is the only
|
|
72
|
+
mode: `history.slice(savedCount)`, full history on a cold cache at TTFT cost
|
|
73
|
+
only, which is also what makes the overflow ladder effective.
|
|
74
|
+
|
|
75
|
+
Full history: [2026-08-20-kvcache-static-placement](https://github.com/tetherto/qvac-app/blob/main/docs/decisions/2026-08-20-kvcache-static-placement.md),
|
|
76
|
+
still in `tetherto/qvac-app`.
|
|
77
|
+
|
|
78
|
+
## Hard facts that trip people up
|
|
79
|
+
|
|
80
|
+
- **A slice at or above `ctx_size` can never be admitted.** Nothing is decoded
|
|
81
|
+
yet, so there is nothing to evict — and nothing evicts anyway.
|
|
82
|
+
- **Overflow is a normal end state:** every long chat legitimately reaches ctx,
|
|
83
|
+
recovered by the ladder and by the caller's fold for any window at or above
|
|
84
|
+
4,096. Also legitimate: the current prompt alone exceeds ctx, a tool result
|
|
85
|
+
alone exceeds ctx, or a device that has never run this chat getting the whole
|
|
86
|
+
history (the cache is **device-local**). Anything else is a drift bug.
|
|
87
|
+
- **A thrown overflow keeps the cache** (SDK 0.19,
|
|
88
|
+
[qvac#4163](https://github.com/tetherto/qvac/pull/4163)): a prefill
|
|
89
|
+
`ContextOverflowError` or an addon pre-mutation refusal releases the turn and
|
|
90
|
+
the committed `.bin` survives. What still destroys it: a turn that hits the
|
|
91
|
+
ceiling **mid-generation** (addon `stopReason=contextOverflow`, surfaced as
|
|
92
|
+
`length`) is not committed — its file is unlinked and the next turn
|
|
93
|
+
cold-primes from history.
|
|
94
|
+
- **The tool block is not in the primed prefix** (since 0.17.1): the prime is
|
|
95
|
+
the system prompt alone. The block travels with the first turn that renders it
|
|
96
|
+
(the SDK requires a user message before believing it landed) and is skipped
|
|
97
|
+
once `toolBlockCached` is recorded at commit. It is never trimmed back out, so
|
|
98
|
+
`configHash` hashes the system prompt **plus the full tool definitions** — any
|
|
99
|
+
tool-set, description, or parameter change re-keys the file and costs a cold
|
|
100
|
+
prime. A skill activation and a `disabledToolsets` edit each do that once and
|
|
101
|
+
then hold. The block is NOT a fixed size — it is whatever the agent's
|
|
102
|
+
`enabledTools` serializes to; read `round start { tools }` and
|
|
103
|
+
`round stats { promptTokens }` from the harness log, never assume a figure.
|
|
104
|
+
- **`modelId` is identity-by-config**: `sha256(type:src:sortedConfig)[:16]`. ANY
|
|
105
|
+
`modelConfig` field change — including `verbosity` from `QVAC_LLM_VERBOSITY` —
|
|
106
|
+
is a new `modelId`, a new cache directory, and a cold prime for every chat.
|
|
107
|
+
Debug the cache with `QVAC_HARNESS_LOG`/`xxd`, never by raising addon
|
|
108
|
+
verbosity. The system prompt is NOT in `modelId` (it is in `configHash`, the
|
|
109
|
+
file name): a prompt edit cold-primes one chat, a config edit cold-primes all.
|
|
110
|
+
- **The addon compacts reasoning out of the KV itself.**
|
|
111
|
+
`remove_thinking_from_context` defaults to `true` (addon 0.33.0); since 0.48 it
|
|
112
|
+
rewinds to the block boundary and re-decodes what it keeps. `cacheTokens`
|
|
113
|
+
after a turn excludes thinking, so nothing above has to strip it.
|
|
114
|
+
- **`ContextOverflowError` carries sizes** (0.19): `requiredTokens`, `ctxSize`,
|
|
115
|
+
`cachedTokens` on the warm guard, and `promptTokens` only when the guard
|
|
116
|
+
counted tokens. The harness matches the error by `name` (`CONTEXT_OVERFLOW`)
|
|
117
|
+
and reads none of them.
|
|
118
|
+
|
|
119
|
+
## Before proposing caller-side eviction
|
|
120
|
+
|
|
121
|
+
Ask whether the SDK cache would already handle it. The answer is yes for
|
|
122
|
+
ordinary history growth; the cases that genuinely need handling above the SDK
|
|
123
|
+
are a message (or tool result) larger than `ctx_size`, plus the cross-device
|
|
124
|
+
cold start. Anything else is re-implementing the cache badly.
|
|
125
|
+
|
|
126
|
+
**Compaction is the one sanctioned exception, and it already exists in
|
|
127
|
+
`@qvac/core` — do not build a second one here.** It evicts from the prompt,
|
|
128
|
+
never from the KV; it uses the SDK's own `cacheTokens` rather than token math;
|
|
129
|
+
and it invalidates the chat key when a fold lands. The floor is
|
|
130
|
+
`COMPACTION_MIN_CTX_SIZE` (4,096): below it a fold cannot pay for the ~420-token
|
|
131
|
+
prefix it shares the window with, so those chats stay on the ladder here.
|
|
132
|
+
|
|
133
|
+
## Debugging
|
|
134
|
+
|
|
135
|
+
- `round stats { round, wallMs, TTFT, TPS, cacheTokens, promptTokens }` and
|
|
136
|
+
`round start { round, turns, tools }` — the per-round `hlog` in
|
|
137
|
+
[lib/capabilities/completion.ts](../../../lib/capabilities/completion.ts).
|
|
138
|
+
`cacheTokens` dropping back to system-prompt size mid-chat = a re-prime.
|
|
139
|
+
`turns` shrinking across an overflow with an identical outcome = an inert
|
|
140
|
+
ladder.
|
|
141
|
+
- SDK `logMessagesToAddon` tags: `PROMPT_SEND` / `CACHE_INIT` / `NO_CACHE`. A
|
|
142
|
+
`CACHE_INIT` mid-chat is a re-prime.
|
|
143
|
+
- No addon line reports eviction any more: `discarded N tokens`,
|
|
144
|
+
`[ContextSlider]` and `runtimeStats().contextSlides` left with sliding in
|
|
145
|
+
addon 0.48. A log that shows them is an old build.
|
|
146
|
+
- Cache files: `{kvCacheDir}/{cacheKey}/{modelId}/{configHash}.bin`. Two files
|
|
147
|
+
under one chat key means `configHash` changed — a volatile system prompt costs
|
|
148
|
+
one cold prime per turn.
|
|
149
|
+
|
|
150
|
+
## Versions — check these first
|
|
151
|
+
|
|
152
|
+
**This behaviour is version-specific and has changed before.** Start every task
|
|
153
|
+
here:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
grep '"@qvac/sdk"' package.json
|
|
157
|
+
grep '"version"' node_modules/@qvac/inference/package.json node_modules/@qvac/llm-llamacpp/package.json
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
This repo pins **`@qvac/sdk` 0.19.0** → **`@qvac/inference` 0.19.0** →
|
|
161
|
+
**`@qvac/llm-llamacpp` 0.49.1**. Since 0.19 `@qvac/sdk` is a thin re-export over
|
|
162
|
+
`@qvac/inference`, and the `#sdk` import seam resolves to `@qvac/inference`
|
|
163
|
+
in-process on Bare — so the cache code that runs is
|
|
164
|
+
`node_modules/@qvac/inference/dist/plugins/builtin/llamacpp-completion/ops/`
|
|
165
|
+
(`completion-stream.js`, `kv-cache-session.js`, `context-overflow.js`), not
|
|
166
|
+
anything under `@qvac/sdk/dist`. If the shipped numbers move past these, re-read
|
|
167
|
+
before acting.
|
|
168
|
+
|
|
169
|
+
Whenever you re-verify something, update the Versions section in
|
|
170
|
+
[docs/kvcache-reference.md](../../../docs/kvcache-reference.md) in the same
|
|
171
|
+
commit.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-create
|
|
3
|
+
description: Write the title, body and commits for a pull request in @qvac/harness, and decide the conventional-commit type for a change — `fix` is reserved for user-facing defects in a released version. Use when opening a PR here, splitting work into a stack, or choosing between `fix` and `chore`.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PR creation
|
|
7
|
+
|
|
8
|
+
`@qvac/harness` is a published package. The log is the only durable record of intent,
|
|
9
|
+
and for this repo it is also the changelog a consumer reads before upgrading.
|
|
10
|
+
|
|
11
|
+
## Title
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
type(scope): subject
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Imperative, lowercase after the colon, no trailing period. Scope optional, and
|
|
18
|
+
only when it narrows something real. What and why, not how.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
feat: publish the sidecar entry, so spawning it needs no bundle
|
|
22
|
+
fix(publish): repoint dynamic imports at dist-lib too
|
|
23
|
+
refactor: own the schema codegen tooling
|
|
24
|
+
chore: regenerate the schema
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
There is no ticket prefix here, and no title validator in CI. That is not
|
|
28
|
+
licence to be loose: nothing will catch a bad title but a reviewer.
|
|
29
|
+
|
|
30
|
+
## Types
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
build chore ci docs style refactor perf test fix feat
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**`fix` is reserved for a defect a consumer of a released version could hit.**
|
|
37
|
+
It is the line someone reads to decide whether to upgrade, so it claims real
|
|
38
|
+
breakage in something already published.
|
|
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` |
|
|
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` |
|
|
51
|
+
|
|
52
|
+
When a repair is on unreleased code, check the last release tag: if the bug was
|
|
53
|
+
never in a published version, it is `chore`, not `fix`.
|
|
54
|
+
|
|
55
|
+
Never relabel a real defect as `chore` to make the log quieter, and never
|
|
56
|
+
inflate a cleanup into `fix` to make it look urgent.
|
|
57
|
+
|
|
58
|
+
## Scopes
|
|
59
|
+
|
|
60
|
+
Optional, and taken from what the diff actually touches — `lib`, `worker`, `schema`, `spec`, `scripts`, `test`, `ci`, `publish`, or a capability name (`completion`, `tools`, `models`).
|
|
61
|
+
A scope that restates the type (`fix(fix)`) or names the whole repo adds
|
|
62
|
+
nothing; leave it off.
|
|
63
|
+
|
|
64
|
+
## Small PRs, stacked
|
|
65
|
+
|
|
66
|
+
A PR is read by a human, so it has to fit in one head. Default to one concern.
|
|
67
|
+
When a change decomposes into dependent steps, do not grow one PR to fit them —
|
|
68
|
+
stack them, so each step is reviewable alone and lands in order.
|
|
69
|
+
|
|
70
|
+
- A large refactor belongs on a `refactor/...` branch with `refactor:` commits.
|
|
71
|
+
- **Refactor commits never live inside a non-refactor branch.** A `feat/` branch
|
|
72
|
+
that also reshuffles unrelated code is two PRs. Behaviour changes and pure
|
|
73
|
+
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
|
|
75
|
+
commit or its own PR in the stack.
|
|
76
|
+
|
|
77
|
+
Branch names must never contain `codex`, `cursor`, or `claude` (case
|
|
78
|
+
insensitive). Use a neutral name before committing or pushing.
|
|
79
|
+
|
|
80
|
+
## Body
|
|
81
|
+
|
|
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".
|
|
84
|
+
|
|
85
|
+
```markdown
|
|
86
|
+
## What
|
|
87
|
+
|
|
88
|
+
One paragraph. The change, in the reviewer's terms.
|
|
89
|
+
|
|
90
|
+
## Why
|
|
91
|
+
|
|
92
|
+
The problem this solves, or the decision it implements. Link the issue,
|
|
93
|
+
PR, or upstream change that forced it.
|
|
94
|
+
|
|
95
|
+
## How
|
|
96
|
+
|
|
97
|
+
Only the parts a reader would not infer from the diff: the seam that moved,
|
|
98
|
+
the invariant being preserved, the thing that looks wrong but isn't.
|
|
99
|
+
|
|
100
|
+
## Testing
|
|
101
|
+
|
|
102
|
+
What you ran, and what it proved. ``bun run test` (node, bare and addon lanes)` at minimum.
|
|
103
|
+
Say plainly when something could not be tested locally and why.
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
For a **breaking change**, say so in the body under its own `## Breaking`
|
|
107
|
+
heading, with the migration a consumer has to perform. Published package —
|
|
108
|
+
this is the only warning they get.
|
|
109
|
+
|
|
110
|
+
## Before opening
|
|
111
|
+
|
|
112
|
+
1. Check the branch is not `main` and the name is neutral.
|
|
113
|
+
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
|
|
116
|
+
red PR wastes a reviewer's round trip.
|
|
117
|
+
4. Rebase on `main` rather than merging it in. A merge commit in the branch
|
|
118
|
+
makes the diff unreadable.
|
|
119
|
+
5. Open as a **draft** unless you are asking for review right now.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
gh pr create --repo tetherto/qvac-harness --draft --title "type(scope): subject" --body-file <path>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Never push to `main`, never force-push a branch someone else is reviewing, and
|
|
126
|
+
never open a PR that carries commits you did not write without saying so.
|
|
127
|
+
|
|
128
|
+
## Version bumps
|
|
129
|
+
|
|
130
|
+
Release PRs in this repo are titled by version alone (`0.2.4 (#32)`,
|
|
131
|
+
`release/0.1.4 (#40)`). They carry the version bump and nothing else — do not
|
|
132
|
+
fold a bump into a feature PR, and do not fold a feature into a bump.
|
|
133
|
+
|
|
134
|
+
## Sibling skills
|
|
135
|
+
|
|
136
|
+
- Reviewing a PR or a local diff → **pr-review**.
|
|
137
|
+
- How the code itself should be shaped → **js-house-style**.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
---
|
|
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.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PR review
|
|
7
|
+
|
|
8
|
+
Reviews changes in `@qvac/harness`. Two modes.
|
|
9
|
+
|
|
10
|
+
- **PR mode** (a PR number or URL) — a short overview in chat, then a **pending**
|
|
11
|
+
GitHub review of per-file inline comments. The pending review is created only
|
|
12
|
+
after the user confirms the exact set of comments. **Never submit the review
|
|
13
|
+
event** (`COMMENT`, `REQUEST_CHANGES`, `APPROVE`) — that is the user's call,
|
|
14
|
+
from the GitHub UI.
|
|
15
|
+
- **Local mode** (`local`, or "review my changes") — the overview in chat only.
|
|
16
|
+
Posts nothing, anywhere.
|
|
17
|
+
|
|
18
|
+
## Gather
|
|
19
|
+
|
|
20
|
+
PR mode:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
gh pr view <num> --repo tetherto/qvac-harness \
|
|
24
|
+
--json title,body,author,headRefName,headRefOid,baseRefName,files,additions,deletions,state,isDraft,mergeable
|
|
25
|
+
gh pr diff <num> --repo tetherto/qvac-harness --patch > /tmp/pr-<num>.patch
|
|
26
|
+
```
|
|
27
|
+
|
|
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.
|
|
30
|
+
|
|
31
|
+
Local mode:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
git diff --staged > /tmp/local-staged.patch
|
|
35
|
+
git diff > /tmp/local-unstaged.patch
|
|
36
|
+
git status --porcelain=v1
|
|
37
|
+
git ls-files --others --exclude-standard # untracked, easy to miss
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For a branch rather than a working tree: `git diff main...HEAD` (three dots —
|
|
41
|
+
the merge base, not the tip).
|
|
42
|
+
|
|
43
|
+
## CI
|
|
44
|
+
|
|
45
|
+
One workflow gates this repo: **Integrate** (`.github/workflows/ci.yml`), a
|
|
46
|
+
single `Lint & Tests` job. `publish.yml` runs on release, not on PRs.
|
|
47
|
+
|
|
48
|
+
Its steps are each a separate way to fail, and the last three catch what a
|
|
49
|
+
local `bun run test` does not:
|
|
50
|
+
|
|
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 |
|
|
58
|
+
|
|
59
|
+
A PR that touches `schema/` and leaves `spec/` stale is the most common red
|
|
60
|
+
here, and it looks nothing like a test failure.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
gh pr checks <num> --repo tetherto/qvac-harness
|
|
64
|
+
gh run view --repo tetherto/qvac-harness --log-failed --job <id> > /tmp/pr-<num>-<id>.log
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
A red `Integrate` is a blocking finding on its own. Read the failing job's log
|
|
68
|
+
before writing a single line of review — half of what looks like a design
|
|
69
|
+
problem is a lint rule.
|
|
70
|
+
|
|
71
|
+
## What to check, in order
|
|
72
|
+
|
|
73
|
+
Stop at the first tier that produces findings worth the author's time; a review
|
|
74
|
+
that lists twelve nits under a broken contract has buried the real thing.
|
|
75
|
+
|
|
76
|
+
**1. Correctness.** Does it do what the title claims? Trace the changed path
|
|
77
|
+
end to end, including the error path. Look for: a promise not awaited, a
|
|
78
|
+
listener never removed, a resource opened on one path and closed on another, an
|
|
79
|
+
error swallowed into a default.
|
|
80
|
+
|
|
81
|
+
**2. Contract and API.** This is a published package, so an exported signature
|
|
82
|
+
is a promise to a consumer.
|
|
83
|
+
|
|
84
|
+
- Anything added to or changed in the export map, `index.ts`, `types/`, or
|
|
85
|
+
`package.json#exports` — is it intentional, and is it a breaking change?
|
|
86
|
+
- `schema/` or `spec/` changes: is the wire format still compatible, and was the
|
|
87
|
+
baseline regenerated (`bun run build:schema`) rather than hand-edited?
|
|
88
|
+
- Does the change match its own type declarations, and do callers in this repo
|
|
89
|
+
still typecheck?
|
|
90
|
+
|
|
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.
|
|
94
|
+
|
|
95
|
+
**4. Tests.** A behaviour change with no test is a finding. Name the missing
|
|
96
|
+
case rather than asking for "more tests": the tests live under `test/`, run on
|
|
97
|
+
both the node and bare lanes, and a fix without a regression guard will come
|
|
98
|
+
back.
|
|
99
|
+
|
|
100
|
+
**5. Commit type and title.** Per **pr-create**: is this really a `fix` (a
|
|
101
|
+
defect a consumer of a released version could hit), or is it `chore` on code
|
|
102
|
+
that never shipped? Is the title imperative and specific? Does the branch name
|
|
103
|
+
avoid `codex` / `cursor` / `claude`?
|
|
104
|
+
|
|
105
|
+
**6. Scope.** Does the PR do one thing? A behaviour change mixed with an
|
|
106
|
+
unrelated rename is two PRs — say so, and say which commit to split out.
|
|
107
|
+
|
|
108
|
+
## Write the findings
|
|
109
|
+
|
|
110
|
+
Each finding: the file and line, what breaks, and the concrete scenario that
|
|
111
|
+
breaks it. No finding without a failure mode you can state.
|
|
112
|
+
|
|
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.
|
|
117
|
+
|
|
118
|
+
Distinguish clearly:
|
|
119
|
+
|
|
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.
|
|
123
|
+
|
|
124
|
+
## Posting (PR mode only)
|
|
125
|
+
|
|
126
|
+
1. Print every proposed comment in chat first: file, line, body.
|
|
127
|
+
2. Ask the user to confirm the exact set. Wait for a clear yes.
|
|
128
|
+
3. Create the review as **PENDING**, with no event:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
gh api repos/tetherto/qvac-harness/pulls/<num>/reviews \
|
|
132
|
+
--method POST --input /tmp/review.json
|
|
133
|
+
```
|
|
134
|
+
|
|
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.
|
|
138
|
+
|
|
139
|
+
4. Hand the user the link and stop:
|
|
140
|
+
`https://github.com/tetherto/qvac-harness/pull/<num>#pullrequestreview-<id>`
|
|
141
|
+
|
|
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.
|
|
144
|
+
|
|
145
|
+
## Sibling skills
|
|
146
|
+
|
|
147
|
+
- Writing the PR being reviewed → **pr-create**.
|
|
148
|
+
- The rules tier 3 reviews against → **js-house-style**.
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @qvac/harness
|
|
2
|
+
|
|
3
|
+
The QV.AC inference engine: `generate(context)` over the QVAC SDK, plus the tool
|
|
4
|
+
runtime skills execute in. **Inference in, events out** — it knows nothing about
|
|
5
|
+
the app, hyperdb or sync. It runs as a supervised child process (or a Bare thread
|
|
6
|
+
on mobile) that a host spawns and talks to over hrpc.
|
|
7
|
+
|
|
8
|
+
Runs on both Bare and Node. Anything that only works on one is a bug.
|
|
9
|
+
|
|
10
|
+
## Durable invariants
|
|
11
|
+
|
|
12
|
+
- **The published package spawns; it does not import.** The tarball ships the
|
|
13
|
+
prebuilt bundle and its runtime content, and its export map deliberately points
|
|
14
|
+
at files it omits. That map is not broken — do not "fix" it.
|
|
15
|
+
- **`spec/` is generated** by `bun run build:schema`. Never hand-edit it; CI fails
|
|
16
|
+
when it is dirty after regeneration.
|
|
17
|
+
- **Dependency `overrides` pin the resolutions the engine is validated against.**
|
|
18
|
+
Keep them aligned with the direct specs — npm refuses a mismatch on publish.
|
|
19
|
+
- **The cache is the SDK's.** Do not add caller-side history eviction or
|
|
20
|
+
chars-per-token estimation.
|
|
21
|
+
|
|
22
|
+
## Working here
|
|
23
|
+
|
|
24
|
+
- `bun run lint` (prettier + lunte + tsc) and `bun run test` (node, bare and
|
|
25
|
+
addon lanes) before considering a change done.
|
|
26
|
+
- Tests live in `test/` and run under brittle. A non-trivial change ships tests.
|
|
27
|
+
|
|
28
|
+
## Always
|
|
29
|
+
|
|
30
|
+
- **Comment only what the code cannot say.** Why, not what. One or two lines,
|
|
31
|
+
never more. Most code needs none — do not narrate it.
|
|
32
|
+
- **Commits read as if a human wrote them.** No `Co-Authored-By` trailer and no
|
|
33
|
+
AI or agent attribution, in a commit message or a PR.
|
|
34
|
+
- **Branch from `main`, and open the PR against `main`.** The one exception is a
|
|
35
|
+
stacked PR, which branches from the PR below it and targets that branch.
|
|
36
|
+
- **Branch names never contain `codex`, `cursor` or `claude`**, in any case.
|