@llblab/pi-kit 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/BACKLOG.md +2 -2
  2. package/CHANGELOG.md +5 -0
  3. package/README.md +4 -4
  4. package/node_modules/@llblab/pi-state-flow/AGENTS.md +1 -1
  5. package/node_modules/@llblab/pi-state-flow/BACKLOG.md +12 -5
  6. package/node_modules/@llblab/pi-state-flow/CHANGELOG.md +9 -0
  7. package/node_modules/@llblab/pi-state-flow/README.md +116 -34
  8. package/node_modules/@llblab/pi-state-flow/dist/lib/acquisition.d.ts +24 -1
  9. package/node_modules/@llblab/pi-state-flow/dist/lib/acquisition.js +80 -1
  10. package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.d.ts +17 -0
  11. package/node_modules/@llblab/pi-state-flow/dist/lib/compaction.js +40 -0
  12. package/node_modules/@llblab/pi-state-flow/dist/lib/extension.js +149 -298
  13. package/node_modules/@llblab/pi-state-flow/dist/lib/git.d.ts +29 -0
  14. package/node_modules/@llblab/pi-state-flow/dist/lib/git.js +58 -0
  15. package/node_modules/@llblab/pi-state-flow/dist/lib/operation.d.ts +37 -0
  16. package/node_modules/@llblab/pi-state-flow/dist/lib/operation.js +59 -0
  17. package/node_modules/@llblab/pi-state-flow/dist/lib/ownership.d.ts +31 -0
  18. package/node_modules/@llblab/pi-state-flow/dist/lib/ownership.js +117 -0
  19. package/node_modules/@llblab/pi-state-flow/dist/lib/protocol.js +7 -7
  20. package/node_modules/@llblab/pi-state-flow/dist/lib/query.js +1 -1
  21. package/node_modules/@llblab/pi-state-flow/dist/lib/status.d.ts +2 -0
  22. package/node_modules/@llblab/pi-state-flow/dist/lib/status.js +28 -0
  23. package/node_modules/@llblab/pi-state-flow/dist/lib/transition.js +6 -1
  24. package/node_modules/@llblab/pi-state-flow/dist/package.json +1 -1
  25. package/node_modules/@llblab/pi-state-flow/dist/skills/state-flow-guide/SKILL.md +14 -6
  26. package/node_modules/@llblab/pi-state-flow/dist/skills/state-flow-memory/SKILL.md +2 -2
  27. package/node_modules/@llblab/pi-state-flow/docs/README.md +19 -9
  28. package/node_modules/@llblab/pi-state-flow/docs/agent-contract-relocation.md +4 -4
  29. package/node_modules/@llblab/pi-state-flow/docs/architecture.md +644 -91
  30. package/node_modules/@llblab/pi-state-flow/docs/compatibility.md +116 -37
  31. package/node_modules/@llblab/pi-state-flow/docs/filesystem-recovery.md +118 -21
  32. package/node_modules/@llblab/pi-state-flow/docs/fork-contract.md +68 -8
  33. package/node_modules/@llblab/pi-state-flow/docs/lazy-state.md +88 -14
  34. package/node_modules/@llblab/pi-state-flow/docs/performance.md +83 -66
  35. package/node_modules/@llblab/pi-state-flow/docs/temporal-acceptance.md +391 -62
  36. package/node_modules/@llblab/pi-state-flow/docs/usage.md +317 -62
  37. package/node_modules/@llblab/pi-state-flow/lib/acquisition.ts +85 -1
  38. package/node_modules/@llblab/pi-state-flow/lib/compaction.ts +47 -0
  39. package/node_modules/@llblab/pi-state-flow/lib/extension.ts +161 -295
  40. package/node_modules/@llblab/pi-state-flow/lib/git.ts +63 -0
  41. package/node_modules/@llblab/pi-state-flow/lib/operation.ts +75 -0
  42. package/node_modules/@llblab/pi-state-flow/lib/ownership.ts +120 -0
  43. package/node_modules/@llblab/pi-state-flow/lib/protocol.ts +7 -8
  44. package/node_modules/@llblab/pi-state-flow/lib/query.ts +1 -1
  45. package/node_modules/@llblab/pi-state-flow/lib/runtime.ts +1 -1
  46. package/node_modules/@llblab/pi-state-flow/lib/snapshot.ts +1 -2
  47. package/node_modules/@llblab/pi-state-flow/lib/status.ts +29 -0
  48. package/node_modules/@llblab/pi-state-flow/lib/transition.ts +5 -1
  49. package/node_modules/@llblab/pi-state-flow/package.json +1 -1
  50. package/node_modules/@llblab/pi-state-flow/skills/state-flow-guide/SKILL.md +14 -6
  51. package/node_modules/@llblab/pi-state-flow/skills/state-flow-memory/SKILL.md +2 -2
  52. package/node_modules/@llblab/pi-telegram/BACKLOG.md +1 -0
  53. package/node_modules/@llblab/pi-telegram/CHANGELOG.md +10 -0
  54. package/node_modules/@llblab/pi-telegram/README.md +1 -1
  55. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.d.ts +4 -1
  56. package/node_modules/@llblab/pi-telegram/dist/lib/bindings.js +16 -12
  57. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.d.ts +1 -1
  58. package/node_modules/@llblab/pi-telegram/dist/lib/bus-follower.js +7 -1
  59. package/node_modules/@llblab/pi-telegram/dist/lib/commands.d.ts +12 -3
  60. package/node_modules/@llblab/pi-telegram/dist/lib/commands.js +137 -83
  61. package/node_modules/@llblab/pi-telegram/dist/lib/extension.js +26 -0
  62. package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.d.ts +57 -2
  63. package/node_modules/@llblab/pi-telegram/dist/lib/lifecycle.js +109 -4
  64. package/node_modules/@llblab/pi-telegram/dist/lib/model.js +2 -4
  65. package/node_modules/@llblab/pi-telegram/dist/lib/status.d.ts +3 -1
  66. package/node_modules/@llblab/pi-telegram/dist/lib/status.js +31 -1
  67. package/node_modules/@llblab/pi-telegram/dist/lib/sync.js +4 -4
  68. package/node_modules/@llblab/pi-telegram/dist/lib/threads.d.ts +1 -0
  69. package/node_modules/@llblab/pi-telegram/dist/lib/threads.js +17 -4
  70. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.d.ts +2 -2
  71. package/node_modules/@llblab/pi-telegram/dist/lib/workspace-retirement.js +48 -12
  72. package/node_modules/@llblab/pi-telegram/dist/package.json +1 -1
  73. package/node_modules/@llblab/pi-telegram/docs/architecture.md +6 -5
  74. package/node_modules/@llblab/pi-telegram/docs/multi-instance-bus.md +2 -0
  75. package/node_modules/@llblab/pi-telegram/docs/public-api.md +2 -2
  76. package/node_modules/@llblab/pi-telegram/docs/ui-style.md +4 -0
  77. package/node_modules/@llblab/pi-telegram/lib/bindings.ts +17 -10
  78. package/node_modules/@llblab/pi-telegram/lib/bus-follower.ts +8 -2
  79. package/node_modules/@llblab/pi-telegram/lib/commands.ts +135 -97
  80. package/node_modules/@llblab/pi-telegram/lib/extension.ts +25 -0
  81. package/node_modules/@llblab/pi-telegram/lib/lifecycle.ts +140 -4
  82. package/node_modules/@llblab/pi-telegram/lib/model.ts +2 -4
  83. package/node_modules/@llblab/pi-telegram/lib/status.ts +30 -1
  84. package/node_modules/@llblab/pi-telegram/lib/sync.ts +4 -4
  85. package/node_modules/@llblab/pi-telegram/lib/threads.ts +21 -3
  86. package/node_modules/@llblab/pi-telegram/lib/workspace-retirement.ts +46 -13
  87. package/node_modules/@llblab/pi-telegram/package.json +1 -1
  88. package/package.json +3 -3
@@ -10,3 +10,32 @@ export declare function pushCurrentStateFlowBackup(repositoryRoot: string, signa
10
10
  remote: string;
11
11
  ref: string;
12
12
  } | undefined>;
13
+ /**
14
+ * Settled-turn backup obligation owned by one extension instance: an accepted
15
+ * publication makes a backup due, an accepted turn permits it at settlement,
16
+ * and one lifetime cancels owned captures/pushes without touching accepted state.
17
+ */
18
+ export declare class SettledTurnBackup {
19
+ #private;
20
+ /** An accepted canonical publication makes the next settled-turn backup due. */
21
+ markPublished(): void;
22
+ /** An accepted turn permits the due backup at its settlement. */
23
+ markTurnAccepted(): void;
24
+ /** Forget the current turn's permission without dropping a due backup. */
25
+ clearTurn(): void;
26
+ /** Consume the accepted-turn permission; true only when a backup is also due. */
27
+ takeSettledTurn(): boolean;
28
+ /** Lifetime signal for owned captures and pushes. */
29
+ get lifetime(): AbortSignal;
30
+ /** Cancel owned work and the due backup, then open a fresh lifetime. */
31
+ cancel(): void;
32
+ /** Cancel owned work for shutdown without opening a new lifetime. */
33
+ abort(): void;
34
+ /** Track one owned capture until it settles. */
35
+ track<T>(operation: Promise<T>): Promise<T>;
36
+ /** Owned captures still in flight. */
37
+ get operations(): Promise<unknown>[];
38
+ /** True once per failure streak; a successful push resets it. */
39
+ claimPushFailureNotice(): boolean;
40
+ resetPushFailureNotice(): void;
41
+ }
@@ -310,3 +310,61 @@ export function pushCurrentStateFlowBackup(repositoryRoot, signal) {
310
310
  cancelled();
311
311
  });
312
312
  }
313
+ /**
314
+ * Settled-turn backup obligation owned by one extension instance: an accepted
315
+ * publication makes a backup due, an accepted turn permits it at settlement,
316
+ * and one lifetime cancels owned captures/pushes without touching accepted state.
317
+ */
318
+ export class SettledTurnBackup {
319
+ #turnAccepted = false;
320
+ #pending = false;
321
+ #lifetime = new AbortController();
322
+ #pushFailureNotified = false;
323
+ #operations = new Set();
324
+ /** An accepted canonical publication makes the next settled-turn backup due. */
325
+ markPublished() { this.#pending = true; }
326
+ /** An accepted turn permits the due backup at its settlement. */
327
+ markTurnAccepted() { this.#turnAccepted = true; }
328
+ /** Forget the current turn's permission without dropping a due backup. */
329
+ clearTurn() { this.#turnAccepted = false; }
330
+ /** Consume the accepted-turn permission; true only when a backup is also due. */
331
+ takeSettledTurn() {
332
+ if (!this.#turnAccepted)
333
+ return false;
334
+ this.#turnAccepted = false;
335
+ if (!this.#pending)
336
+ return false;
337
+ this.#pending = false;
338
+ return true;
339
+ }
340
+ /** Lifetime signal for owned captures and pushes. */
341
+ get lifetime() { return this.#lifetime.signal; }
342
+ /** Cancel owned work and the due backup, then open a fresh lifetime. */
343
+ cancel() {
344
+ this.#lifetime.abort();
345
+ this.#lifetime = new AbortController();
346
+ this.#pending = false;
347
+ }
348
+ /** Cancel owned work for shutdown without opening a new lifetime. */
349
+ abort() { this.#lifetime.abort(); }
350
+ /** Track one owned capture until it settles. */
351
+ async track(operation) {
352
+ this.#operations.add(operation);
353
+ try {
354
+ return await operation;
355
+ }
356
+ finally {
357
+ this.#operations.delete(operation);
358
+ }
359
+ }
360
+ /** Owned captures still in flight. */
361
+ get operations() { return [...this.#operations]; }
362
+ /** True once per failure streak; a successful push resets it. */
363
+ claimPushFailureNotice() {
364
+ if (this.#pushFailureNotified)
365
+ return false;
366
+ this.#pushFailureNotified = true;
367
+ return true;
368
+ }
369
+ resetPushFailureNotice() { this.#pushFailureNotified = false; }
370
+ }
@@ -0,0 +1,37 @@
1
+ /** Minimal shape of a cancellable owned lifecycle operation. */
2
+ export interface OwnedOperation {
3
+ readonly controller: AbortController;
4
+ operation?: Promise<unknown>;
5
+ }
6
+ /**
7
+ * At most one current owner per lifecycle concern. A newer claim supersedes by
8
+ * explicit cancellation, and identity-guarded release prevents a late
9
+ * completion from clearing newer work.
10
+ */
11
+ export declare class OwnedOperationSlot<E extends OwnedOperation> {
12
+ #private;
13
+ /** The current owner, if any. */
14
+ get current(): E | undefined;
15
+ /** True while `entry` still owns the slot. */
16
+ owns(entry: E): boolean;
17
+ /** Install a new owner; callers cancel a previous owner explicitly when supersession requires it. */
18
+ claim(entry: E): E;
19
+ /** Abort and forget the current owner; returns its operation for optional awaiting. */
20
+ cancel(): E["operation"] | undefined;
21
+ /** Forget `entry` only if it still owns the slot. */
22
+ release(entry: E): void;
23
+ /** Attach `operation` to `entry` and remember it until it settles, optionally releasing ownership then. */
24
+ track<P extends NonNullable<E["operation"]>>(entry: E, operation: P, releaseOnSettle?: boolean): P;
25
+ /** Tracked operations not yet settled, including superseded ones. */
26
+ get inflight(): Promise<unknown>[];
27
+ }
28
+ /** A renewable cancellation lifetime: ending it aborts every holder of the current signal. */
29
+ export declare class RenewableLifetime {
30
+ #private;
31
+ /** Signal of the current lifetime. */
32
+ get signal(): AbortSignal;
33
+ /** Abort current holders and open a fresh lifetime. */
34
+ renew(reason?: unknown): void;
35
+ /** Abort current holders without opening a new lifetime (shutdown). */
36
+ end(reason?: unknown): void;
37
+ }
@@ -0,0 +1,59 @@
1
+ // Domain: one cancellable lifecycle owner slot shared by Start, inactive-mode persistence,
2
+ // branch restoration, inference preparation and response reconciliation.
3
+ /**
4
+ * At most one current owner per lifecycle concern. A newer claim supersedes by
5
+ * explicit cancellation, and identity-guarded release prevents a late
6
+ * completion from clearing newer work.
7
+ */
8
+ export class OwnedOperationSlot {
9
+ #current;
10
+ #inflight = new Set();
11
+ /** The current owner, if any. */
12
+ get current() { return this.#current; }
13
+ /** True while `entry` still owns the slot. */
14
+ owns(entry) { return this.#current === entry; }
15
+ /** Install a new owner; callers cancel a previous owner explicitly when supersession requires it. */
16
+ claim(entry) {
17
+ this.#current = entry;
18
+ return entry;
19
+ }
20
+ /** Abort and forget the current owner; returns its operation for optional awaiting. */
21
+ cancel() {
22
+ const entry = this.#current;
23
+ entry?.controller.abort();
24
+ this.#current = undefined;
25
+ return entry?.operation;
26
+ }
27
+ /** Forget `entry` only if it still owns the slot. */
28
+ release(entry) {
29
+ if (this.#current === entry)
30
+ this.#current = undefined;
31
+ }
32
+ /** Attach `operation` to `entry` and remember it until it settles, optionally releasing ownership then. */
33
+ track(entry, operation, releaseOnSettle = true) {
34
+ entry.operation = operation;
35
+ this.#inflight.add(operation);
36
+ const settle = () => {
37
+ this.#inflight.delete(operation);
38
+ if (releaseOnSettle)
39
+ this.release(entry);
40
+ };
41
+ void operation.then(settle, settle);
42
+ return operation;
43
+ }
44
+ /** Tracked operations not yet settled, including superseded ones. */
45
+ get inflight() { return [...this.#inflight]; }
46
+ }
47
+ /** A renewable cancellation lifetime: ending it aborts every holder of the current signal. */
48
+ export class RenewableLifetime {
49
+ #controller = new AbortController();
50
+ /** Signal of the current lifetime. */
51
+ get signal() { return this.#controller.signal; }
52
+ /** Abort current holders and open a fresh lifetime. */
53
+ renew(reason) {
54
+ this.#controller.abort(reason);
55
+ this.#controller = new AbortController();
56
+ }
57
+ /** Abort current holders without opening a new lifetime (shutdown). */
58
+ end(reason) { this.#controller.abort(reason); }
59
+ }
@@ -0,0 +1,31 @@
1
+ import { type JsonObject, type JsonValue } from "./json.ts";
2
+ import type { SemanticState, StateScope } from "./state.ts";
3
+ /** Planes whose object keys an intent may own by structured reference. */
4
+ export type OwnedPlane = "working" | "lazy";
5
+ /** One same-scope object-key target of an intent ownership reference. */
6
+ export interface OwnedPath {
7
+ plane: OwnedPlane;
8
+ keys: string[];
9
+ }
10
+ /**
11
+ * Parse one structured `$ref` target as an ownership path of `scope`.
12
+ * Cross-scope, unscoped, `effective`, historical, plane-root, array-element
13
+ * and non-`working`/`lazy` targets are not ownership targets.
14
+ */
15
+ export declare function parseOwnedPath(scope: StateScope, ref: string): OwnedPath | undefined;
16
+ /** Extract unique ownership targets from structured references anywhere inside one intent value. */
17
+ export declare function extractOwnedPaths(scope: StateScope, value: JsonValue): OwnedPath[];
18
+ /**
19
+ * Compute the same-scope ownership cascade for intent keys removed between
20
+ * `before` and `after` (the state after authored operations). A target is
21
+ * kept while any remaining intent references it, an ancestor or a descendant;
22
+ * missing targets are skipped. The result is minimal (no target below
23
+ * another) and deterministically ordered.
24
+ */
25
+ export declare function computeIntentCascade(scope: StateScope, before: SemanticState, after: SemanticState): OwnedPath[];
26
+ /** Express cascade targets as explicit nested object-key deletions. */
27
+ export declare function cascadeDeletionPatch(paths: readonly OwnedPath[]): JsonObject;
28
+ /** Render an ownership target as its scoped `read_state` path. */
29
+ export declare function formatOwnedPath(scope: StateScope, path: OwnedPath): string;
30
+ /** Top-level `working`/`lazy` keys that at least one current intent of `scope` owns. */
31
+ export declare function ownedTopLevelKeys(scope: StateScope, state: SemanticState): Record<OwnedPlane, Set<string>>;
@@ -0,0 +1,117 @@
1
+ import { isObject } from "./json.js";
2
+ const OWNED_PLANES = new Set(["working", "lazy"]);
3
+ // Same key grammar as read_state value paths; array selectors never parse.
4
+ const OBJECT_KEY = /^[A-Za-z_$][A-Za-z0-9_$-]*$/;
5
+ /**
6
+ * Parse one structured `$ref` target as an ownership path of `scope`.
7
+ * Cross-scope, unscoped, `effective`, historical, plane-root, array-element
8
+ * and non-`working`/`lazy` targets are not ownership targets.
9
+ */
10
+ export function parseOwnedPath(scope, ref) {
11
+ const parts = ref.split(".");
12
+ if (parts.length < 3 || parts[0] !== scope || !OWNED_PLANES.has(parts[1]))
13
+ return undefined;
14
+ const keys = parts.slice(2);
15
+ if (!keys.every((key) => OBJECT_KEY.test(key)))
16
+ return undefined;
17
+ return { plane: parts[1], keys };
18
+ }
19
+ function pathId(path) {
20
+ return JSON.stringify([path.plane, ...path.keys]);
21
+ }
22
+ /** Extract unique ownership targets from structured references anywhere inside one intent value. */
23
+ export function extractOwnedPaths(scope, value) {
24
+ const found = new Map();
25
+ const visit = (node) => {
26
+ if (Array.isArray(node)) {
27
+ for (const item of node)
28
+ visit(item);
29
+ return;
30
+ }
31
+ if (!isObject(node))
32
+ return;
33
+ if (typeof node.$ref === "string") {
34
+ const path = parseOwnedPath(scope, node.$ref);
35
+ if (path)
36
+ found.set(pathId(path), path);
37
+ }
38
+ for (const key of Object.keys(node))
39
+ if (key !== "$ref" || typeof node[key] !== "string")
40
+ visit(node[key]);
41
+ };
42
+ visit(value);
43
+ return [...found.values()];
44
+ }
45
+ function related(left, right) {
46
+ if (left.plane !== right.plane)
47
+ return false;
48
+ const length = Math.min(left.keys.length, right.keys.length);
49
+ for (let index = 0; index < length; index++)
50
+ if (left.keys[index] !== right.keys[index])
51
+ return false;
52
+ return true;
53
+ }
54
+ function exists(state, path) {
55
+ let node = state[path.plane];
56
+ for (const key of path.keys) {
57
+ if (!isObject(node) || !Object.hasOwn(node, key))
58
+ return false;
59
+ node = node[key];
60
+ }
61
+ return true;
62
+ }
63
+ /**
64
+ * Compute the same-scope ownership cascade for intent keys removed between
65
+ * `before` and `after` (the state after authored operations). A target is
66
+ * kept while any remaining intent references it, an ancestor or a descendant;
67
+ * missing targets are skipped. The result is minimal (no target below
68
+ * another) and deterministically ordered.
69
+ */
70
+ export function computeIntentCascade(scope, before, after) {
71
+ const previous = isObject(before.intents) ? before.intents : {};
72
+ const remaining = isObject(after.intents) ? after.intents : {};
73
+ const deleted = Object.keys(previous).filter((key) => !Object.hasOwn(remaining, key));
74
+ if (deleted.length === 0)
75
+ return [];
76
+ const candidates = new Map();
77
+ for (const key of deleted)
78
+ for (const path of extractOwnedPaths(scope, previous[key]))
79
+ candidates.set(pathId(path), path);
80
+ if (candidates.size === 0)
81
+ return [];
82
+ const retained = Object.values(remaining).flatMap((value) => extractOwnedPaths(scope, value));
83
+ const owned = [...candidates.values()].filter((path) => !retained.some((other) => related(path, other)) && exists(after, path));
84
+ return owned
85
+ .filter((path) => !owned.some((other) => other.keys.length < path.keys.length && related(path, other)))
86
+ .sort((left, right) => pathId(left).localeCompare(pathId(right)));
87
+ }
88
+ /** Express cascade targets as explicit nested object-key deletions. */
89
+ export function cascadeDeletionPatch(paths) {
90
+ const patch = {};
91
+ const define = (target, key, value) => Object.defineProperty(target, key, { value, enumerable: true, configurable: true, writable: true });
92
+ for (const path of paths) {
93
+ if (!Object.hasOwn(patch, path.plane))
94
+ define(patch, path.plane, {});
95
+ let node = patch[path.plane];
96
+ for (const key of path.keys.slice(0, -1)) {
97
+ if (!Object.hasOwn(node, key))
98
+ define(node, key, {});
99
+ node = node[key];
100
+ }
101
+ define(node, path.keys.at(-1), null);
102
+ }
103
+ return patch;
104
+ }
105
+ /** Render an ownership target as its scoped `read_state` path. */
106
+ export function formatOwnedPath(scope, path) {
107
+ return [scope, path.plane, ...path.keys].join(".");
108
+ }
109
+ /** Top-level `working`/`lazy` keys that at least one current intent of `scope` owns. */
110
+ export function ownedTopLevelKeys(scope, state) {
111
+ const owned = { working: new Set(), lazy: new Set() };
112
+ const intents = isObject(state.intents) ? state.intents : {};
113
+ for (const value of Object.values(intents))
114
+ for (const path of extractOwnedPaths(scope, value))
115
+ owned[path.plane].add(path.keys[0]);
116
+ return owned;
117
+ }
@@ -84,24 +84,24 @@ export function stateFlowProtocol(bootstrap) {
84
84
  return `State Flow is enabled. It owns durable memory.
85
85
 
86
86
  ${bootstrapProtocol}STATE:
87
- - intents: chosen active commitments; detail may stay lazy; remove when fulfilled, abandoned, superseded, or impossible.
88
- - contract: durable requirements, decisions, rejections, interfaces, compiled knowledge.
89
- - working: facts, validation, failures, domain state, unresolved work, continuation.
87
+ - intents: queue of chosen actions; work from them; remove when fulfilled, abandoned, superseded, or impossible.
88
+ - contract: durable requirements, decisions, rejections, interfaces.
89
+ - working: temporary context of intents: facts, validation, failures, domain state.
90
90
  - artifacts: source-path routing metadata; descriptions do not imply body acquisition.
91
- - response: previous answer; runtime stores the exact accepted answer at turn_end (empty=""). Ordinary assistant completion needs no finalization patch.
91
+ - response: previous answer; runtime stores the exact accepted answer at turn_end (empty="").
92
92
  - lazy: retrieve explicitly.
93
93
 
94
94
  SCOPES: Use the narrowest scope: session=branch/run continuation by default; cwd=reusable project truth; global=established cross-project/user/environment knowledge.
95
95
 
96
- READ: Use read_state for concrete scope/retained-history gaps. lazy_navigation lists bounded effective lazy keys, not bodies. Unscoped=effective; effective/global/cwd/session select overlay or owner. Arrays use indices or [start..end]; keys gives structure, patch the intersected change. ${TASK_DRIVEN_HISTORY}
96
+ READ: Use read_state for concrete scope/retained-history gaps. lazy_navigation lists bounded effective lazy keys, not bodies. ${TASK_DRIVEN_HISTORY}
97
97
 
98
- WRITE: patch_state is the sole model-authored semantic mutation mechanism; all supplied scopes are validated and durably accepted as one atomic transition. Call alone in an assistant response; await acceptance. Global/CWD use current canonical values after cancelable lock waiting. Correct repeats succeed without new revisions. ${PATCH_RESULT_PROTOCOL}
98
+ WRITE: patch_state is the sole model-authored semantic mutation mechanism; all supplied scopes are validated and durably accepted as one atomic transition. Global/CWD use current canonical values after cancelable lock waiting. Correct repeats succeed without new revisions. ${PATCH_RESULT_PROTOCOL}
99
99
 
100
100
  PATCH: Use global/cwd/session object patches for material updates, not acknowledgments. Omit empty scopes. artifacts/contract/working/intents are objects; lazy is ordinary JSON. Omitted fields persist. Never patch runtime config/meta/response. Objects merge recursively; arrays/primitives replace. An object containing only canonical "[N]" keys recursively patches array elements. Indexed deletion is forbidden; nested object null deletes; materialized null is forbidden.
101
101
 
102
102
  MEMORY: Treat every patch as reconciliation rather than append-only notes: merge superseded fragments, remove obsolete progress. Preserve commitments, open questions, consequential results and exact continuation; distinguish requirements, decisions, observations, conclusions and hypotheses. Exclude secrets, raw history, transient progress, speculation and unsupported claims; retain decision-relevant uncertainty. Curate touched state; cleanup and scope reviews require an explicit user request. Proven moves use targeted read_state and one atomic multi-scope patch, then verify both owners. External transfers need verified acceptance before deletion. Never invent memory changes.
103
103
 
104
- REFS: State refs use {"$ref":"cwd.lazy.plan"} or \`$cwd.lazy.plan\` in text. Resolve only when needed; infer no authority, hydration, execution, or completion. Hint paths are current reference owners, not relocated targets or proof of staleness. Fix proven stale refs only as needed; never scan refs or history offsets.
104
+ REFS: State refs use {"$ref":"cwd.lazy.plan"} or \`$cwd.lazy.plan\` in text. In an intent, $ref owns a same-scope working/lazy key; deleting the intent deletes keys no other intent refs (supersede in one patch). Text refs only use. Before deleting, save survivors unowned: results to working/contract/broader scope, abandonment reasons to contract. Unowned entries are fine. Resolve only when needed; infer no authority, hydration, execution, or completion. Hint paths are current reference owners, not relocated targets or proof of staleness. Fix proven stale refs only as needed; never scan refs or history offsets.
105
105
 
106
106
  ACQUISITION: Read only for a concrete gap, exact source/edit, invalidation, contradiction/failure, or explicit request; changed source fingerprints require rereading.
107
107
  ARTIFACTS: Compile acquired invalidated artifacts at artifacts[exact path] in the reported scope (global/cwd/session), with a description; never relocate or invent global copies. Runtime owns all artifact/Skill provenance.
@@ -67,7 +67,7 @@ function parseValuePath(path) {
67
67
  rest = rest.slice(index[0].length);
68
68
  continue;
69
69
  }
70
- throw new Error("Invalid State Flow read path selector");
70
+ throw new Error("Invalid State Flow read path selector; object keys must match [A-Za-z_$][A-Za-z0-9_$-]* (ASCII), array selectors use [N] or [start..end]");
71
71
  }
72
72
  return { root, selectors };
73
73
  }
@@ -32,4 +32,6 @@ export interface StatusDiagnostics {
32
32
  }
33
33
  export declare function formatScopeRevisionVector(revisions: ScopeRevisions): string;
34
34
  export declare function compactStatus(snapshot: Snapshot, _revisions: ScopeRevisions, colorize: Colorize): string | undefined;
35
+ /** Operator-only footprint: serialized plane sizes and intent-owned share of top-level working/lazy entries. */
36
+ export declare function scopeMemoryLines(states: ScopedStates): string[];
35
37
  export declare function detailedStatus(snapshot: Snapshot, diagnostics: StatusDiagnostics): string;
@@ -1,3 +1,4 @@
1
+ import { ownedTopLevelKeys } from "./ownership.js";
1
2
  import { conciseDiagnostic } from "./protocol.js";
2
3
  import { overlayStates, projectSemanticState } from "./state.js";
3
4
  export const STATUS_KEY = "state-flow";
@@ -13,6 +14,32 @@ export function compactStatus(snapshot, _revisions, colorize) {
13
14
  function countArtifacts(states, scope) {
14
15
  return Object.keys(states[scope].artifacts).length;
15
16
  }
17
+ const STATUS_PLANES = ["intents", "contract", "working", "artifacts", "response", "lazy"];
18
+ const encoder = new TextEncoder();
19
+ function isPresentPlane(value) {
20
+ if (value === undefined || value === "")
21
+ return false;
22
+ return typeof value !== "object" || value === null || Object.keys(value).length > 0;
23
+ }
24
+ /** Operator-only footprint: serialized plane sizes and intent-owned share of top-level working/lazy entries. */
25
+ export function scopeMemoryLines(states) {
26
+ const lines = [];
27
+ for (const scope of ["global", "cwd", "session"]) {
28
+ const state = states[scope];
29
+ const sizes = STATUS_PLANES.filter((plane) => isPresentPlane(state[plane]))
30
+ .map((plane) => `${plane} ${encoder.encode(JSON.stringify(state[plane])).length} B`);
31
+ if (sizes.length === 0)
32
+ continue;
33
+ const owned = ownedTopLevelKeys(scope, state);
34
+ const shares = ["working", "lazy"].flatMap((plane) => {
35
+ const value = state[plane];
36
+ const keys = value !== null && typeof value === "object" && !Array.isArray(value) ? Object.keys(value) : [];
37
+ return keys.length === 0 ? [] : [`${plane} ${keys.filter((key) => owned[plane].has(key)).length}/${keys.length}`];
38
+ });
39
+ lines.push(`- ${scope}: ${sizes.join(", ")}${shares.length ? `; intent-owned ${shares.join(", ")}` : ""}`);
40
+ }
41
+ return lines.length ? ["Scope memory:", ...lines] : [];
42
+ }
16
43
  export function detailedStatus(snapshot, diagnostics) {
17
44
  const available = diagnostics.temporal !== undefined && diagnostics.durableStateError === undefined;
18
45
  const materialized = !available ? undefined : diagnostics.effectiveState ?? projectSemanticState(overlayStates(diagnostics.scopeStates.global, diagnostics.scopeStates.cwd, diagnostics.scopeStates.session));
@@ -41,6 +68,7 @@ export function detailedStatus(snapshot, diagnostics) {
41
68
  ...(diagnostics.publicationError === undefined ? [] : [`Memory writes paused after mode change: ${conciseDiagnostic(diagnostics.publicationError)}`]),
42
69
  ...(hasArtifacts ? [`Artifacts: global ${artifacts("global")}; CWD ${artifacts("cwd")}; session ${artifacts("session")}; pending invalidations ${invalidated}`] : []),
43
70
  ...invalidationLines,
71
+ ...(available ? scopeMemoryLines(diagnostics.scopeStates) : []),
44
72
  ...(stateJson === undefined
45
73
  ? ["Effective memory: unavailable"]
46
74
  : ["Effective memory:", "", stateJson]),
@@ -1,6 +1,7 @@
1
1
  import { compileArtifact, ORDINARY_ARTIFACT_COMPILER, validateArtifactMetadata, validateArtifactRegistry, validateModelArtifactPatch, } from "./artifact.js";
2
2
  import { createAcceptedTransition } from "./history.js";
3
3
  import { applyPatch, containsNull, hashJson, isObject, validatePatch } from "./json.js";
4
+ import { cascadeDeletionPatch, computeIntentCascade } from "./ownership.js";
4
5
  import { hasCompiledSkillArtifact, SKILL_ARTIFACT_COMPILER } from "./skills.js";
5
6
  import { emptyState } from "./state.js";
6
7
  const SCOPES = new Set(["global", "cwd", "session"]);
@@ -138,7 +139,11 @@ function stageScopedSemanticTransition(currentStates, transition, successfulSkil
138
139
  for (const scope of SCOPES) {
139
140
  const authored = patches.get(scope) ?? {};
140
141
  const patch = { ...authored, ...(scope === "session" && acceptedResponse !== undefined ? { response: acceptedResponse } : {}) };
141
- const materialized = applyPatch({ ...emptyState(), ...currentStates[scope] }, patch);
142
+ let materialized = applyPatch({ ...emptyState(), ...currentStates[scope] }, patch);
143
+ // Authored operations first, then the same-scope intent ownership cascade.
144
+ const cascade = computeIntentCascade(scope, currentStates[scope], materialized);
145
+ if (cascade.length > 0)
146
+ materialized = applyPatch(materialized, cascadeDeletionPatch(cascade));
142
147
  compileReadArtifacts(materialized, { artifacts: authored.artifacts ?? {} }, artifactReads.filter((read) => (read.scope ?? "global") === scope), provenanceUpdates[scope]);
143
148
  compileReadSkills(scope, materialized, { artifacts: authored.artifacts ?? {} }, skillReads.filter((read) => read.scope === scope), provenanceUpdates[scope]);
144
149
  validateMaterializedTransition(materialized, scope);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llblab/pi-state-flow",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "description": "Incremental scoped state/context/memory compiler for Pi, inspired by SKILL.state",
@@ -21,9 +21,9 @@ Operator commands: `/state-flow-status` inspects; `/state-flow-active` selects s
21
21
 
22
22
  | Field | Purpose |
23
23
  | --- | --- |
24
- | `intents` | Chosen future actions, not possibilities |
25
- | `contract` | Requirements, decisions, constraints, interfaces |
26
- | `working` | Observations, results, open questions, continuation |
24
+ | `intents` | Queue of chosen actions, not possibilities; may own `working`/`lazy` keys |
25
+ | `contract` | Requirements, decisions, rejections, constraints, interfaces |
26
+ | `working` | Temporary context of intents: observations, results, open questions |
27
27
  | `artifacts` | Exact source paths, descriptions, compilations |
28
28
  | `response` | Previous completed answer; runtime-owned |
29
29
  | `lazy` | Durable detail omitted from ordinary context |
@@ -46,7 +46,7 @@ Example arguments:
46
46
  {"paths":["cwd.working","session.working"]}
47
47
  ```
48
48
 
49
- Unscoped paths use effective state. `cwd[1].working` reads the preceding causal boundary. Materialized-history and scope patch-history paths such as `cwd.patches[1]` share the configured `historyLimit` bound (default 7) and require actually retained history. Lowering the limit folds excess tails without erasing current state; increasing it does not reconstruct discarded history. Array ranges such as `cwd.lazy.checks[0..3]` exclude the endpoint and require existing elements. Missing paths are unavailable; inspect parent keys only when needed for the task. Missing history is not empty history. Read `lazy` explicitly. Treat structured `$ref` values and `$`-prefixed `read_state` paths inside ordinary strings, such as `$effective.lazy.memory[7]`, as semantic-state references. Other resources retain their native locators. Resolve any reference through the appropriate read/tool only when needed. Neither form proves authority or existence, hydrates, or executes anything. Never scan or resolve references merely to test them. A missing single value path with exact durable sources returns `{value:null, hint:[{type:"dangling-reference", message, paths}]}`. Treat `hint` as top-level diagnostic metadata, never as the requested state: its message is descriptive and conditional; its paths are runtime-verified current reference owners, not verified new locations of the target. The hint proves provenance rather than staleness and is absent when no current durable source matches; keys, patch, and batch reads keep all-or-error behavior. Only then inspect ownership as needed and patch a proven stale owning value while preserving its surrounding meaning. Effective absence, inaccessible external resources, and transient failures are not proof.
49
+ Unscoped paths use effective state. `cwd[1].working` reads the preceding causal boundary. Materialized-history and scope patch-history paths such as `cwd.patches[1]` share the configured `historyLimit` bound (default 7) and require actually retained history. Lowering the limit folds excess tails without erasing current state; increasing it does not reconstruct discarded history. Array ranges such as `cwd.lazy.checks[0..3]` exclude the endpoint and require existing elements. Missing paths are unavailable; inspect parent keys only when needed for the task. Missing history is not empty history. Read `lazy` explicitly. Treat structured `$ref` values and `$`-prefixed `read_state` paths inside ordinary strings, such as `$effective.lazy.memory[7]`, as semantic-state references. Other resources retain their native locators. Resolve any reference through the appropriate read/tool only when needed. Neither form proves authority or existence, hydrates, or executes anything; only intent ownership (see Write) has a deletion consequence. Never scan or resolve references merely to test them. A missing single value path with exact durable sources returns `{value:null, hint:[{type:"dangling-reference", message, paths}]}`. Treat `hint` as top-level diagnostic metadata, never as the requested state: its message is descriptive and conditional; its paths are runtime-verified current reference owners, not verified new locations of the target. The hint proves provenance rather than staleness and is absent when no current durable source matches; keys, patch, and batch reads keep all-or-error behavior. Only then inspect ownership as needed and patch a proven stale owning value while preserving its surrounding meaning. Effective absence, inaccessible external resources, and transient failures are not proof.
50
50
 
51
51
  Missing paths or runtime hints alone do not require historical search. The agent may choose a targeted historical read when a previous value is useful to the current task, without separate user permission. Otherwise continue without searching. Use found values as historical evidence, not automatically as current state; never automatically restore deleted memory. Do not scan all offsets, hydrate automatically or request repair inference. A hint does not prove prior existence, retained history or relocation. A proven stale reference may be repaired within touched work without resurrecting its target. Automatic state and recent-transition projections omit lazy bodies; bounded `lazy_navigation` preserves structure, and explicit current/historical reads still return requested lazy values or patches.
52
52
 
@@ -58,12 +58,20 @@ The runtime waits cancelably for publication ownership, then applies authored Gl
58
58
 
59
59
  When present, semantic planes `intents`, `contract`, `working`, `artifacts`, and `lazy` are objects; nested lazy values may contain ordinary JSON without stored nulls. Stored checkpoints and patches may omit any documented plane. Current and historical views assemble only known fields present in the selected scopes. Absent fields and empty responses are omitted from views. Checkpoint/tail readers ignore unknown top-level fields, and writers emit only known fields. Nested data within known planes remains intact. Explicit value reads of an absent documented top-level field return `null`. Authored `patch_state` keeps its documented field grammar. Objects merge, arrays/scalars replace, omitted fields persist. Nested `null` removes an owned object key; inherited content may reappear. Canonical `"[N]"` keys patch array elements; indexed deletion is forbidden.
60
60
 
61
- Illustrative deletion, only for an actually completed intent and after satisfying pending acquisitions:
61
+ Work from intents. A structured `{"$ref"}` anywhere inside an intent owns ("delete with me") an existing object key under `working` or `lazy` in the same scope; a textual `$path` mention only uses it. Opening a task:
62
62
 
63
63
  ```json
64
- {"session":{"intents":{"check_api":null}}}
64
+ {"session":{"intents":{"check_api":{"action":"Verify the API","notes":{"$ref":"session.working.api"},"plan":{"$ref":"session.lazy.api_plan"}}},"working":{"api":"draft findings"},"lazy":{"api_plan":["probe","compare"]}}}
65
65
  ```
66
66
 
67
+ Deleting the intent deletes the owned keys after the authored operations, in the same atomic patch, unless another remaining same-scope intent references the target, an ancestor or a descendant. Before closing, move what must survive to an unowned path: results to `working`, `contract` or a broader scope; reasons for abandoned work to `contract` as rejected approaches. Supersede in one patch by deleting the old intent and referencing the same targets from its replacement. Writing to an owned target in the same patch that deletes its intent does not save it: the write is deleted too. Only keys matching `[A-Za-z_$][A-Za-z0-9_$-]*` can be owned. Cross-scope, plane-root, array-element and non-`working`/`lazy` targets are never deleted, nothing is rejected or warned about, and unowned entries remain legal. Illustrative closing, only for an actually completed intent and after satisfying pending acquisitions:
68
+
69
+ ```json
70
+ {"session":{"intents":{"check_api":null},"contract":{"api":"verified: v2 only"}}}
71
+ ```
72
+
73
+ Name object keys in ASCII matching `[A-Za-z_$][A-Za-z0-9_$-]*` (for example `api_plan`, not a Cyrillic or spaced key): other keys cannot be addressed by `read_state` paths or `$` references, and cannot be owned by intents. Values may use any language.
74
+
67
75
  Never edit backing files, `response`, configuration, provenance, or runtime metadata. Verify changed owner paths when needed; check effective state after override deletion.
68
76
 
69
77
  ## Acquire and finish
@@ -20,9 +20,9 @@ Follow the installed runtime contract. This registered Skill follows its Pi sour
20
20
  ## Reconcile one bounded set
21
21
 
22
22
  1. **Limit the review.** Address the requested scope. A completed phase may motivate recommending cleanup, not starting it without a request. For a whole-state cleanup, inspect global, CWD, and session ownership explicitly; for a narrower request, inspect only affected owners. Use targeted reads for gaps, contradictions, ownership, or verification; do not rerun the project.
23
- 2. **Classify.** Put user requirements and binding confirmed decisions in `contract`, observations, assistant conclusions, and unresolved work in `working`, chosen actions in `intents`, and inactive reusable detail in `lazy`. Never give an assistant conclusion user authority. Remove fulfilled, abandoned, superseded, or impossible intents; retain consequential results. Possibilities are not commitments.
23
+ 2. **Classify.** Put user requirements and binding confirmed decisions in `contract`, the queue of chosen actions in `intents`, their temporary context (observations, assistant conclusions, results in progress) in `working`, and inactive reusable detail in `lazy`. Never give an assistant conclusion user authority. Possibilities are not commitments. Name keys in ASCII (`[A-Za-z_$][A-Za-z0-9_$-]*`) so paths, references and ownership resolve; values may use any language. Work from intents: a structured `{"$ref"}` inside an intent owns ("delete with me") a same-scope `working`/`lazy` key; a textual `$path` mention only uses it. Deleting a fulfilled, abandoned, superseded, or impossible intent deletes owned keys no remaining same-scope intent references, so first move what must survive to an unowned path (a write to an owned key in the deleting patch is deleted too): results to `working`, `contract`, or a broader scope; reasons for abandoned work to `contract` as rejected approaches. Supersede in one patch by referencing the same targets from the replacement. Unowned entries remain legal.
24
24
  3. **Keep evidence boundaries.** Preserve corrections, prerequisites, bounded negative results, and useful uncertainty. Separate requirements, decisions, observations, conclusions, and hypotheses. Silence is not acceptance; repetition is not verification. One implementation's failure does not reject an approach. Neither freeze provisional methods nor reopen confirmed decisions without grounds.
25
- 4. **Compact for continuation.** Remove duplicates, obsolete progress, unsupported claims, and secrets. Keep sufficient results, real retrieval pointers, pending interaction, and known next checks. Observations are not live external facts. Keep `lazy` shallow and priority-ordered. Recognize optional structured `$ref` values and `$`-prefixed `read_state` paths inside ordinary strings as semantic-state references; other resources retain native locators. No reference form proves authority or existence, authorizes execution, or implies completion. Never scan or resolve references merely to find broken ones. When the bounded review independently needs a reference, a missing single value path with exact durable sources returns `{value:null, hint:[{type:"dangling-reference", message, paths}]}`. Treat the top-level hint as conditional navigation and provenance, never as requested state or proof of staleness; its paths are runtime-verified current reference owners, not verified new locations of the target, while no hint does not prove invention. Inspect ownership only as needed, then patch a proven stale owning value while preserving surrounding meaning. Effective absence or external inaccessibility is insufficient.
25
+ 4. **Compact for continuation.** Remove duplicates, obsolete progress, unsupported claims, and secrets. Keep sufficient results, real retrieval pointers, pending interaction, and known next checks. Observations are not live external facts. Keep `lazy` shallow and priority-ordered. Recognize optional structured `$ref` values and `$`-prefixed `read_state` paths inside ordinary strings as semantic-state references; other resources retain native locators. No reference form proves authority or existence, authorizes execution, or implies completion; only intent ownership has a deletion consequence. Never scan or resolve references merely to find broken ones. When the bounded review independently needs a reference, a missing single value path with exact durable sources returns `{value:null, hint:[{type:"dangling-reference", message, paths}]}`. Treat the top-level hint as conditional navigation and provenance, never as requested state or proof of staleness; its paths are runtime-verified current reference owners, not verified new locations of the target, while no hint does not prove invention. Inspect ownership only as needed, then patch a proven stale owning value while preserving surrounding meaning. Effective absence or external inaccessibility is insufficient.
26
26
  5. **Check ownership.** Prefer `session` for branch/run continuation, `cwd` for project knowledge, and `global` for established cross-project knowledge. Effective values do not prove ownership; inspect owners before moves. Broader applicability requires evidence.
27
27
 
28
28
  Missing paths or runtime hints alone do not require historical search. The agent may choose a targeted historical read when a previous value is useful to the current task, without separate user permission. Otherwise continue without searching. Use found values as historical evidence, not automatically as current state; never automatically restore deleted memory. Do not scan all offsets, hydrate automatically or request repair inference. A hint does not prove prior existence, retained history or relocation. A proven stale reference may be repaired within touched work without resurrecting its target. Lazy bodies require explicit reads; automatic state/history projections retain navigation without hydrating those bodies.
@@ -1,11 +1,21 @@
1
1
  # State Flow documentation
2
2
 
3
- - [Usage and recovery](usage.md): Configuration, new/resumed sessions, Active/Passive/Off controls, diagnostics, privacy, and storage recovery.
4
- - [Architecture](architecture.md): Semantic state, temporal algebra, Pi lifecycle, storage, publication, artifacts, and embedding contracts.
5
- - [Lazy state](lazy-state.md): Implemented ordinary-JSON lazy planes, an effective-by-default `lazy` read path, pure state/patch snapshots, narrow structural `meta` + `keys`, and recursive indexed array patches.
6
- - [Filesystem recovery](filesystem-recovery.md): Cohort-wide absence, partial-presence, malformed-evidence, repair-authority, and transaction rules.
7
- - [Temporal acceptance](temporal-acceptance.md): Required temporal properties and their executable witnesses.
8
- - [SDK compatibility](compatibility.md): Tested dependency stacks, public lifecycle seams, isolated validation, and host limits.
9
- - [Physical fork contract](fork-contract.md): Session-stream copying, live shared memory, child ownership/origin, and tested support boundaries.
10
- - [Agent contract relocation ledger](agent-contract-relocation.md): Source-bound paragraph-to-owner parity map for the compact `AGENTS.md`, with transferred clauses and validation evidence.
11
- - [Session performance](performance.md): Reproducible native-Pi/stateful workloads, long-session resume measurements, two-process publication probes, and evidence limits.
3
+ Start with the [project README](../README.md) for installation and the memory model.
4
+
5
+ ## Operating State Flow
6
+
7
+ - [Usage and recovery](usage.md): Configure State Flow, choose Active/Passive/Off, inspect memory and recover from storage problems. Includes diagnostics and privacy rules.
8
+ - [Lazy state](lazy-state.md): Store ordinary JSON in `lazy` outside baseline context, read it progressively with structural `meta` + `keys`, patch array indices and understand intent ownership.
9
+ - [Filesystem recovery](filesystem-recovery.md): What to do when files are missing, incomplete or malformed; which evidence authorizes repair and what durability is promised.
10
+ - [Physical fork contract](fork-contract.md): What a child session copies, what stays live, how cancellation works and which forks are supported.
11
+
12
+ ## Integration and verification
13
+
14
+ - [Architecture](architecture.md): Semantic state, temporal history, Pi lifecycle, storage transactions, artifact acquisition and embedding APIs.
15
+ - [SDK compatibility](compatibility.md): Required packages, verified environments, host lifecycle requirements and isolated validation procedures.
16
+ - [Session performance](performance.md): Run synthetic benchmarks, interpret their metrics and understand the current cost model. No provider-cache or latency guarantees.
17
+ - [Temporal acceptance](temporal-acceptance.md): Find the tests that witness each required property, including cancellation, ownership and replay.
18
+
19
+ ## Development policy
20
+
21
+ - [Agent contract relocation ledger](agent-contract-relocation.md): Audit map from [AGENTS.md](../AGENTS.md) development instructions to their owning contracts and tests. It is provenance evidence, not a user guide or an open-work list.
@@ -1,6 +1,6 @@
1
1
  # Agent contract relocation ledger
2
2
 
3
- This is the source-bound **paragraph-to-owner parity map** for the 8,141-word pre-compaction `AGENTS.md` (SHA-256 `0d328eacc96d6b67c5eb036a51adc27e1dcd24d20bb6695f2fff6d5a3c87737b`; source lines 3–58, based on commit `70baecde` plus the Passive-footprint and `barrier-block` edits). Each `L##` identifies exactly one original bullet/paragraph. Its destination is the current owner of that paragraph's reusable contract; where necessary, a compact root rule or executable witness is also named. The root remains approximately 1,300 words; its 0.23.0 default-mode rule supersedes the original Passive-default clause. This is a reviewed documentation trace, not a claim that prose links alone prove runtime correctness.
3
+ This is the source-bound **paragraph-to-owner parity map** for the 8,141-word pre-compaction `AGENTS.md` (SHA-256 `0d328eacc96d6b67c5eb036a51adc27e1dcd24d20bb6695f2fff6d5a3c87737b`; source lines 3–58, based on commit `70baecde` plus the Passive-footprint and `barrier-block` edits). Each `L##` identifies exactly one original bullet/paragraph. Its destination is the current owner of that paragraph's reusable contract; where necessary, a compact root rule or executable witness is also named. The root remains approximately 1,300 words; its current default-mode rule (new sessions start Off) supersedes the source's Passive-default clause. This is a reviewed documentation trace, not a claim that prose links alone prove runtime correctness.
4
4
 
5
5
  ## Composition, semantics, and model access
6
6
 
@@ -35,7 +35,7 @@ This is the source-bound **paragraph-to-owner parity map** for the 8,141-word pr
35
35
  - L19 canonical layout and identity → [storage and identity](architecture.md#storage-and-identity).
36
36
  - L20 optimistic durability, optional backup and contention → [power-loss boundary](filesystem-recovery.md#power-loss-durability), [asynchronous transaction](architecture.md#asynchronous-storage-transaction), [optional Git backup](architecture.md#optional-git-backup).
37
37
  - L21 cohort classification and missing shared pairs → [recovery](usage.md#missing-partial-and-malformed-storage), [transaction rule](filesystem-recovery.md#transaction-rule).
38
- - L22 predecessor formats and no in-place migration → [format boundary](usage.md#moving-a-store-and-the-017-format-boundary), [optional Git backup](architecture.md#optional-git-backup).
38
+ - L22 predecessor formats and no in-place migration → [format boundary](usage.md#moving-a-store-and-supported-formats), [optional Git backup](architecture.md#optional-git-backup).
39
39
  - L23 exact-file CAS, awaited transaction and rollback → [asynchronous transaction](architecture.md#asynchronous-storage-transaction), [storage and identity](architecture.md#storage-and-identity), [transaction rule](filesystem-recovery.md#transaction-rule).
40
40
  - L24 initialization and exact-source fork → [Pi lifecycle](architecture.md#pi-lifecycle), [fork contract](fork-contract.md).
41
41
  - L25 retained-boundary restore, failed-Stop read-only recovery and selection races → [Pi lifecycle](architecture.md#pi-lifecycle), [mode restoration](compatibility.md#mode-selection-and-memory-restoration).
@@ -51,7 +51,7 @@ This is the source-bound **paragraph-to-owner parity map** for the 8,141-word pr
51
51
  ## Operator, agent, and development policy
52
52
 
53
53
  - L30 terminal handoff plane routing → [operational guidance](architecture.md#operational-guidance-and-memory-curation), [semantic state](architecture.md#semantic-state).
54
- - L31 consequential evidence, semantic references and dangling hints → [model tools](architecture.md#model-tools), [lazy navigation](usage.md#lazy-navigation-and-historical-reading), [memory curation](architecture.md#operational-guidance-and-memory-curation).
54
+ - L31 consequential evidence, semantic references and dangling hints → [model tools](architecture.md#model-tools), [lazy navigation](usage.md#lazy-navigation-and-historical-reading), [memory curation](architecture.md#operational-guidance-and-memory-curation). The root's intent-ownership exception to reference semantics is owned by [intent ownership](lazy-state.md#intent-ownership).
55
55
  - L32 volatile observation and external-effects revalidation → [operational boundaries](../README.md#operational-boundaries), [memory guidance](usage.md#memory-and-source-acquisition).
56
56
  - L33 registered Skill acquisition → [artifact routing](architecture.md#artifact-routing).
57
57
  - L34 bounded curation and verified transfers → [operational guidance](architecture.md#operational-guidance-and-memory-curation), [memory Skill](../skills/state-flow-memory/SKILL.md).
@@ -69,4 +69,4 @@ This is the source-bound **paragraph-to-owner parity map** for the 8,141-word pr
69
69
 
70
70
  ## Verification evidence
71
71
 
72
- The map names all 56 source paragraphs exactly once. Each was compared with its destinations; the highest-risk clause groups were checked explicitly: L06/L45 native run anchors and Stop context, L23–L26 CAS/backup/rollback, L28 receipt-elision bounds, L31 reference/epistemic limits, L36 diagnostic privacy, L47 native compaction and L50 callback revocation. An additional exact-code-token audit exposed otherwise easy-to-lose clauses: legacy `{disabled:true}`, in-memory header key derivation, materialization equality, `contract.compiled_skills` rejection, Skill compiler revision, runtime-origin null exception and normalized artifact replay. Those are now stated in architecture; terse `patches[n]` and `{value:null, hint:[...]}` from the source are represented there by the more precise scoped patch path and expanded dangling-reference sentinel. The remaining uniquely durable developer rules, including no live-store fixture edits, stay in the compact root. `tests/invariants.test.ts` is unchanged; native and domain-specific witnesses remain in their named test files. Package, context and domain-DAG validation establish the final checked boundary; they cannot substitute for semantic judgment about future models.
72
+ The map names all 56 source paragraphs exactly once. Each was compared with its destinations; the highest-risk clause groups were checked explicitly: L06/L45 native run anchors and Stop context, L23–L26 CAS/backup/rollback, L28 receipt-elision bounds, L31 reference/epistemic limits, L36 diagnostic privacy, L47 native compaction and L50 callback revocation. An additional exact-code-token audit exposed otherwise easy-to-lose clauses: legacy `{disabled:true}`, in-memory header key derivation, materialization equality, `contract.compiled_skills` rejection, Skill compiler revision, runtime-origin null exception and normalized artifact replay. Those are now stated in architecture; terse `patches[n]` and `{value:null, hint:[...]}` from the source are represented there by the more precise scoped patch path and expanded dangling-reference sentinel. The remaining uniquely durable developer rules, including no live-store fixture edits, stay in the compact root. The relocation itself changed no tests; native and domain-specific witnesses remain in their named test files. Later structural guards in `tests/invariants.test.ts` enforce composition-root ownership and do not alter this mapping. Package, context and domain-DAG validation establish the final checked boundary; they cannot substitute for semantic judgment about future models.