@llblab/pi-state-flow 0.13.4 → 0.15.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.
- package/AGENTS.md +10 -10
- package/BACKLOG.md +1 -14
- package/CHANGELOG.md +19 -0
- package/README.md +9 -7
- package/dist/lib/config.d.ts +5 -2
- package/dist/lib/config.js +17 -16
- package/dist/lib/context.d.ts +8 -0
- package/dist/lib/context.js +24 -0
- package/dist/lib/continuation.js +4 -3
- package/dist/lib/durable.d.ts +2 -1
- package/dist/lib/durable.js +15 -3
- package/dist/lib/episode.d.ts +2 -0
- package/dist/lib/episode.js +4 -0
- package/dist/lib/extension.d.ts +5 -0
- package/dist/lib/extension.js +93 -35
- package/dist/lib/git.js +17 -14
- package/dist/lib/history.js +8 -4
- package/dist/lib/json.js +29 -3
- package/dist/lib/migration.d.ts +2 -2
- package/dist/lib/migration.js +55 -21
- package/dist/lib/protocol.js +18 -17
- package/dist/lib/query.d.ts +27 -1
- package/dist/lib/query.js +182 -10
- package/dist/lib/runtime.d.ts +2 -0
- package/dist/lib/runtime.js +34 -5
- package/dist/lib/snapshot.d.ts +5 -5
- package/dist/lib/snapshot.js +20 -24
- package/dist/lib/state.d.ts +11 -3
- package/dist/lib/state.js +14 -4
- package/dist/lib/status.js +1 -1
- package/dist/lib/storage.js +13 -12
- package/dist/lib/telegram.d.ts +9 -6
- package/dist/lib/telegram.js +10 -3
- package/dist/lib/transition.js +8 -3
- package/dist/package.json +1 -1
- package/dist/skills/state-flow-memory/SKILL.md +16 -6
- package/docs/README.md +1 -0
- package/docs/architecture.md +14 -10
- package/docs/filesystem-recovery.md +3 -2
- package/docs/lazy-state.md +505 -0
- package/docs/usage.md +11 -8
- package/lib/config.ts +18 -15
- package/lib/context.ts +24 -0
- package/lib/continuation.ts +4 -3
- package/lib/durable.ts +14 -5
- package/lib/episode.ts +5 -0
- package/lib/extension.ts +86 -34
- package/lib/git.ts +18 -14
- package/lib/history.ts +8 -4
- package/lib/json.ts +31 -3
- package/lib/migration.ts +51 -20
- package/lib/protocol.ts +18 -17
- package/lib/query.ts +173 -9
- package/lib/runtime.ts +32 -4
- package/lib/snapshot.ts +22 -25
- package/lib/state.ts +22 -6
- package/lib/status.ts +1 -1
- package/lib/storage.ts +14 -11
- package/lib/telegram.ts +20 -6
- package/lib/transition.ts +8 -3
- package/package.json +1 -1
- package/skills/state-flow-memory/SKILL.md +16 -6
package/lib/state.ts
CHANGED
|
@@ -5,15 +5,18 @@ import {
|
|
|
5
5
|
type ArtifactCompilationUpdate,
|
|
6
6
|
type ArtifactRegistry,
|
|
7
7
|
} from "./artifact.ts";
|
|
8
|
-
import { applyPatch, isObject, type JsonObject } from "./json.ts";
|
|
8
|
+
import { applyPatch, isJsonValue, isObject, type JsonObject, type JsonValue } from "./json.ts";
|
|
9
9
|
|
|
10
10
|
/** The canonical semantic state shape shared by global, CWD, and session scopes. */
|
|
11
|
-
export
|
|
11
|
+
export type MaterializedState = JsonObject & {
|
|
12
12
|
artifacts: ArtifactRegistry;
|
|
13
13
|
contract: JsonObject;
|
|
14
14
|
working: JsonObject;
|
|
15
|
+
intents: JsonObject;
|
|
15
16
|
response: string;
|
|
16
|
-
|
|
17
|
+
/** Absent is the canonical empty lazy plane and preserves predecessor-store compatibility. */
|
|
18
|
+
lazy?: JsonValue;
|
|
19
|
+
};
|
|
17
20
|
|
|
18
21
|
/** Compatibility name for callers that still treat materialized state as a document. */
|
|
19
22
|
export type StateDocument = MaterializedState;
|
|
@@ -23,6 +26,7 @@ export interface StatePatch extends JsonObject {
|
|
|
23
26
|
artifacts: JsonObject;
|
|
24
27
|
contract: JsonObject;
|
|
25
28
|
working: JsonObject;
|
|
29
|
+
intents: JsonObject;
|
|
26
30
|
response: string;
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -33,6 +37,8 @@ export interface ScopePatch {
|
|
|
33
37
|
artifacts?: JsonObject;
|
|
34
38
|
contract?: JsonObject;
|
|
35
39
|
working?: JsonObject;
|
|
40
|
+
intents?: JsonObject;
|
|
41
|
+
lazy?: JsonValue;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
export interface ScopedPatch {
|
|
@@ -62,7 +68,7 @@ export interface ScopedStates {
|
|
|
62
68
|
}
|
|
63
69
|
|
|
64
70
|
export function emptyState(): MaterializedState {
|
|
65
|
-
return { artifacts: {}, contract: {}, working: {}, response: "" };
|
|
71
|
+
return { artifacts: {}, contract: {}, working: {}, intents: {}, response: "" } as MaterializedState;
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
export function isMaterializedState(value: unknown): value is MaterializedState {
|
|
@@ -70,12 +76,21 @@ export function isMaterializedState(value: unknown): value is MaterializedState
|
|
|
70
76
|
&& isArtifactRegistry(value.artifacts)
|
|
71
77
|
&& isObject(value.contract)
|
|
72
78
|
&& isObject(value.working)
|
|
79
|
+
&& isObject(value.intents)
|
|
73
80
|
&& typeof value.response === "string"
|
|
74
|
-
&& Object.
|
|
81
|
+
&& (!Object.hasOwn(value, "lazy") || (isJsonValue(value.lazy) && value.lazy !== null))
|
|
82
|
+
&& Object.keys(value).every((key) => key === "artifacts" || key === "contract" || key === "working" || key === "intents" || key === "response" || key === "lazy");
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
export const isStateDocument = isMaterializedState;
|
|
78
86
|
|
|
87
|
+
/** Upgrade one exact pre-intents materialized state without inferring commitments. */
|
|
88
|
+
export function migratePreIntentState(value: unknown): MaterializedState | undefined {
|
|
89
|
+
if (!isObject(value) || Object.hasOwn(value, "intents")) return undefined;
|
|
90
|
+
const candidate = { ...structuredClone(value), intents: {} };
|
|
91
|
+
return isMaterializedState(candidate) ? candidate : undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
79
94
|
/** Atomically replace compiled and removed artifacts inside one materialized scope. */
|
|
80
95
|
export function updateMaterializedArtifacts(
|
|
81
96
|
state: MaterializedState,
|
|
@@ -96,5 +111,6 @@ export function overlayStates(...scopes: readonly MaterializedState[]): Material
|
|
|
96
111
|
|
|
97
112
|
/** Model-visible projection: runtime artifact bookkeeping never reaches ordinary context. */
|
|
98
113
|
export function projectStateForModel(state: MaterializedState): MaterializedState {
|
|
99
|
-
|
|
114
|
+
const { lazy: _lazy, ...hot } = structuredClone(state);
|
|
115
|
+
return { ...hot, artifacts: projectArtifactsForModel(state.artifacts) } as MaterializedState;
|
|
100
116
|
}
|
package/lib/status.ts
CHANGED
|
@@ -100,7 +100,7 @@ export function detailedStatus(snapshot: Snapshot, diagnostics: StatusDiagnostic
|
|
|
100
100
|
`State Flow diagnostics — config.enabled=${snapshot.config.enabled}; branch mode=${snapshot.config.enabled ? "active" : "inactive"}`,
|
|
101
101
|
`Repository: ${diagnostics.repositoryRoot}`,
|
|
102
102
|
`Scope keys: CWD ${diagnostics.cwdScopeKey}; session ${diagnostics.sessionScopeKey}`,
|
|
103
|
-
"Session files: config.json owns behavior; meta.json owns
|
|
103
|
+
"Session files: config.json owns behavior; runtime.json owns branch recovery; meta.json owns scope provenance",
|
|
104
104
|
`Runtime metadata: step #${snapshot.meta.step}; active revision ${snapshot.meta.durableBase ?? "none"}; bootstrap ${snapshot.meta.bootstrap === true}`,
|
|
105
105
|
`Remote publication policy: ${snapshot.meta.remotePublication?.mode ?? "legacy-transition"}`,
|
|
106
106
|
diagnostics.publicationQueueError !== undefined
|
package/lib/storage.ts
CHANGED
|
@@ -116,9 +116,9 @@ export function planTemporalPublication(
|
|
|
116
116
|
changedScopes.push(scope);
|
|
117
117
|
}
|
|
118
118
|
const provenanceUpdates: OwnedFileUpdate[] = [];
|
|
119
|
-
//
|
|
119
|
+
// Every scope metadata file owns provenance and temporal boundaries beside semantic files.
|
|
120
120
|
if (!runtimeOnly) {
|
|
121
|
-
for (const scope of
|
|
121
|
+
for (const scope of SCOPES) {
|
|
122
122
|
const paths = temporalScopePaths(cwd, sessionId, scope, root, sessionKey);
|
|
123
123
|
const registry = provenance?.[scope] ?? parseScopeProvenance(files.get(paths.meta)!.content, paths.meta);
|
|
124
124
|
const currentFile = files.get(paths.meta)!;
|
|
@@ -129,18 +129,21 @@ export function planTemporalPublication(
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
const runtimePaths = sessionRuntimePaths(cwd, sessionId, root, sessionKey);
|
|
132
|
-
const previousRuntime = parseSessionRuntime(files.get(runtimePaths.config)!.content, files.get(runtimePaths.
|
|
132
|
+
const previousRuntime = parseSessionRuntime(files.get(runtimePaths.config)!.content, files.get(runtimePaths.runtime)!.content, cwd, sessionId, files.get(runtimePaths.meta)!.content);
|
|
133
133
|
if (previousRuntime !== undefined && changedScopes.length > 0 && runtime === undefined) throw new Error("Temporal semantic publication requires its session runtime cohort");
|
|
134
134
|
const runtimeUpdates: OwnedFileUpdate[] = [];
|
|
135
135
|
if (runtime !== undefined) {
|
|
136
|
-
const sources = serializeSessionRuntime(runtime, cwd, sessionId
|
|
136
|
+
const sources = serializeSessionRuntime(runtime, cwd, sessionId);
|
|
137
137
|
if (!sameJson(runtime.meta.lineage, view.lineage)) throw new Error("Runtime lineage does not match the temporal cohort");
|
|
138
|
-
if (files.get(runtimePaths.config)!.content !== sources.config || files.get(runtimePaths.
|
|
139
|
-
runtimeUpdates.push({ path: runtimePaths.config, content: sources.config }, { path: runtimePaths.
|
|
138
|
+
if (files.get(runtimePaths.config)!.content !== sources.config || files.get(runtimePaths.runtime)!.content !== sources.runtime) {
|
|
139
|
+
runtimeUpdates.push({ path: runtimePaths.config, content: sources.config }, { path: runtimePaths.runtime, content: sources.runtime });
|
|
140
|
+
}
|
|
141
|
+
if (files.get(runtimePaths.runtime)!.identity === "missing" && files.get(runtimePaths.meta)!.content !== undefined
|
|
142
|
+
&& previousRuntime !== undefined && !provenanceUpdates.some(({ path }) => path === runtimePaths.meta)) {
|
|
143
|
+
const registry = provenance?.session ?? parseArtifactProvenanceRegistry(previousRuntime.meta.artifacts, "State Flow session artifact provenance");
|
|
144
|
+
const content = serializeScopeMetadata(registry, view.scopes.session, "session", undefined, files.get(runtimePaths.meta)!.content);
|
|
145
|
+
runtimeUpdates.push({ path: runtimePaths.meta, content });
|
|
140
146
|
}
|
|
141
|
-
} else if (!runtimeOnly && changedScopes.includes("session")) {
|
|
142
|
-
const content = serializeScopeMetadata(undefined, view.scopes.session, "session", undefined, files.get(runtimePaths.meta)!.content);
|
|
143
|
-
if (files.get(runtimePaths.meta)!.content !== content) runtimeUpdates.push({ path: runtimePaths.meta, content });
|
|
144
147
|
}
|
|
145
148
|
const changedPaths = new Set(changedScopes.flatMap((scope) => {
|
|
146
149
|
const paths = temporalScopePaths(cwd, sessionId, scope, root, sessionKey);
|
|
@@ -178,14 +181,14 @@ function decodeFileCohort(cwd: string, sessionId: string, root: string, base: Te
|
|
|
178
181
|
scopes[scope] = stream;
|
|
179
182
|
}
|
|
180
183
|
const paths = sessionRuntimePaths(cwd, sessionId, root, sessionKey);
|
|
181
|
-
const runtime = parseSessionRuntime(files.get(paths.config), files.get(paths.
|
|
184
|
+
const runtime = parseSessionRuntime(files.get(paths.config), files.get(paths.runtime), cwd, sessionId, files.get(paths.meta));
|
|
182
185
|
if (!runtime || runtime.meta.publication !== "files") throw new Error("File-only recovery requires file publication provenance, not a Git self reference");
|
|
183
186
|
const view = { scopes, lineage: runtime.meta.lineage };
|
|
184
187
|
validateTemporalState(view);
|
|
185
188
|
const provenance: Record<StateScope, ArtifactProvenanceRegistry> = {
|
|
186
189
|
global: parseScopeProvenance(files.get(temporalScopePaths(cwd, sessionId, "global", root, sessionKey).meta), temporalScopePaths(cwd, sessionId, "global", root, sessionKey).meta),
|
|
187
190
|
cwd: parseScopeProvenance(files.get(temporalScopePaths(cwd, sessionId, "cwd", root, sessionKey).meta), temporalScopePaths(cwd, sessionId, "cwd", root, sessionKey).meta),
|
|
188
|
-
session:
|
|
191
|
+
session: parseScopeProvenance(files.get(paths.meta), paths.meta),
|
|
189
192
|
};
|
|
190
193
|
return { runtime, view, provenance };
|
|
191
194
|
}
|
package/lib/telegram.ts
CHANGED
|
@@ -26,13 +26,20 @@ export interface StateFlowTelegramState {
|
|
|
26
26
|
artifacts: Record<string, unknown>;
|
|
27
27
|
contract: Record<string, unknown>;
|
|
28
28
|
working: Record<string, unknown>;
|
|
29
|
+
intents: Record<string, unknown>;
|
|
29
30
|
response: string;
|
|
31
|
+
lazy?: unknown;
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
export type StateFlowTelegramRichText =
|
|
35
|
+
| string
|
|
36
|
+
| StateFlowTelegramRichText[]
|
|
37
|
+
| { type: "bold" | "code"; text: StateFlowTelegramRichText };
|
|
38
|
+
|
|
32
39
|
export type StateFlowTelegramRichBlock =
|
|
33
|
-
| { type: "heading"; text:
|
|
34
|
-
| { type: "pre"; text:
|
|
35
|
-
| { type: "details"; summary:
|
|
40
|
+
| { type: "heading"; text: StateFlowTelegramRichText; size: 3 }
|
|
41
|
+
| { type: "pre"; text: StateFlowTelegramRichText; language?: string }
|
|
42
|
+
| { type: "details"; summary: StateFlowTelegramRichText; blocks: StateFlowTelegramRichBlock[]; is_open?: true };
|
|
36
43
|
|
|
37
44
|
export interface StateFlowTelegramRichMessage {
|
|
38
45
|
blocks: StateFlowTelegramRichBlock[];
|
|
@@ -168,6 +175,9 @@ function renderStateFlowTelegramField(value: unknown): string {
|
|
|
168
175
|
const length = Math.floor((low + high) / 2);
|
|
169
176
|
const candidate = JSON.stringify({
|
|
170
177
|
truncated: true,
|
|
178
|
+
...(value !== null && typeof value === "object" && !Array.isArray(value)
|
|
179
|
+
? { keys: Object.keys(value) }
|
|
180
|
+
: {}),
|
|
171
181
|
preview: json.slice(0, length),
|
|
172
182
|
omittedChars: json.length - length,
|
|
173
183
|
}, null, 2);
|
|
@@ -182,14 +192,18 @@ function renderStateFlowTelegramField(value: unknown): string {
|
|
|
182
192
|
}
|
|
183
193
|
|
|
184
194
|
export function renderStateFlowRichState(scope: StateFlowTelegramScope, step: number, state: StateFlowTelegramState): StateFlowTelegramRichMessage {
|
|
185
|
-
const fields = ["artifacts", "contract", "working", "response"] as const;
|
|
195
|
+
const fields = ["artifacts", "contract", "working", "intents", "response", "lazy"] as const;
|
|
186
196
|
return {
|
|
187
197
|
blocks: [
|
|
188
|
-
{
|
|
198
|
+
{
|
|
199
|
+
type: "heading",
|
|
200
|
+
text: [`${STATE_FLOW_SCOPE_LABELS[scope]}: `, { type: "code", text: `#${step}` }],
|
|
201
|
+
size: 3,
|
|
202
|
+
},
|
|
189
203
|
...fields.map((field) => ({
|
|
190
204
|
type: "details" as const,
|
|
191
205
|
summary: { type: "code" as const, text: field },
|
|
192
|
-
blocks: [{ type: "pre" as const, language: "json", text: renderStateFlowTelegramField(state[field]) }],
|
|
206
|
+
blocks: [{ type: "pre" as const, language: "json", text: renderStateFlowTelegramField(state[field] ?? {}) }],
|
|
193
207
|
})),
|
|
194
208
|
],
|
|
195
209
|
skip_entity_detection: true,
|
package/lib/transition.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface StagedScopedTransition {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const SCOPES = new Set<StateScope>(["global", "cwd", "session"]);
|
|
38
|
-
const PATCH_KEYS = new Set(["artifacts", "contract", "working"]);
|
|
38
|
+
const PATCH_KEYS = new Set(["artifacts", "contract", "working", "intents", "lazy"]);
|
|
39
39
|
|
|
40
40
|
function compileReadArtifacts(
|
|
41
41
|
nextState: StateDocument,
|
|
@@ -123,14 +123,17 @@ function validateScopePatch(scope: unknown, patch: unknown): asserts patch is Sc
|
|
|
123
123
|
validatePatch(patch);
|
|
124
124
|
for (const key of Object.keys(patch)) {
|
|
125
125
|
if (!PATCH_KEYS.has(key)) {
|
|
126
|
-
throw new Error(`Scoped State Flow patches cannot modify ${key}; only artifacts, contract, and
|
|
126
|
+
throw new Error(`Scoped State Flow patches cannot modify ${key}; only artifacts, contract, working, intents, and lazy are model-owned`);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
for (const key of
|
|
129
|
+
for (const key of ["artifacts", "contract", "working", "intents"] as const) {
|
|
130
130
|
if (Object.hasOwn(patch, key) && !isObject(patch[key])) {
|
|
131
131
|
throw new Error(`Scoped State Flow patch field ${key} must be a JSON object`);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
if (Object.hasOwn(patch, "lazy") && patch.lazy === null) {
|
|
135
|
+
throw new Error("Scoped State Flow patch field lazy cannot be null");
|
|
136
|
+
}
|
|
134
137
|
if (isObject(patch.artifacts)) validateModelArtifactPatch(patch.artifacts);
|
|
135
138
|
}
|
|
136
139
|
|
|
@@ -139,7 +142,9 @@ function completePatch(patch: ScopePatch, response: string): StatePatch {
|
|
|
139
142
|
artifacts: patch.artifacts ?? {},
|
|
140
143
|
contract: patch.contract ?? {},
|
|
141
144
|
working: patch.working ?? {},
|
|
145
|
+
intents: patch.intents ?? {},
|
|
142
146
|
response,
|
|
147
|
+
...(Object.hasOwn(patch, "lazy") ? { lazy: structuredClone(patch.lazy!) } : {}),
|
|
143
148
|
};
|
|
144
149
|
}
|
|
145
150
|
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ Use this Skill for one bounded maintenance cohort: either an explicit curation r
|
|
|
19
19
|
|
|
20
20
|
## Inventory
|
|
21
21
|
|
|
22
|
-
Read only the smallest required projections with `read_state`: session for branch/run continuation, CWD for project-specific knowledge, and global for established cross-project, user, or environment knowledge. Use older offsets only for a concrete contradiction or provenance question. Do not reread current effective state already in context without a specific verification or ownership need.
|
|
22
|
+
Read only the smallest required projections with `read_state`: session for branch/run continuation, CWD for project-specific knowledge, and global for established cross-project, user, or environment knowledge. Distinguish `contract` requirements, `working` observations and unresolved state, active commitments in `intents`, and inactive reusable memory in `lazy`. Use older offsets only for a concrete contradiction or provenance question. Do not reread current effective state already in context without a specific verification or ownership need.
|
|
23
23
|
|
|
24
24
|
Distinguish user requirements, confirmed decisions, observations, assistant conclusions, and hypotheses. Do not infer user acceptance from silence, repetition, or an earlier assistant assertion.
|
|
25
25
|
|
|
@@ -38,6 +38,8 @@ These are audit decisions, not required stored labels. Do not manufacture timest
|
|
|
38
38
|
|
|
39
39
|
### Preserve commitments without freezing methods
|
|
40
40
|
|
|
41
|
+
Treat every value in `intents` as an active commitment to future action. Keep it only while that course remains chosen; remove it when fulfilled, abandoned, superseded, or impossible, retaining only consequential results in `working`, `contract`, or `lazy`. Alternatives, possible next steps, observations, and historical plans are not intents. Check touched intent references for moved or missing targets, but never auto-hydrate, rewrite, execute, or complete a `{"$ref":"..."}` pointer.
|
|
42
|
+
|
|
41
43
|
Preserve active goals, explicit constraints, confirmed decisions, completed prerequisites, and obligations that still affect future work. Preserve corrections and their consequences.
|
|
42
44
|
|
|
43
45
|
Separate a binding requirement from the method currently proposed to satisfy it. Do not turn an assistant preference into a user requirement, or a provisional approach into a settled decision. Conversely, do not demote a confirmed decision merely to encourage exploration. Retain its scope and known reconsideration conditions when relevant; do not invent them.
|
|
@@ -46,6 +48,8 @@ Separate a binding requirement from the method currently proposed to satisfy it.
|
|
|
46
48
|
|
|
47
49
|
When it affects continuation, retain what was proposed, accepted, rejected, corrected, explained, or left unresolved, and what the next response or action must address. Preserve enough referents for pending follow-ups to make sense.
|
|
48
50
|
|
|
51
|
+
Treat every completed work slice as a possible restart boundary. Its checkpoint should let a fresh executor recover the achieved outcome, surviving evidence, active commitments, decision-relevant uncertainty, and exact continuation without replaying the prior reasoning trajectory. Optimize decomposition for resumability as well as functional completion; if the next safe action depends on transient context that will disappear, the slice is not yet at a sufficient boundary.
|
|
52
|
+
|
|
49
53
|
Keep consequences, not a transcript or a personality dossier. Do not invent shared history or claim subjective continuity. A fresh run should not unnecessarily reopen a settled exchange or treat an unanswered proposal as approved.
|
|
50
54
|
|
|
51
55
|
### Preserve learning at its demonstrated boundary
|
|
@@ -70,11 +74,17 @@ A locator supports later retrieval; it does not replace content needed for the n
|
|
|
70
74
|
|
|
71
75
|
Do not rerun the underlying project merely to curate its memory. Leave an exact unresolved check when verification falls outside the requested boundary.
|
|
72
76
|
|
|
73
|
-
###
|
|
77
|
+
### Preserve priority and keep Lazy shallow
|
|
78
|
+
|
|
79
|
+
Treat array order in Lazy as semantic priority: earlier entries are higher priority. Preserve that order deliberately; do not reorder entries for aesthetics, incidental grouping, or normalization.
|
|
80
|
+
|
|
81
|
+
Minimize Lazy nesting, especially for top-level collections. Keep a top-level collection as a direct array when its members are the domain values. Represent a standalone item directly, normally as a string; use an object only when that item genuinely owns structured or nested fields. Do not add `items`, `owner`, `source`, or similar wrapper objects merely to describe the collection, and do not introduce nested arrays unless the domain itself requires a matrix or grouped sequence.
|
|
82
|
+
|
|
83
|
+
### Compact without flattening meaning
|
|
74
84
|
|
|
75
85
|
Merge redundant fragments and remove obsolete scaffolding, repeated argumentation, and routine progress. Do not rewrite unchanged state merely to normalize wording.
|
|
76
86
|
|
|
77
|
-
Do not erase a meaningful correction, uncertainty, commitment, negative result, or continuation dependency to make state shorter. Do not retain the previous chain of reasoning solely to steer the next run toward the same method.
|
|
87
|
+
Do not erase a meaningful correction, uncertainty, commitment, negative result, priority order, or continuation dependency to make state shorter. Do not retain the previous chain of reasoning solely to steer the next run toward the same method.
|
|
78
88
|
|
|
79
89
|
### Reconcile phase boundaries
|
|
80
90
|
|
|
@@ -90,7 +100,7 @@ Effective state does not prove which scope owns a value. When ownership matters
|
|
|
90
100
|
|
|
91
101
|
Before writing, review the proposed changes once within the requested boundary:
|
|
92
102
|
|
|
93
|
-
- Would a fresh executor know what must still hold, what changed, what remains unresolved, and
|
|
103
|
+
- Would a fresh executor know what must still hold, what changed, what remains unresolved, and the exact next action without replaying the prior cognitive trajectory?
|
|
94
104
|
- Could an omission cause a known failed attempt, an unnecessary repeated explanation, or loss of an active commitment?
|
|
95
105
|
- Could a retained claim impose an unapproved method, overgeneralize a result, or hide a live alternative?
|
|
96
106
|
|
|
@@ -98,14 +108,14 @@ Adjust only identified defects. This is a semantic review, not a request for ext
|
|
|
98
108
|
|
|
99
109
|
## Apply one reconciliation cohort
|
|
100
110
|
|
|
101
|
-
Use `patch_state` only for material changes to `artifacts`, `contract`, or `
|
|
111
|
+
Use `patch_state` only for material changes to `artifacts`, `contract`, `working`, `intents`, or `lazy`. One call may supply `global`, `cwd`, and `session` patches as one atomic cohort; each call must be alone in its assistant response, and subsequent actions must use the rematerialized state. Set `final:true` only when the iteration is eligible to finish at a later `turn_end`. Do not patch runtime-owned `response`, config, or metadata, or bypass validation by editing backing files.
|
|
102
112
|
|
|
103
113
|
Schedule acquisition and migration barriers in this order:
|
|
104
114
|
|
|
105
115
|
1. After reading this Skill, compile it into its exact-path CWD artifact before acquiring a stale global Markdown source or attempting an unrelated state write.
|
|
106
116
|
2. Read only the smallest required state projections. If a justified stale Markdown read creates a global compilation obligation, include every pending compilation scope in the next atomic patch before unrelated work.
|
|
107
117
|
3. Write the migration destination with `patch_state`, verify it with a separate `read_state`, then delete or narrow the source and verify both its scope and the effective overlay. Do all readback before the terminal answer.
|
|
108
|
-
4. Complete one terminal reconciliation without repeating accepted compilations or inventing memory changes. Simultaneously pending CWD and global acquisitions must be compiled together in one atomic `patch_state` call; set `final:true` in that call only when the iteration is otherwise ready to finish.
|
|
118
|
+
4. Complete one terminal reconciliation without repeating accepted compilations or inventing memory changes. Review touched intents explicitly: retain active commitments, remove completed or impossible ones, replace superseded ones, and preserve their consequential results in the appropriate plane. Simultaneously pending CWD and global acquisitions must be compiled together in one atomic `patch_state` call; set `final:true` in that call only when the iteration is otherwise ready to finish.
|
|
109
119
|
|
|
110
120
|
Scope-local deletion may reveal a lower-scope value. Deleting an override is not necessarily removal from effective state.
|
|
111
121
|
|