@cortexkit/opencode-magic-context 0.49.23 → 0.49.24
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 +0 -26
- package/dist/agents/permissions.d.ts +8 -3
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/auto-search-worker.js +4 -4
- package/dist/chunk-embedding-write-worker.js +4 -4
- package/dist/{compartment-chunk-embedding-he60aaa2.js → compartment-chunk-embedding-eypvn607.js} +3 -3
- package/dist/{conflict-warning-hook-2r32hyx6.js → conflict-warning-hook-a27bhggg.js} +4 -4
- package/dist/{context-j7hp43a0.js → context-tvrjhnmj.js} +17 -17
- package/dist/{embedding-backfill-dtke6tck.js → embedding-backfill-vddgmem3.js} +5 -5
- package/dist/features/magic-context/dreamer/primer-seed.d.ts.map +1 -1
- package/dist/hooks/magic-context/ask-answer-notice.d.ts +25 -0
- package/dist/hooks/magic-context/ask-answer-notice.d.ts.map +1 -0
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts +8 -0
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-raw.d.ts +10 -0
- package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
- package/dist/{index-syaazvy2.js → index-21bkd3m6.js} +5 -5
- package/dist/{index-1gtfne2c.js → index-2haxh8h3.js} +1 -1
- package/dist/{index-m32esgmj.js → index-3d5wnkq7.js} +1 -1
- package/dist/{index-j32jj2t8.js → index-57jf5ztp.js} +3 -3
- package/dist/{index-11gzxvf4.js → index-6g7tyb6e.js} +39 -34
- package/dist/{index-jmq8kfe7.js → index-7516anfj.js} +4 -4
- package/dist/{index-jfem3dgz.js → index-7tdtpqrg.js} +5 -1
- package/dist/{index-1kbznkft.js → index-8e9qsnrw.js} +7 -7
- package/dist/{index-ksq50rg0.js → index-c9zrgcnt.js} +1 -1
- package/dist/{index-y76rhsnr.js → index-dds7cxhz.js} +44 -25
- package/dist/{index-66eby7hx.js → index-jcr6pe7z.js} +1 -1
- package/dist/{index-ffzhwfzy.js → index-jd0y50w3.js} +3 -3
- package/dist/{index-a9zvn5fe.js → index-jrjr58ez.js} +2 -2
- package/dist/{index-mnnkgq0q.js → index-p6evxfcc.js} +3 -3
- package/dist/{index-x6cbrv9h.js → index-szf8r0ba.js} +1 -1
- package/dist/{index-mnhcdfxg.js → index-t1zk694n.js} +78 -6
- package/dist/{index-rxqr723x.js → index-t6j3qxnd.js} +1 -1
- package/dist/{index-zy67whjr.js → index-z05n7702.js} +1 -1
- package/dist/{index-3svaejkh.js → index-z928hmnp.js} +1 -1
- package/dist/index.js +31 -31
- package/dist/{message-fts-rowid-map-e79b7b6x.js → message-fts-rowid-map-9e1getgs.js} +2 -2
- package/dist/{message-index-4q8ek2fc.js → message-index-1sgzev6c.js} +6 -6
- package/dist/{message-index-bounded-rydsg9r5.js → message-index-bounded-k8pgrxad.js} +6 -6
- package/dist/migration-worker.js +3 -3
- package/dist/{project-embedding-registry-hn529988.js → project-embedding-registry-rstzmb60.js} +4 -4
- package/dist/raw-ordinal-warmup-worker.js +6 -6
- package/dist/{read-session-chunk-t039f0m5.js → read-session-chunk-q9z6s48t.js} +3 -3
- package/dist/{read-session-raw-aw6jgvwg.js → read-session-raw-s4amywnh.js} +3 -1
- package/dist/{recomp-orchestrator-hbm53jj5.js → recomp-orchestrator-hr8ddk8z.js} +13 -13
- package/dist/{search-hea079d7.js → search-3zjjmc60.js} +10 -10
- package/dist/{search-archive-weh164mh.js → search-archive-c00etw7k.js} +4 -4
- package/dist/{send-session-notification-gqzkz7da.js → send-session-notification-ygj4mja0.js} +3 -3
- package/dist/shared/slow-test.d.ts +7 -0
- package/dist/shared/slow-test.d.ts.map +1 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/parameter-descriptions.d.ts +6 -6
- package/dist/tools/parameter-descriptions.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-0b04tm1p.js → transform-postprocess-phase-rredw6bz.js} +13 -13
- package/dist/v2/auto-search-worker.js +4 -4
- package/dist/v2/chunk-embedding-write-worker.js +4 -4
- package/dist/v2/{compartment-chunk-embedding-8jjmcgeg.js → compartment-chunk-embedding-tk6g4q80.js} +3 -3
- package/dist/v2/{context-ea3x7smm.js → context-zbydzq4g.js} +37 -32
- package/dist/v2/{embedding-backfill-5e74ae0m.js → embedding-backfill-w5qp7t28.js} +5 -5
- package/dist/v2/{message-fts-rowid-map-n8fdg2ja.js → message-fts-rowid-map-pqk3a55v.js} +2 -2
- package/dist/v2/{message-index-qz9wdp82.js → message-index-5gnnn64b.js} +5 -5
- package/dist/v2/{message-index-bounded-8rcd7qq9.js → message-index-bounded-a9xa8wsq.js} +5 -5
- package/dist/v2/migration-worker.js +3 -3
- package/dist/v2/{project-embedding-registry-v38q4xd5.js → project-embedding-registry-e7zftfvj.js} +4 -4
- package/dist/v2/raw-ordinal-warmup-worker.js +6 -6
- package/dist/v2/{read-session-chunk-wazfyxcg.js → read-session-chunk-qqvda7zv.js} +2 -2
- package/dist/v2/{read-session-raw-b70cpwzj.js → read-session-raw-ppjxnqk4.js} +3 -1
- package/dist/v2/{recomp-orchestrator-b12zaptj.js → recomp-orchestrator-nmt9y25j.js} +10 -10
- package/dist/v2/{search-hza9x72a.js → search-6dawx2gt.js} +9 -9
- package/dist/v2/{search-archive-x64rtz1z.js → search-archive-dhqj1w31.js} +3 -3
- package/dist/v2/{send-session-notification-8eqe259v.js → send-session-notification-f8scq6ae.js} +1 -1
- package/dist/v2/{server-132h8twc.js → server-16dpnz56.js} +2 -2
- package/dist/v2/{server-qteg2kt9.js → server-8j2e7t31.js} +1 -1
- package/dist/v2/{server-33nqbqkw.js → server-9e55n4wx.js} +5 -5
- package/dist/v2/{server-d48x3m4x.js → server-9xbbaekh.js} +1 -1
- package/dist/v2/{server-m4bfaevz.js → server-gwmshgx9.js} +77 -5
- package/dist/v2/{server-ppcd1qxh.js → server-mefps930.js} +3 -3
- package/dist/v2/{server-62g58aaz.js → server-pw21ypwb.js} +1 -1
- package/dist/v2/{server-ad18djzs.js → server-q5z0gag0.js} +1 -1
- package/dist/v2/{server-zg5y109h.js → server-r209n2fk.js} +39 -21
- package/dist/v2/{server-4kjmrjn4.js → server-swvhxhxz.js} +5 -1
- package/dist/v2/{server-dtp8hcjh.js → server-wxrdher8.js} +1 -1
- package/dist/v2/{server-j8h7bsca.js → server-y9ncq4ck.js} +2 -2
- package/dist/v2/server.js +5 -5
- package/dist/v2/{wrapup-orchestrator-3ssd5yy1.js → wrapup-orchestrator-9z81xj66.js} +10 -10
- package/dist/{wrapup-orchestrator-5vpcd1zx.js → wrapup-orchestrator-dbnb530w.js} +14 -14
- package/package.json +4 -4
- package/src/agents/permissions.ts +22 -6
- package/src/agents/smart-notes-dreamer-gate.golden.json +241 -241
- package/src/agents/smart-notes-on.golden.json +4 -4
- package/src/config/compaction-accessor-guard.test.ts +0 -5
- package/src/config/removed-config-keys.test.ts +12 -26
- package/src/shared/announcement.test.ts +55 -59
- package/src/shared/prompt-surface-a1-golden.md +6 -7
- package/src/shared/slow-test.ts +24 -0
- package/src/shared/stable-json-linear.test.ts +18 -10
- package/src/config/latch-permanence-guard.test.ts +0 -258
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
3
|
-
import { dirname, join, relative } from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
|
|
6
|
-
const REPOSITORY_ROOT = join(dirname(fileURLToPath(import.meta.url)), "../../../..");
|
|
7
|
-
const SOURCE_ROOTS = ["packages/plugin/src", "packages/pi-plugin/src"] as const;
|
|
8
|
-
|
|
9
|
-
type Classification = "VERDICT" | "DIAGNOSTIC" | "PUBLICATION";
|
|
10
|
-
|
|
11
|
-
type KnownSlot = {
|
|
12
|
-
classification: Classification;
|
|
13
|
-
reason: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Every module-level mutable slot whose name says it can retain a capability,
|
|
18
|
-
* absence, or failure verdict. A new matching slot must be classified here so
|
|
19
|
-
* a negative cache cannot quietly become permanent.
|
|
20
|
-
*/
|
|
21
|
-
const KNOWN_SLOTS: Record<string, KnownSlot> = {
|
|
22
|
-
"packages/plugin/src/features/magic-context/compaction-marker-candidates.ts:exitRegistered": {
|
|
23
|
-
classification: "PUBLICATION",
|
|
24
|
-
reason: "Records that the process-exit handler stopping marker candidate workers is installed; it stores no candidate, absence or failure verdict.",
|
|
25
|
-
},
|
|
26
|
-
"packages/pi-plugin/src/index.ts:databaseExitHookRegistered": {
|
|
27
|
-
classification: "PUBLICATION",
|
|
28
|
-
reason: "Correct: records that the one process-exit handler closing the shared database is installed, so /reload doesn't register a second one; it holds no failure or absence verdict.",
|
|
29
|
-
},
|
|
30
|
-
"packages/plugin/src/features/magic-context/compartment-chunk-embedding.ts:cachedCoverageWindows":
|
|
31
|
-
{
|
|
32
|
-
classification: "VERDICT",
|
|
33
|
-
reason: "Bounded LRU keyed by compartment id, canonical transcript content hash, chunker version, embedding model and token budget; a content or identity change cannot reuse a prior classification.",
|
|
34
|
-
},
|
|
35
|
-
"packages/plugin/src/features/magic-context/compaction-marker.ts:cachedSchemaCompatible": {
|
|
36
|
-
classification: "VERDICT",
|
|
37
|
-
reason: "DEFECT: a transient PRAGMA/read failure is cached as incompatible until the writable DB is closed.",
|
|
38
|
-
},
|
|
39
|
-
"packages/plugin/src/features/magic-context/memory/embedding-local.ts:nativeRuntimeMissing": {
|
|
40
|
-
classification: "VERDICT",
|
|
41
|
-
reason: "Correct: a missing or unloadable native binding needs an install repair, which this process cannot observe.",
|
|
42
|
-
},
|
|
43
|
-
"packages/plugin/src/features/magic-context/memory/embedding-local.ts:localEmbeddingProcessFailure":
|
|
44
|
-
{
|
|
45
|
-
classification: "DIAGNOSTIC",
|
|
46
|
-
reason: "Most-recent local runtime diagnostic: successful initialization and test reset both clear it; the separate runtime-mode slot owns the process verdict.",
|
|
47
|
-
},
|
|
48
|
-
"packages/plugin/src/features/magic-context/memory/embedding-synapse.ts:sharedClientPromise": {
|
|
49
|
-
classification: "VERDICT",
|
|
50
|
-
reason: "DEFECT: a rejected connection promise remains shared after the daemon recovers.",
|
|
51
|
-
},
|
|
52
|
-
"packages/plugin/src/features/magic-context/memory/embedding-synapse.ts:permanentFailure": {
|
|
53
|
-
classification: "VERDICT",
|
|
54
|
-
reason: "DEFECT: a daemon catalog or response classification can be repaired in-process, but the provider then returns null without another probe.",
|
|
55
|
-
},
|
|
56
|
-
"packages/plugin/src/features/magic-context/memory/embedding-openai.ts:failureTimes": {
|
|
57
|
-
classification: "VERDICT",
|
|
58
|
-
reason: "Correct: circuit state expires and a half-open probe re-evaluates the endpoint.",
|
|
59
|
-
},
|
|
60
|
-
"packages/plugin/src/hooks/magic-context/raw-ordinal-warmup.ts:exitHookRegistered": {
|
|
61
|
-
classification: "PUBLICATION",
|
|
62
|
-
reason: "Correct: records that the one process-exit handler stopping canonical-ordinal warm-up workers is installed; it holds no failure or absence verdict.",
|
|
63
|
-
},
|
|
64
|
-
"packages/plugin/src/features/magic-context/memory/project-identity.ts:homeProjectPermission": {
|
|
65
|
-
classification: "VERDICT",
|
|
66
|
-
reason: "Boot config publishes the home-project permission; the setter replaces it on another host initialization, while explicit resolution arguments override it.",
|
|
67
|
-
},
|
|
68
|
-
"packages/plugin/src/features/magic-context/memory/project-identity.ts:directoryFallbackCache":
|
|
69
|
-
{
|
|
70
|
-
classification: "VERDICT",
|
|
71
|
-
reason: "Saved: each read checks for a newly-created .git directory and deletes the fallback before resolving again.",
|
|
72
|
-
},
|
|
73
|
-
"packages/plugin/src/features/magic-context/memory/project-identity.ts:transientFailureCooldown":
|
|
74
|
-
{
|
|
75
|
-
classification: "VERDICT",
|
|
76
|
-
reason: "Saved: getActiveCooldown deletes an expired entry and forces a new git probe after five minutes.",
|
|
77
|
-
},
|
|
78
|
-
"packages/plugin/src/features/magic-context/message-index.ts:MESSAGE_HISTORY_ORPHAN_UNAVAILABLE_REPROBE_MS":
|
|
79
|
-
{
|
|
80
|
-
classification: "VERDICT",
|
|
81
|
-
reason: "Saved: source_unavailable persists a future timestamp, then the normal cooldown arithmetic re-probes after one day.",
|
|
82
|
-
},
|
|
83
|
-
"packages/plugin/src/features/magic-context/mural/storage-mural-cues.ts:muralCueColumnCache": {
|
|
84
|
-
classification: "VERDICT",
|
|
85
|
-
reason: "Correct by scope: the database is fully migrated before this handle reaches cue reads, so its schema cannot gain this column during use.",
|
|
86
|
-
},
|
|
87
|
-
"packages/plugin/src/features/magic-context/mural/storage-mural-cues.ts:muralCueRejectionColumnCache":
|
|
88
|
-
{
|
|
89
|
-
classification: "VERDICT",
|
|
90
|
-
reason: "Correct by scope: the database is fully migrated before this handle reaches cue reads, so its schema cannot gain this column during use.",
|
|
91
|
-
},
|
|
92
|
-
"packages/plugin/src/features/magic-context/smart-notes/sandbox-runner.ts:asyncModulePromise": {
|
|
93
|
-
classification: "VERDICT",
|
|
94
|
-
reason: "Saved: the shared load has a ten-second deadline; timeout or rejection evicts the same cached attempt so a later check retries, and late native results cannot publish over a replacement.",
|
|
95
|
-
},
|
|
96
|
-
"packages/plugin/src/features/magic-context/smart-notes/sandbox-runner.ts:asyncModuleLoadAttempted":
|
|
97
|
-
{
|
|
98
|
-
classification: "DIAGNOSTIC",
|
|
99
|
-
reason: "Memory-stat history only: records that loading was attempted even after cache eviction; it never gates loading, retry or guest execution.",
|
|
100
|
-
},
|
|
101
|
-
"packages/plugin/src/features/magic-context/storage-meta-session.ts:sessionMetaSelectColumnsCache":
|
|
102
|
-
{
|
|
103
|
-
classification: "VERDICT",
|
|
104
|
-
reason: "Correct by scope: session_meta migration completes before the first projection is built for this database handle.",
|
|
105
|
-
},
|
|
106
|
-
"packages/plugin/src/features/magic-context/memory/storage-memory.ts:memoryImportanceColumnCache":
|
|
107
|
-
{
|
|
108
|
-
classification: "VERDICT",
|
|
109
|
-
reason: "Correct by scope: memory schema migration completes before this database handle serves memory reads.",
|
|
110
|
-
},
|
|
111
|
-
"packages/plugin/src/features/magic-context/memory/storage-memory.ts:memoryScopeColumnCache": {
|
|
112
|
-
classification: "VERDICT",
|
|
113
|
-
reason: "Correct by scope: memory schema migration completes before this database handle serves memory reads.",
|
|
114
|
-
},
|
|
115
|
-
"packages/plugin/src/features/magic-context/memory/storage-memory.ts:memoryShareableColumnCache":
|
|
116
|
-
{
|
|
117
|
-
classification: "VERDICT",
|
|
118
|
-
reason: "Correct by scope: memory schema migration completes before this database handle serves memory reads.",
|
|
119
|
-
},
|
|
120
|
-
"packages/plugin/src/features/magic-context/memory/storage-memory.ts:memoryClassifiedAtColumnCache":
|
|
121
|
-
{
|
|
122
|
-
classification: "VERDICT",
|
|
123
|
-
reason: "Correct by scope: memory schema migration completes before this database handle serves memory reads.",
|
|
124
|
-
},
|
|
125
|
-
"packages/plugin/src/hooks/magic-context/ctx-reduce-availability.ts:ctxReduceRegisteredGlobally":
|
|
126
|
-
{
|
|
127
|
-
classification: "VERDICT",
|
|
128
|
-
reason: "Correct by scope: tool registration is resolved once at plugin boot and cannot change while that instance runs.",
|
|
129
|
-
},
|
|
130
|
-
"packages/plugin/src/hooks/magic-context/ctx-reduce-availability.ts:availabilityBySession": {
|
|
131
|
-
classification: "VERDICT",
|
|
132
|
-
reason: "Correct by contract: the first persisted user message freezes that session's tool surface.",
|
|
133
|
-
},
|
|
134
|
-
"packages/plugin/src/hooks/magic-context/ctx-reduce-availability.ts:permissionDeniedBySession":
|
|
135
|
-
{
|
|
136
|
-
classification: "DIAGNOSTIC",
|
|
137
|
-
reason: "Repeatedly assigned on each cache-busting permission read; later reads replace an earlier denial.",
|
|
138
|
-
},
|
|
139
|
-
"packages/plugin/src/hooks/magic-context/read-session-formatting.ts:tokenizerLoadAttempted": {
|
|
140
|
-
classification: "VERDICT",
|
|
141
|
-
reason: "DEFECT: a failed tokenizer load permanently selects heuristic token counts even if the package becomes available.",
|
|
142
|
-
},
|
|
143
|
-
"packages/plugin/src/hooks/magic-context/module-transport.ts:stateSyncCapabilityCache": {
|
|
144
|
-
classification: "VERDICT",
|
|
145
|
-
reason: "Saved: invalidateStateSyncCapabilities runs on NEED_FULL_SYNC and connection invalidation before the next capability probe.",
|
|
146
|
-
},
|
|
147
|
-
"packages/plugin/src/plugin/conflict-warning-hook.ts:cachedDesktopStateByDir": {
|
|
148
|
-
classification: "VERDICT",
|
|
149
|
-
reason: "Correct by scope: its deciding startup-warning paths run once per plugin boot, so a later Desktop state-file write is not observed by design.",
|
|
150
|
-
},
|
|
151
|
-
"packages/plugin/src/plugin/embedding-routing.ts:synapseProbeCache": {
|
|
152
|
-
classification: "VERDICT",
|
|
153
|
-
reason: "Saved: the promise has a 60-second TTL, including rejections, and discovery is retried after expiry.",
|
|
154
|
-
},
|
|
155
|
-
"packages/plugin/src/shared/opencode-db-path.ts:lastReadFailure": {
|
|
156
|
-
classification: "DIAGNOSTIC",
|
|
157
|
-
reason: "Most-recent OpenCode DB read diagnostic: a successful open clears it, and path discovery re-probes after disappearance.",
|
|
158
|
-
},
|
|
159
|
-
"packages/plugin/src/shared/models-dev-cache.ts:authRewarmDone": {
|
|
160
|
-
classification: "VERDICT",
|
|
161
|
-
reason: "Saved: refreshModelLimitsAfterAuthOnce resets the latch when its warm fails.",
|
|
162
|
-
},
|
|
163
|
-
"packages/pi-plugin/src/dreamer/pi-session-api.ts:cachedModulePromise": {
|
|
164
|
-
classification: "VERDICT",
|
|
165
|
-
reason: "Saved: promise.catch clears the same rejected promise, allowing the next resolver call to retry.",
|
|
166
|
-
},
|
|
167
|
-
"packages/plugin/src/features/magic-context/fail-closed-block.ts:lastHookInitFailure": {
|
|
168
|
-
classification: "DIAGNOSTIC",
|
|
169
|
-
reason: "Most-recent boot diagnostic: recordHookInitFailure overwrites it and clearHookInitFailure resets it.",
|
|
170
|
-
},
|
|
171
|
-
"packages/plugin/src/hooks/magic-context/read-session-formatting.ts:tokenizerLoadPromise": {
|
|
172
|
-
classification: "PUBLICATION",
|
|
173
|
-
reason: "In-flight handle only: finally clears it after the load settles, so it cannot retain a failure verdict.",
|
|
174
|
-
},
|
|
175
|
-
"packages/plugin/src/shared/exit-abort-registry.ts:listenerRegistered": {
|
|
176
|
-
classification: "PUBLICATION",
|
|
177
|
-
reason: "One-time process exit-listener installation, not a capability or failure verdict.",
|
|
178
|
-
},
|
|
179
|
-
"packages/plugin/src/shared/storage-permissions.ts:enforcePrivateStoragePermissions": {
|
|
180
|
-
classification: "VERDICT",
|
|
181
|
-
reason: "Repeatedly assigned configuration: the public setter can update it during the process.",
|
|
182
|
-
},
|
|
183
|
-
"packages/plugin/src/features/magic-context/storage-db.ts:lastSchemaFenceRejection": {
|
|
184
|
-
classification: "DIAGNOSTIC",
|
|
185
|
-
reason: "Most-recent diagnostic: every open attempt clears or overwrites it.",
|
|
186
|
-
},
|
|
187
|
-
"packages/plugin/src/features/magic-context/storage-db.ts:lastMigrationOnOpenRefusal": {
|
|
188
|
-
classification: "DIAGNOSTIC",
|
|
189
|
-
reason: "Most-recent diagnostic: every open attempt clears or overwrites it.",
|
|
190
|
-
},
|
|
191
|
-
"packages/pi-plugin/src/pi-append-compaction.ts:loggedIncompatibleHost": {
|
|
192
|
-
classification: "DIAGNOSTIC",
|
|
193
|
-
reason: "Log-once flag for the incompatible-host error line only: the binding and getEntry checks run again on every adaptPiAppendCompaction call, so a host that becomes compatible gets markers without a restart.",
|
|
194
|
-
},
|
|
195
|
-
"packages/plugin/src/shared/models-dev-cache.ts:apiCache": {
|
|
196
|
-
classification: "PUBLICATION",
|
|
197
|
-
reason: "Publishes last-known-good model metadata, not a failure verdict; refresh writes a later successful value.",
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
function sourceFiles(directory: string): string[] {
|
|
202
|
-
const files: string[] = [];
|
|
203
|
-
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
204
|
-
const path = join(directory, entry.name);
|
|
205
|
-
if (entry.isDirectory()) {
|
|
206
|
-
// Package fixture harnesses are excluded from production compilation.
|
|
207
|
-
if (entry.name !== "__tests__") files.push(...sourceFiles(path));
|
|
208
|
-
} else if (entry.isFile() && path.endsWith(".ts") && !path.endsWith(".test.ts")) {
|
|
209
|
-
files.push(path);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return files;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function declaredOneShotSlots(source: string): string[] {
|
|
216
|
-
// `let` is deliberate: this targets mutable module state, not constant lookup
|
|
217
|
-
// tables or prepared-statement handles. The initializer restriction excludes
|
|
218
|
-
// ordinary counters and per-call scratch values.
|
|
219
|
-
const declarations =
|
|
220
|
-
/^(?:export\s+)?let\s+([A-Za-z_$][\w$]*)\b[^\n]*(?:=\s*(?:null|false|true)|Promise<)/gm;
|
|
221
|
-
const verdictName =
|
|
222
|
-
/(?:attempted|availability|compatible|cooldown|disabled|failed|failure|latch|missing|permission|promise|registered|unavailable)/i;
|
|
223
|
-
const moduleSlots = [...source.matchAll(declarations)].map((match) => match[1]);
|
|
224
|
-
// A provider-local permanent failure has the same operational effect as a
|
|
225
|
-
// module slot: every later provider call short-circuits without re-probing.
|
|
226
|
-
const providerLatches = [
|
|
227
|
-
...source.matchAll(/^\s*private\s+(permanentFailure)\s*=\s*false;/gm),
|
|
228
|
-
].map((match) => match[1]);
|
|
229
|
-
return [...moduleSlots, ...providerLatches].filter(
|
|
230
|
-
(name): name is string => name !== undefined && verdictName.test(name),
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
describe("latch permanence classification guard", () => {
|
|
235
|
-
test("classifies every production one-shot verdict-shaped slot", () => {
|
|
236
|
-
const inlineTestBlocks: string[] = [];
|
|
237
|
-
const discovered = new Set<string>();
|
|
238
|
-
for (const root of SOURCE_ROOTS) {
|
|
239
|
-
for (const file of sourceFiles(join(REPOSITORY_ROOT, root))) {
|
|
240
|
-
const source = readFileSync(file, "utf8");
|
|
241
|
-
if (/from\s+["']bun:test["']/.test(source)) {
|
|
242
|
-
inlineTestBlocks.push(relative(REPOSITORY_ROOT, file));
|
|
243
|
-
}
|
|
244
|
-
for (const slot of declaredOneShotSlots(source)) {
|
|
245
|
-
discovered.add(`${relative(REPOSITORY_ROOT, file)}:${slot}`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
expect(inlineTestBlocks).toEqual([]);
|
|
251
|
-
const unclassified = [...discovered].filter((slot) => !(slot in KNOWN_SLOTS)).sort();
|
|
252
|
-
expect(
|
|
253
|
-
unclassified,
|
|
254
|
-
`Classify each new one-shot verdict-shaped slot in KNOWN_SLOTS: ${unclassified.join(", ")}`,
|
|
255
|
-
).toEqual([]);
|
|
256
|
-
expect(Object.keys(KNOWN_SLOTS).length).toBeGreaterThan(0);
|
|
257
|
-
});
|
|
258
|
-
});
|