@lmzhen/dsh-evolution-core 0.26.26 → 0.27.1
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 +16 -1
- package/lib/composition/index.js +3 -0
- package/lib/composition-D8Y3-ROd.js +604 -0
- package/lib/ensure-MEYMj9jn.js +222 -0
- package/lib/errors-Br2-uUSK.js +57 -0
- package/lib/http-routes-BP-S3KV-.js +149 -0
- package/lib/http-routes.js +2 -0
- package/lib/index.js +66 -850
- package/lib/restrictor.js +37 -0
- package/lib/subagent/index.js +186 -0
- package/lib/types/citations.js +192 -0
- package/lib/types/{preset-composition.d.ts → composition/composer.d.ts} +1 -1
- package/lib/types/composition/composer.js +681 -0
- package/lib/types/composition/ensure.d.ts +10 -0
- package/lib/types/composition/ensure.js +95 -0
- package/lib/types/composition/index.d.ts +5 -0
- package/lib/types/composition/index.js +7 -0
- package/lib/types/composition/preset-ids.d.ts +17 -0
- package/lib/types/composition/preset-ids.js +21 -0
- package/lib/types/composition/restricted-preset.d.ts +36 -0
- package/lib/types/composition/restricted-preset.js +42 -0
- package/lib/types/constants.js +223 -0
- package/lib/types/cost.js +67 -0
- package/lib/types/curator.js +346 -0
- package/lib/types/diagnostics.d.ts +26 -0
- package/lib/types/diagnostics.js +23 -0
- package/lib/types/document-body.js +91 -0
- package/lib/types/drift-signals.js +319 -0
- package/lib/types/env.js +25 -0
- package/lib/types/errors.d.ts +4 -1
- package/lib/types/errors.js +59 -0
- package/lib/types/events.js +16 -0
- package/lib/types/evidence.js +65 -0
- package/lib/types/evolution-events.js +479 -0
- package/lib/types/fold-untrusted.js +44 -0
- package/lib/types/frontmatter.js +623 -0
- package/lib/types/fuzzy-match.js +135 -0
- package/lib/types/gates.js +51 -0
- package/lib/types/guards.js +27 -0
- package/lib/types/health-baseline.js +63 -0
- package/lib/types/http-routes.d.ts +67 -35
- package/lib/types/http-routes.js +135 -0
- package/lib/types/index.d.ts +7 -2
- package/lib/types/index.js +101 -0
- package/lib/types/instance-scope.js +69 -0
- package/lib/types/io.js +675 -0
- package/lib/types/learn-prompt.js +42 -0
- package/lib/types/limits.js +63 -0
- package/lib/types/live.js +107 -0
- package/lib/types/long-runs.js +96 -0
- package/lib/types/memory-store.d.ts +0 -16
- package/lib/types/memory-store.js +606 -0
- package/lib/types/mutations.js +95 -0
- package/lib/types/namespace-migration.js +156 -0
- package/lib/types/numeric.js +47 -0
- package/lib/types/opt-in.js +101 -0
- package/lib/types/package-identity.js +47 -0
- package/lib/types/params.js +328 -0
- package/lib/types/payload.js +36 -0
- package/lib/types/platform-line.generated.d.ts +10 -0
- package/lib/types/platform-line.generated.js +12 -0
- package/lib/types/platform-services.d.ts +2 -2
- package/lib/types/platform-services.js +52 -0
- package/lib/types/probe.js +122 -0
- package/lib/types/prompts.js +409 -0
- package/lib/types/quality.js +308 -0
- package/lib/types/reachability.js +122 -0
- package/lib/types/redact.js +257 -0
- package/lib/types/reference-rewrite.js +144 -0
- package/lib/types/reports.js +110 -0
- package/lib/types/restrictor.d.ts +11 -0
- package/lib/types/restrictor.js +48 -0
- package/lib/types/review-channel.js +59 -0
- package/lib/types/run-registry.js +345 -0
- package/lib/types/scope.js +7 -0
- package/lib/types/serial.js +17 -0
- package/lib/types/session-fold.d.ts +15 -0
- package/lib/types/session-fold.js +28 -0
- package/lib/types/session-projection.js +295 -0
- package/lib/types/signals.js +209 -0
- package/lib/types/skill-discovery.js +66 -0
- package/lib/types/skill-health.js +134 -0
- package/lib/types/skill-history.js +745 -0
- package/lib/types/skill-lint.js +112 -0
- package/lib/types/skill-reads.js +67 -0
- package/lib/types/skill-row-cells.js +123 -0
- package/lib/types/skill-store.js +3528 -0
- package/lib/types/state-store.js +60 -0
- package/lib/types/store-ledger.js +117 -0
- package/lib/types/subagent/channel.d.ts +4 -0
- package/lib/types/subagent/channel.js +131 -0
- package/lib/types/subagent/index.d.ts +4 -0
- package/lib/types/subagent/index.js +5 -0
- package/lib/types/subagent/readiness.d.ts +6 -0
- package/lib/types/subagent/readiness.js +35 -0
- package/lib/types/subagent/types.d.ts +58 -0
- package/lib/types/subagent/types.js +2 -0
- package/lib/types/threats.js +338 -0
- package/lib/types/tool-dispatch.d.ts +5 -0
- package/lib/types/tool-dispatch.js +535 -0
- package/lib/types/tree-write.js +40 -0
- package/lib/types/unit-members.js +121 -0
- package/lib/types/usage.js +474 -0
- package/lib/types/write-authority.js +23 -0
- package/lib/types/write-gates.js +344 -0
- package/lib/types/write-inventory.js +158 -0
- package/package.json +39 -11
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* B3 / G4 (0.3.78): the family's single-instance contract, made explicit.
|
|
3
|
+
*
|
|
4
|
+
* Every persisted sidecar is written under TWO assumptions: the IO backend's
|
|
5
|
+
* cross-process write lock serializes different processes, and exactly ONE
|
|
6
|
+
* instance of each writer service exists per evolution home. The second half
|
|
7
|
+
* was implicit — `makeSerialQueue()` and the module-scope stores are
|
|
8
|
+
* per-instance, so two rows writing one home interleave inside one file (the
|
|
9
|
+
* "two instances, one file" class). This module makes that half enforceable: a
|
|
10
|
+
* writer CLAIMS its key while mounted and releases it on dispose, and a second
|
|
11
|
+
* claimant is told who holds the key instead of silently racing it.
|
|
12
|
+
*
|
|
13
|
+
* The claim is keyed by the HOME, not by the process: the contended resource is
|
|
14
|
+
* the sidecar directory, so two instances resolving different homes (an
|
|
15
|
+
* isolated test fixture, a second DSH_HOME) do not contend, while two rows on
|
|
16
|
+
* one profile do.
|
|
17
|
+
*
|
|
18
|
+
* ## Scope (v43 FLOW2-1) — this registry is PER PROCESS
|
|
19
|
+
*
|
|
20
|
+
* `claims` below is a module-scope Map: two ROWS over one home in ONE process
|
|
21
|
+
* contend, while the SAME home in another process gets its own Map and is
|
|
22
|
+
* granted the key. That is by construction, not a gap to close here — the
|
|
23
|
+
* cross-process half of the contract is the IO backend's write lock
|
|
24
|
+
* (`transactIo`, core/io.ts), which serializes a per-target read-modify-write.
|
|
25
|
+
* The FLOW2-1 finding was three call sites reading a GRANTED claim as "no other
|
|
26
|
+
* process can be doing this work", so the caller contract is stated here:
|
|
27
|
+
* - granted means "no other row OF THIS PROCESS owns the key";
|
|
28
|
+
* - `instanceHolder()` answers "who holds it HERE"; `undefined` also covers
|
|
29
|
+
* "held by another process";
|
|
30
|
+
* - a foreign holder's LIVENESS cannot be decided from a claim at all (no pid
|
|
31
|
+
* is recorded here): a consumer that needs that decision must carry a pid in
|
|
32
|
+
* its own credential and probe it (`isProcessAlive`, core/io.ts), or state
|
|
33
|
+
* that its action is destructive.
|
|
34
|
+
* @module @lmzhen/dsh-evolution-core/src/instance-scope
|
|
35
|
+
*/
|
|
36
|
+
/** home+key -> holder, IN THIS PROCESS ONLY. The Map is module-scope, so two
|
|
37
|
+
* processes never share it: this half cannot exclude another process (v43
|
|
38
|
+
* FLOW2-1) — the cross-process half is the write lock, see
|
|
39
|
+
* persisted-write-inventory.json. It is still the whole point for the case it
|
|
40
|
+
* was written for: two ROWS of one process writing one home. */
|
|
41
|
+
const claims = new Map();
|
|
42
|
+
/** `<home> :: <key>` — the registry key, exported so diagnostics name the
|
|
43
|
+
* same unit the claim does. */
|
|
44
|
+
export function instanceClaimKey(home, key) {
|
|
45
|
+
return `${home} :: ${key}`;
|
|
46
|
+
}
|
|
47
|
+
/** Take the claim for `key` at `home`. Grants while it is free or already
|
|
48
|
+
* held BY `owner` — remounting the same instance is not a second instance. */
|
|
49
|
+
export function claimInstance(home, key, owner) {
|
|
50
|
+
const id = instanceClaimKey(home, key);
|
|
51
|
+
const current = claims.get(id);
|
|
52
|
+
if (current === undefined || current === owner) {
|
|
53
|
+
claims.set(id, owner);
|
|
54
|
+
return { granted: true, key: id, holder: owner };
|
|
55
|
+
}
|
|
56
|
+
return { granted: false, key: id, holder: current };
|
|
57
|
+
}
|
|
58
|
+
/** Release only the claim `owner` took — never another instance's. */
|
|
59
|
+
export function releaseInstance(home, key, owner) {
|
|
60
|
+
const id = instanceClaimKey(home, key);
|
|
61
|
+
if (claims.get(id) === owner)
|
|
62
|
+
claims.delete(id);
|
|
63
|
+
}
|
|
64
|
+
/** The current holder of `key` at `home`, IN THIS PROCESS, or undefined
|
|
65
|
+
* (which also covers "another process holds it" — v43 FLOW2-1). */
|
|
66
|
+
export function instanceHolder(home, key) {
|
|
67
|
+
return claims.get(instanceClaimKey(home, key));
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=instance-scope.js.map
|