opencode-self-improvement 0.33.0 → 0.33.2
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/README.md +2 -2
- package/docs/adr/0002-window-dedup.md +5 -0
- package/docs/auto-capture-evidence.md +4 -4
- package/docs/injection-cost.md +3 -3
- package/docs/pre-release-ritual.md +1 -1
- package/package.json +2 -1
- package/src/capture/runtime.ts +2 -2
- package/src/recall/dedupe.ts +5 -3
- package/src/store/lock.ts +7 -6
- package/src/tools/schema.ts +3 -3
- package/src/viewer/page.html +1 -1
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ Two results. Only two are quoted, each with its `n` and the seat it ran on, beca
|
|
|
105
105
|
|
|
106
106
|
**What is not claimed here.** No token saving. No dollar figure. The seat above is a local box with no cache price; on a hosted provider a cache miss costs roughly 0.1× read and 1.25× write, which is a different claim and cannot be quoted from these numbers.
|
|
107
107
|
|
|
108
|
-
**Rules for any cost claim in this repository** — the published numbers live in `bench/claims.json`, and `test/claims.test.ts` enforces that file and this one in CI:
|
|
108
|
+
**Rules for any cost claim in this repository** — the published numbers live in `bench/claims.json`, and `test/host/claims.test.ts` enforces that file and this one in CI:
|
|
109
109
|
|
|
110
110
|
- No cost claim below **n=6 pairs per arm**. A ratio at `6 ≤ n < 21` is labelled **"20% resolution"**.
|
|
111
111
|
- A **seat** and a **metric** are named on the same line as the number.
|
|
@@ -174,7 +174,7 @@ The rule is: never merge two entries unless every question that used to find eit
|
|
|
174
174
|
- **Deterministic.** The canonical row is the survivor's prose verbatim plus the absorbed rows' aliases as keywords. No model rewrites anything.
|
|
175
175
|
- **Proven by recorded reads.** Every read the ledger recorded for a cluster is replayed against the merged store, and a merge is proposed only when the canonical row catches at least as many of the cluster's own reads as the best single member did alone. A cluster with no recorded reads is reported as *unmeasured* and never merged on resemblance.
|
|
176
176
|
|
|
177
|
-
**Bench** — on the eval dataset the pass takes 200 rows to 52 with **R@3 52 → 53 and R@1 52 → 50**, and store-wide injected characters 25 945c → 6 933c. Both the regression and the budget swap are bounded in CI (`test/consolidate-bench.test.ts`).
|
|
177
|
+
**Bench** — on the eval dataset the pass takes 200 rows to 52 with **R@3 52 → 53 and R@1 52 → 50**, and store-wide injected characters 25 945c → 6 933c. Both the regression and the budget swap are bounded in CI (`test/consolidate/consolidate-bench.test.ts`).
|
|
178
178
|
|
|
179
179
|
## Secret redaction
|
|
180
180
|
|
|
@@ -20,6 +20,11 @@ The live store carries repeated rows — superseded snapshots, cursor rows diffe
|
|
|
20
20
|
4. It treated differing numeric facts as duplicates: short tokens are dropped, so "DB 3" and "DB 4" share identical token sets and the older row was suppressed even at threshold 1.
|
|
21
21
|
- Default-ON followed the same rule as ADR 0001: a quality fix behind an opt-in flag is not a fix.
|
|
22
22
|
- Evidence: live-store replay published in the #409 record (§17) and PR #426. The replay's off-arm must set `OPENCODE_MEMORY_DEDUP=0` explicitly — with default-ON, an unset arm measures nothing.
|
|
23
|
+
- Re-measured 2026-11-19 over the window a repository actually reads — its own rows plus rows carrying no repository stamp (`bun bench/runners/dedup-live-replay.ts`; written up in the [live dedup replay](https://github.com/abogartz/opencode-self-improvement/blob/main/bench/dedup-live-results.md), whose counts are a dated snapshot because the store drifts). The scan neither confirms nor refutes 0.8: among the repository's own active rows no pair reaches the threshold, and once superseded history is included every candidate has a superseded side. It found two other things, and they are the useful part. Near-identical rows can stay active together: the write gate's duplicate check is exact and keyed by type, while this pass compares across types, so identical prose filed as two types lands twice and stays active. This pass is therefore not redundant with the gate. And the pass is inert on the repository's own rows because of its guards, not because the store is clean: of the pairs the pre-`fc59b84` rule would have suppressed, the dropped-chunk guard stops nearly all and the content floor the rest.
|
|
24
|
+
- Known limitation, from that same replay: 0.8 suppresses a pair that is not a copy. Two active rows naming two different build commands in one scope score 0.824 and pass every guard. Ranking favors recency and the pass keeps the first-ranked row of a clash, so the survivor is the newer, narrower command and the plain build command is what disappears from the reader's view. The threshold trades that against crowding; where a scope holds parallel short facts, it costs real information.
|
|
25
|
+
- Raising the default was evaluated on 2026-11-19 and rejected. The pair worth releasing scores 0.8235; the changed-fact pair pinned in `test/recall/dedupe-tool.test.ts` — the same runbook sentence with `friday` replaced by `monday` — scores 0.8333. Any threshold separating them must sit in a window one hundredth wide, which is a constant fitted to two observations, and 0.9 releases both and removes the recency rule above. The two rows have the same shape: one sentence, one long token swapped out. Whether that swap replaced a fact or added one is not visible in a token overlap, so this is not a threshold problem.
|
|
26
|
+
- The dropped-chunk guard, not the threshold, decides what this pass ever sees. Two rows differing by a timestamp have different dropped fragments and are never compared, so the cursor rows this record names as the motivation are exempt, while prose carrying no short fragments at all is compared and can be suppressed on shape alone.
|
|
27
|
+
|
|
23
28
|
|
|
24
29
|
## Addition groups
|
|
25
30
|
|
|
@@ -13,11 +13,11 @@ in the README; this is the record behind them.
|
|
|
13
13
|
|
|
14
14
|
What is established, from tests and fixtures (no live store involved):
|
|
15
15
|
|
|
16
|
-
- **The trigger events are ones the host actually emits.** Capture subscribes to `session.execution.succeeded` and `session.execution.interrupted`, the two turn-end events present in a recording of the desktop service (`test/fixtures/host-events.jsonl`). `session.idle`, `session.status` and `session.execution.failed` are *declared* by the host but absent from that recording, so they deliberately do not trigger capture; `test/event-fidelity.test.ts` refuses a trigger that is only declared. An earlier revision subscribed to `session.idle` and stayed silent for days with no signal — reading a declared event as an emitted one is the failure that fixture exists to prevent.
|
|
17
|
-
- **The path runs under simulated host traffic** — unit tests hand the plugin the recorded envelopes and assert a candidate lands through the write gate, including conservation (a near-duplicate collapses at the gate instead of writing a second row): `test/capture-auto.test.ts`, `test/capture-compaction.test.ts`. No terminal e2e scenario covers the trigger, so the simulated envelope is the strongest evidence that exists — and fabricating the envelope is exactly what passed while this feature was dead.
|
|
18
|
-
- **Identity triggers have their own recording check.** `test/event-fidelity.test.ts` checks `IDENTITY_EVENT_TYPES` against the original 2.1.4 recording plus `test/fixtures/host-session-move.json`, a normalized one-frame extract from a separate 2.2.2 move capture. The extract must declare nonempty provenance and its retained envelopes must round-trip through the lockfile-pinned `@opencode/schema` 2.0.32 decoder. These checks reject missing metadata and malformed envelopes; they do not authenticate the capture. The identity replay uses the plugin subscription, but live plugin rebinding remains unverified. The recording version is distinct from the CI host pin (2.0.26).
|
|
16
|
+
- **The trigger events are ones the host actually emits.** Capture subscribes to `session.execution.succeeded` and `session.execution.interrupted`, the two turn-end events present in a recording of the desktop service (`test/fixtures/host-events.jsonl`). `session.idle`, `session.status` and `session.execution.failed` are *declared* by the host but absent from that recording, so they deliberately do not trigger capture; `test/identity/event-fidelity.test.ts` refuses a trigger that is only declared. An earlier revision subscribed to `session.idle` and stayed silent for days with no signal — reading a declared event as an emitted one is the failure that fixture exists to prevent.
|
|
17
|
+
- **The path runs under simulated host traffic** — unit tests hand the plugin the recorded envelopes and assert a candidate lands through the write gate, including conservation (a near-duplicate collapses at the gate instead of writing a second row): `test/capture/capture-auto.test.ts`, `test/capture/capture-compaction.test.ts`. No terminal e2e scenario covers the trigger, so the simulated envelope is the strongest evidence that exists — and fabricating the envelope is exactly what passed while this feature was dead.
|
|
18
|
+
- **Identity triggers have their own recording check.** `test/identity/event-fidelity.test.ts` checks `IDENTITY_EVENT_TYPES` against the original 2.1.4 recording plus `test/fixtures/host-session-move.json`, a normalized one-frame extract from a separate 2.2.2 move capture. The extract must declare nonempty provenance and its retained envelopes must round-trip through the lockfile-pinned `@opencode/schema` 2.0.32 decoder. These checks reject missing metadata and malformed envelopes; they do not authenticate the capture. The identity replay uses the plugin subscription, but live plugin rebinding remains unverified. The recording version is distinct from the CI host pin (2.0.26).
|
|
19
19
|
|
|
20
|
-
- **Teardown stops work that is still in flight.** `generate.text` does not take the abort signal, so a capture parked mid-model-call used to wake up after the host disposed the plugin and run the whole write gate against a store its caller had already removed. Cleanup now aborts the subscription, every pass re-checks the signal after the model call and between candidates (a gate already mutating is never cut in half), and cleanup drains the tracked passes under a one-second bound — teardown never waits on the model. `test/capture-dispose-drain.test.ts` parks a capture, disposes, releases, and asserts that no row and no evidence line carries a timestamp after disposal (#211).
|
|
20
|
+
- **Teardown stops work that is still in flight.** `generate.text` does not take the abort signal, so a capture parked mid-model-call used to wake up after the host disposed the plugin and run the whole write gate against a store its caller had already removed. Cleanup now aborts the subscription, every pass re-checks the signal after the model call and between candidates (a gate already mutating is never cut in half), and cleanup drains the tracked passes under a one-second bound — teardown never waits on the model. `test/capture/capture-dispose-drain.test.ts` parks a capture, disposes, releases, and asserts that no row and no evidence line carries a timestamp after disposal (#211).
|
|
21
21
|
|
|
22
22
|
- **The trigger is live on a real host, and the write now survives it.** An end-to-end scenario drives `opencode run` against a real turn with a scripted provider (`e2e/capture.test.ts`): the turn-end event fires and a capture pass starts, 12 of 12 runs. It used to reach the write gate in only some of them — 3 of 12 in one sample, 6 of 12 in a controlled A/B against the same script, 12 of 12 in two samples after the fix. `opencode run` disposes the plugin as the turn ends, and `captureCleanup` aborted every in-flight pass before its gate ran: the #211 contract, correct for the teardown it was written for and fatal here, because nothing is being torn down and the process simply exits. Cleanup now distinguishes the two cases — a pass still parked in the model call is abandoned, a pass that already holds its answer is drained, because its remaining work is local and milliseconds. All of #211's disposal assertions still pass unchanged. Fixed on this branch, #404.
|
|
23
23
|
|
package/docs/injection-cost.md
CHANGED
|
@@ -14,8 +14,8 @@ claim, and a provider audit reported by its author.
|
|
|
14
14
|
- **A session never pays for bytes it is not riding.** A memory *you* saved in this session is a fact you already produced — it is in your own transcript — so it never busts your cache. The test is not "did the store change" but "would the frozen bytes still have been produced from the same inputs, minus the rows this session authored since": a correction, blocklisting, redaction or supersession of a row you are riding, and anything another session, the viewer or an import wrote, all still land on your next request.
|
|
15
15
|
- **Two-concept threshold.** A free-text prompt must share at least two distinct concepts with a memory for it to be injected; keyword-length queries (one or two words) need only one. Silence on single-word coincidences is deliberate; an explicit `memory_recall` search can admit a complete authored keyword unique among its visible candidates.
|
|
16
16
|
- **Identifiers split.** `getUserAccount`, `get_user_account`, `get-user-account` and `get.user.account` are one concept to the matcher rather than four, and a memory citing `src/recall/score.ts` answers a session that typed the path ([#409](https://github.com/abogartz/opencode-self-improvement/issues/409)). Measured on the published eval: aggregate recall unchanged, wrong-memory-first at the top falls 6% → 5%. Replayed over 1,091 logged recall queries through this scorer against the live store: 92.3% of top-5 sets are identical and 97.5% keep their top row.
|
|
17
|
-
- **User-stated guidance rides ahead of relevance.** A row auto-capture tagged `user-guided` — something you said outright, like "the correct sales tax rate is 8.25%" — rides the block ahead of the lexical picks: newest-first, at most three, and `injectBudget` still bounds the whole block (`test/hint-channel.test.ts`). The channel exists because ranking cannot bridge vocabulary: a prompt about "the injected bug" shares no word with a row stating a tax rate, and the shipped matcher scored it zero ([#334](https://github.com/abogartz/opencode-self-improvement/issues/334)). `memory_recall` and the contextual pull stay query-driven — the channel changes only what rides the prompt. Because always-riding priority is a poisoning amplifier, the tag is minted by auto-capture alone: `memory_remember`, `memory_update` replacements and JSONL imports strip it, along with the contradiction fields ([#342](https://github.com/abogartz/opencode-self-improvement/issues/342), `test/guidance-provenance.test.ts`).
|
|
18
|
-
- **The block re-scores at every user turn.** An epoch is not frozen at the first request: a later prompt re-scores, and the epoch MOVES only when the rendered bytes move — a prompt change that selects the same rows in the same order costs no cache bust ([#340](https://github.com/abogartz/opencode-self-improvement/issues/340), `test/epoch.test.ts`). Order is part of those bytes on this build: the lexical picks render in score order, so a prompt that keeps the same rows and re-ranks them moves the bytes and pays the bust. Canonical render order, which removes that churn, is still open ([#388](https://github.com/abogartz/opencode-self-improvement/issues/388), [#396](https://github.com/abogartz/opencode-self-improvement/pull/396)).
|
|
17
|
+
- **User-stated guidance rides ahead of relevance.** A row auto-capture tagged `user-guided` — something you said outright, like "the correct sales tax rate is 8.25%" — rides the block ahead of the lexical picks: newest-first, at most three, and `injectBudget` still bounds the whole block (`test/inject/hint-channel.test.ts`). The channel exists because ranking cannot bridge vocabulary: a prompt about "the injected bug" shares no word with a row stating a tax rate, and the shipped matcher scored it zero ([#334](https://github.com/abogartz/opencode-self-improvement/issues/334)). `memory_recall` and the contextual pull stay query-driven — the channel changes only what rides the prompt. Because always-riding priority is a poisoning amplifier, the tag is minted by auto-capture alone: `memory_remember`, `memory_update` replacements and JSONL imports strip it, along with the contradiction fields ([#342](https://github.com/abogartz/opencode-self-improvement/issues/342), `test/gate/guidance-provenance.test.ts`).
|
|
18
|
+
- **The block re-scores at every user turn.** An epoch is not frozen at the first request: a later prompt re-scores, and the epoch MOVES only when the rendered bytes move — a prompt change that selects the same rows in the same order costs no cache bust ([#340](https://github.com/abogartz/opencode-self-improvement/issues/340), `test/inject/epoch.test.ts`). Order is part of those bytes on this build: the lexical picks render in score order, so a prompt that keeps the same rows and re-ranks them moves the bytes and pays the bust. Canonical render order, which removes that churn, is still open ([#388](https://github.com/abogartz/opencode-self-improvement/issues/388), [#396](https://github.com/abogartz/opencode-self-improvement/pull/396)).
|
|
19
19
|
- **Hard budgets.** Relevance block and each pull are capped at `injectBudget` characters, the frontier at `frontierBudget`, trimmed at whole-memory boundaries.
|
|
20
20
|
- **Nothing volatile on the cached prefix.** The standing digest carries no row count and no latest timestamp. Both used to ride the very front of the system prompt, so every saved memory rewrote the prefix and made the next request re-bill the whole conversation; the exact numbers now live where they are free — the footer badge, `/memory`, `memory_status`, the viewer.
|
|
21
21
|
- **Evidence is never injected**, and the standing system digest is two lines.
|
|
@@ -31,7 +31,7 @@ claim, and a provider audit reported by its author.
|
|
|
31
31
|
| C — section frozen on rendered bytes | 4 | 3 | 55258 | 2762.9 | 2856 |
|
|
32
32
|
| D — C + riding bytes (shipped) | 1 | 0 | 53500 | 2675.0 | 2675 |
|
|
33
33
|
|
|
34
|
-
The invalidation counter counts **byte-moving recomputes**: epochs whose memory-section bytes differ from the previous epoch. It is not a provider cache-miss or re-prefill count, and no status surface claims it is. All three synthetic writes change B and C's bytes; D records no change for these self-writes. Corrections, removals and writes by another session can still move D's bytes, as pinned by `test/epoch.test.ts`. The workload re-scores only when the store fingerprint moves, so its 20 prompts never re-rank one shared set — D's `0` is not evidence about the same-set re-ranking above. D also injects 12.3% fewer **characters** than the naive policy, measured over the whole section — bytes on a deterministic workload, not tokens and not a provider bill. Reproduce this deterministic byte workload:
|
|
34
|
+
The invalidation counter counts **byte-moving recomputes**: epochs whose memory-section bytes differ from the previous epoch. It is not a provider cache-miss or re-prefill count, and no status surface claims it is. All three synthetic writes change B and C's bytes; D records no change for these self-writes. Corrections, removals and writes by another session can still move D's bytes, as pinned by `test/inject/epoch.test.ts`. The workload re-scores only when the store fingerprint moves, so its 20 prompts never re-rank one shared set — D's `0` is not evidence about the same-set re-ranking above. D also injects 12.3% fewer **characters** than the naive policy, measured over the whole section — bytes on a deterministic workload, not tokens and not a provider bill. Reproduce this deterministic byte workload:
|
|
35
35
|
|
|
36
36
|
```sh
|
|
37
37
|
bun run bench
|
|
@@ -21,7 +21,7 @@ Run it when you want to know whether the suite still has teeth — after changin
|
|
|
21
21
|
|
|
22
22
|
### Bench artifacts stay out of git
|
|
23
23
|
|
|
24
|
-
Raw sweep output is regenerable measurement data, and it was the largest tracked content in the repository. It is not committed (#232). A clone carries the published summaries — `bench/RESULTS.md
|
|
24
|
+
Raw sweep output is regenerable measurement data, and it was the largest tracked content in the repository. It is not committed (#232). A clone carries the published summaries — `bench/RESULTS.md` and the `bench/*-results.md` files — and the inputs those summaries are rebuilt from. History is not rewritten: the old blobs stay in earlier revisions, so this shrinks new checkouts, not the archive.
|
|
25
25
|
|
|
26
26
|
| Artifact | How to get it back |
|
|
27
27
|
| --- | --- |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-self-improvement",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.2",
|
|
4
4
|
"description": "Durable memory for opencode: remember facts, decisions, and commands across sessions, plus a one-command per-repo setup (/repo-init).",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"bench:recall": "bun bench/runners/recall-quality.ts",
|
|
68
68
|
"bench:write": "bun bench/runners/write-latency.ts",
|
|
69
69
|
"bench:availability": "bun bench/runners/availability-policy-compare.ts",
|
|
70
|
+
"bench:dedup": "bun bench/runners/dedup-live-replay.ts",
|
|
70
71
|
"sweep:test": "bun scripts/test-sweep.ts",
|
|
71
72
|
"memory-view": "bun run src/viewer/server.ts",
|
|
72
73
|
"format": "biome format --write",
|
package/src/capture/runtime.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
RESTATABLE_TAG,
|
|
10
10
|
USER_GUIDED_TAG,
|
|
11
11
|
} from "../core/tags.ts";
|
|
12
|
-
import { record, recordCaptureLag } from "../telemetry/record.ts";
|
|
13
12
|
import { type GateContext, runWriteGate } from "../gate/gate.ts";
|
|
14
13
|
import { captureSessionID } from "../identity/host-events.ts";
|
|
15
14
|
import { bindSessionProvisional, writeTarget } from "../identity/repokey.ts";
|
|
@@ -23,6 +22,7 @@ import {
|
|
|
23
22
|
import { quarantineCandidate } from "../store/quarantine/quarantine.ts";
|
|
24
23
|
import { flattenMemoryText } from "../store/sanitize.ts";
|
|
25
24
|
import { redactSecrets } from "../store/secrets.ts";
|
|
25
|
+
import { record, recordCaptureLag } from "../telemetry/record.ts";
|
|
26
26
|
import { type AvailabilityIndex, availabilityIndex } from "./available.ts";
|
|
27
27
|
import { parseCandidates, parseModelRef } from "./candidates.ts";
|
|
28
28
|
import { claimVerdictFromContent } from "./checked.ts";
|
|
@@ -154,7 +154,7 @@ export function resetCaptureCooldowns(): void {
|
|
|
154
154
|
// ---- capture trigger vocabulary -------------------------------------
|
|
155
155
|
// Single source of truth for capture subscriptions. Both turn-end events were
|
|
156
156
|
// observed on the desktop service (test/fixtures/host-events.jsonl).
|
|
157
|
-
// test/event-fidelity.test.ts requires every trigger to appear in both that
|
|
157
|
+
// test/identity/event-fidelity.test.ts requires every trigger to appear in both that
|
|
158
158
|
// recording and the installed @opencode/schema manifest: a declared event
|
|
159
159
|
// alone is insufficient evidence that the host emits it.
|
|
160
160
|
// Identity triggers have a separate observed check in that test, combining
|
package/src/recall/dedupe.ts
CHANGED
|
@@ -173,9 +173,11 @@ function sameDroppedChunks(a: Memory, b: Memory): boolean {
|
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* A row's own tokens: built DIRECTLY from the content and keyword fields.
|
|
176
|
-
* Never from `haystack()` — the identifier tokenizer splits a
|
|
177
|
-
*
|
|
178
|
-
*
|
|
176
|
+
* Never from `haystack()` — the identifier tokenizer splits a multi-word scope
|
|
177
|
+
* into its parts, and those parts stand in for content. Any delimiter does it:
|
|
178
|
+
* `auth_token_refresh_policy` and `auth-token-refresh-policy` both yield
|
|
179
|
+
* auth/token/refresh/policy, so a store holding no underscore is not exempt.
|
|
180
|
+
* Deleting only the whole scope/type strings leaves those words standing in
|
|
179
181
|
* for content: two unrelated non-Latin rows in one scope then share a
|
|
180
182
|
* Jaccard-1 metadata vocabulary, clear MIN_CONTENT on scope tokens alone,
|
|
181
183
|
* and dedup hides one.
|
package/src/store/lock.ts
CHANGED
|
@@ -49,10 +49,11 @@
|
|
|
49
49
|
// serialise. That is a deliberate cut, not an oversight — the lock is the
|
|
50
50
|
// correctness mechanism for the whole store, so a silently unserialised store
|
|
51
51
|
// on a share was the worse option.
|
|
52
|
+
|
|
53
|
+
import { Database } from "bun:sqlite";
|
|
52
54
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
53
55
|
import { chmod, unlink } from "node:fs/promises";
|
|
54
56
|
import { basename, dirname, join } from "node:path";
|
|
55
|
-
import { Database } from "bun:sqlite";
|
|
56
57
|
import { ensureDir } from "../core/logfmt/publish.ts";
|
|
57
58
|
import { record } from "../telemetry/record.ts";
|
|
58
59
|
|
|
@@ -245,7 +246,7 @@ process.on("exit", closeAllLockDatabases);
|
|
|
245
246
|
* It has to be an async-context set, not a Map keyed by lock. A Map is
|
|
246
247
|
* process-wide, so a task that merely happens to run while an UNRELATED task
|
|
247
248
|
* holds a lock reads "already held" and writes with no lock at all — measured:
|
|
248
|
-
* the sibling-holder test in test/lock-narrowing.test.ts resolved instead of
|
|
249
|
+
* the sibling-holder test in test/store/lock-narrowing.test.ts resolved instead of
|
|
249
250
|
* refusing, which is silent data loss and worse than the bug this module fixes.
|
|
250
251
|
* AsyncLocalStorage scopes the set to the chain that acquired it, so a nested
|
|
251
252
|
* call inherits and a sibling does not. Verified on Bun 1.4.3 across deep await
|
|
@@ -268,7 +269,7 @@ const heldLocks = new AsyncLocalStorage<ReadonlySet<string>>();
|
|
|
268
269
|
* made the one situation this lock is supposed to survive — a wait that names
|
|
269
270
|
* itself an extension of busy — fatal: a writer got "store lock unavailable:
|
|
270
271
|
* database is locked" instead of waiting the few hundred microseconds the other
|
|
271
|
-
* side needs. Measured on test/scenarios-consistency.test.ts, which kills
|
|
272
|
+
* side needs. Measured on test/host/scenarios-consistency.test.ts, which kills
|
|
272
273
|
* racers mid-write.
|
|
273
274
|
*
|
|
274
275
|
* SQLITE_BUSY is 5 and every extension is 5 | (kind << 8), so the low byte is
|
|
@@ -289,7 +290,7 @@ function contention(err: unknown): boolean {
|
|
|
289
290
|
* SQLite detects the case exactly: SQLITE_IOERR_VNODE is reported when the inode
|
|
290
291
|
* behind an open handle changes. It is reachable without a defect — the store
|
|
291
292
|
* directory is not ours to protect. A user can wipe and rebuild a memory root
|
|
292
|
-
* while a session is alive, and test/hits.test.ts does it on purpose. The right
|
|
293
|
+
* while a session is alive, and test/telemetry/hits.test.ts does it on purpose. The right
|
|
293
294
|
* answer is to throw the stale connection away and open a fresh one, which is
|
|
294
295
|
* what a handle against a replaced file needs; the wrong answer is to wait, and
|
|
295
296
|
* the other wrong answer is to keep the poisoned connection and fail every later
|
|
@@ -307,7 +308,7 @@ function staleHandle(err: unknown): boolean {
|
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
/**
|
|
310
|
-
* The classifier above, exposed for its pin in test/lock.test.ts.
|
|
311
|
+
* The classifier above, exposed for its pin in test/store/lock.test.ts.
|
|
311
312
|
*
|
|
312
313
|
* Getting this one line wrong is what made a crashed holder fatal, and the
|
|
313
314
|
* integration test for it is probabilistic: whether a second opener arrives
|
|
@@ -315,7 +316,7 @@ function staleHandle(err: unknown): boolean {
|
|
|
315
316
|
* itself is not probabilistic, so it gets a table.
|
|
316
317
|
*/
|
|
317
318
|
export const isLockContention = contention;
|
|
318
|
-
/** Test seam for the stale-handle classification in test/lock.test.ts. */
|
|
319
|
+
/** Test seam for the stale-handle classification in test/store/lock.test.ts. */
|
|
319
320
|
export const isStaleLockHandle = staleHandle;
|
|
320
321
|
|
|
321
322
|
/**
|
package/src/tools/schema.ts
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
// that is what the 4-gate pipeline is for.
|
|
15
15
|
// * Store reads deliberately do NOT use zod: they get a plain ISO-instant
|
|
16
16
|
// check in memory.ts (row identity), where the row schema lives.
|
|
17
|
-
import {
|
|
17
|
+
import { type ZodTypeAny, z } from "zod";
|
|
18
18
|
import { STATUSES, TYPES } from "../core/types.ts";
|
|
19
|
-
import { flattenMemoryText } from "../store/sanitize.ts";
|
|
20
19
|
import { MAX_KEYWORDS } from "../store/model/memory.ts";
|
|
20
|
+
import { flattenMemoryText } from "../store/sanitize.ts";
|
|
21
21
|
|
|
22
22
|
type JSONSchema = Record<string, unknown>;
|
|
23
23
|
|
|
@@ -265,7 +265,7 @@ export const RestoreEntryBody = z.object({
|
|
|
265
265
|
|
|
266
266
|
/**
|
|
267
267
|
* Generate the host-facing JSON Schema. Matches the pre-zod hand-written
|
|
268
|
-
* builders byte-for-byte modulo key order (test/boundaries.test.ts pins all
|
|
268
|
+
* builders byte-for-byte modulo key order (test/tools/boundaries.test.ts pins all
|
|
269
269
|
* 13 against a capture from main): $schema stripped, empty `required` kept.
|
|
270
270
|
*/
|
|
271
271
|
export function wire(schema: ZodTypeAny): JSONSchema {
|
package/src/viewer/page.html
CHANGED
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
</div>
|
|
148
148
|
|
|
149
149
|
<script id="viewer-helpers">
|
|
150
|
-
// Pure render helpers — DOM-free by contract so test/viewer.test.ts can eval
|
|
150
|
+
// Pure render helpers — DOM-free by contract so test/viewer/viewer.test.ts can eval
|
|
151
151
|
// THIS block standalone and assert the shipped escaping. Keep it
|
|
152
152
|
// free of document/window references.
|
|
153
153
|
// Store values are untrusted by principle, not just by policy: ts and
|