@feltdb/feltkit 0.3.22 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/app.d.ts +17 -3
  2. package/dist/app.js +10 -0
  3. package/dist/app.js.map +1 -1
  4. package/dist/appboundry/build.js +4 -0
  5. package/dist/appboundry/build.js.map +1 -1
  6. package/dist/authorize.d.ts +1 -1
  7. package/dist/cli/deploy-appboundry.d.ts +26 -0
  8. package/dist/cli/deploy-appboundry.js +1 -1
  9. package/dist/cli/deploy-appboundry.js.map +1 -1
  10. package/dist/cli/main.js +17 -153
  11. package/dist/cli/main.js.map +1 -1
  12. package/dist/client/index.d.ts +83 -4
  13. package/dist/client/index.js +204 -10
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/dashboard/assets/index-BEjtLLYq.js +15 -0
  16. package/dist/dashboard/index.html +1 -1
  17. package/dist/docs.d.ts +1 -1
  18. package/dist/docs.js +2 -0
  19. package/dist/docs.js.map +1 -1
  20. package/dist/index.d.ts +4 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/platform/approvals.d.ts +102 -0
  23. package/dist/platform/approvals.js +155 -0
  24. package/dist/platform/approvals.js.map +1 -0
  25. package/dist/platform/artifacts.d.ts +126 -0
  26. package/dist/platform/artifacts.js +251 -0
  27. package/dist/platform/artifacts.js.map +1 -0
  28. package/dist/platform/blobs.d.ts +25 -0
  29. package/dist/platform/blobs.js +78 -0
  30. package/dist/platform/blobs.js.map +1 -0
  31. package/dist/platform/diff.d.ts +23 -0
  32. package/dist/platform/diff.js +107 -0
  33. package/dist/platform/diff.js.map +1 -0
  34. package/dist/platform/exec.d.ts +182 -0
  35. package/dist/platform/exec.js +575 -0
  36. package/dist/platform/exec.js.map +1 -0
  37. package/dist/platform/managed.d.ts +43 -0
  38. package/dist/platform/managed.js +137 -0
  39. package/dist/platform/managed.js.map +1 -0
  40. package/dist/platform/operations.d.ts +30 -13
  41. package/dist/platform/operations.js +8 -17
  42. package/dist/platform/operations.js.map +1 -1
  43. package/dist/platform/permissions.d.ts +15 -0
  44. package/dist/platform/permissions.js +16 -0
  45. package/dist/platform/permissions.js.map +1 -0
  46. package/dist/platform/platform.d.ts +51 -0
  47. package/dist/platform/platform.js +105 -6
  48. package/dist/platform/platform.js.map +1 -1
  49. package/dist/platform/releases.d.ts +150 -0
  50. package/dist/platform/releases.js +467 -0
  51. package/dist/platform/releases.js.map +1 -0
  52. package/dist/platform/review.d.ts +10 -0
  53. package/dist/platform/review.js +109 -0
  54. package/dist/platform/review.js.map +1 -0
  55. package/dist/platform/server.js +7 -0
  56. package/dist/platform/server.js.map +1 -1
  57. package/dist/platform/source.d.ts +2 -0
  58. package/dist/platform/source.js +1 -1
  59. package/dist/platform/source.js.map +1 -1
  60. package/dist/platform/workspace-operations.d.ts +2 -0
  61. package/dist/platform/workspace-operations.js +605 -0
  62. package/dist/platform/workspace-operations.js.map +1 -0
  63. package/dist/platform/workspaces.d.ts +211 -0
  64. package/dist/platform/workspaces.js +435 -0
  65. package/dist/platform/workspaces.js.map +1 -0
  66. package/dist/react/index.d.ts +29 -1
  67. package/dist/react/index.js +50 -0
  68. package/dist/react/index.js.map +1 -1
  69. package/dist/runtime/activity.d.ts +1 -1
  70. package/dist/runtime/agent.d.ts +216 -2
  71. package/dist/runtime/agent.js +333 -7
  72. package/dist/runtime/agent.js.map +1 -1
  73. package/dist/runtime/approval-rules.d.ts +16 -0
  74. package/dist/runtime/approval-rules.js +37 -0
  75. package/dist/runtime/approval-rules.js.map +1 -0
  76. package/dist/runtime/authboundry.d.ts +53 -0
  77. package/dist/runtime/authboundry.js +82 -0
  78. package/dist/runtime/authboundry.js.map +1 -0
  79. package/dist/runtime/authority.d.ts +18 -1
  80. package/dist/runtime/authority.js +26 -1
  81. package/dist/runtime/authority.js.map +1 -1
  82. package/dist/runtime/browser-inference.d.ts +52 -0
  83. package/dist/runtime/browser-inference.js +53 -0
  84. package/dist/runtime/browser-inference.js.map +1 -0
  85. package/dist/runtime/context.d.ts +110 -0
  86. package/dist/runtime/decisions.d.ts +23 -0
  87. package/dist/runtime/decisions.js +54 -0
  88. package/dist/runtime/decisions.js.map +1 -1
  89. package/dist/runtime/generation.d.ts +94 -0
  90. package/dist/runtime/generation.js +295 -0
  91. package/dist/runtime/generation.js.map +1 -0
  92. package/dist/runtime/runtime.d.ts +10 -2
  93. package/dist/runtime/runtime.js +125 -1
  94. package/dist/runtime/runtime.js.map +1 -1
  95. package/dist/server/admin.d.ts +9 -1
  96. package/dist/server/admin.js +84 -2
  97. package/dist/server/admin.js.map +1 -1
  98. package/dist/server/index.d.ts +1 -1
  99. package/dist/server/index.js +208 -11
  100. package/dist/server/index.js.map +1 -1
  101. package/dist/server/tenancy.js +1 -1
  102. package/dist/server/tenancy.js.map +1 -1
  103. package/dist/testing/index.d.ts +11 -0
  104. package/dist/testing/index.js +7 -3
  105. package/dist/testing/index.js.map +1 -1
  106. package/docs/AUTH.md +3 -2
  107. package/docs/EXTENSION-HOSTS.md +52 -0
  108. package/docs/GENERATION.md +136 -0
  109. package/docs/README.md +4 -2
  110. package/package.json +6 -8
  111. package/skills/.claude-plugin/marketplace.json +1 -1
  112. package/skills/.claude-plugin/plugin.json +1 -1
  113. package/dist/cli/compose.d.ts +0 -31
  114. package/dist/cli/compose.js +0 -274
  115. package/dist/cli/compose.js.map +0 -1
  116. package/dist/cli/create.d.ts +0 -219
  117. package/dist/cli/create.js +0 -1197
  118. package/dist/cli/create.js.map +0 -1
  119. package/dist/cli/domain.d.ts +0 -174
  120. package/dist/cli/domain.js +0 -1170
  121. package/dist/cli/domain.js.map +0 -1
  122. package/dist/cli/screens.d.ts +0 -25
  123. package/dist/cli/screens.js +0 -282
  124. package/dist/cli/screens.js.map +0 -1
  125. package/dist/cli/shell.d.ts +0 -7
  126. package/dist/cli/shell.js +0 -63
  127. package/dist/cli/shell.js.map +0 -1
  128. package/dist/composition/catalog.d.ts +0 -3
  129. package/dist/composition/catalog.js +0 -217
  130. package/dist/composition/catalog.js.map +0 -1
  131. package/dist/composition/contract.d.ts +0 -165
  132. package/dist/composition/contract.js +0 -12
  133. package/dist/composition/contract.js.map +0 -1
  134. package/dist/composition/execute.d.ts +0 -110
  135. package/dist/composition/execute.js +0 -350
  136. package/dist/composition/execute.js.map +0 -1
  137. package/dist/composition/generate.d.ts +0 -105
  138. package/dist/composition/generate.js +0 -274
  139. package/dist/composition/generate.js.map +0 -1
  140. package/dist/composition/plan.d.ts +0 -131
  141. package/dist/composition/plan.js +0 -558
  142. package/dist/composition/plan.js.map +0 -1
  143. package/dist/composition/profiles.d.ts +0 -20
  144. package/dist/composition/profiles.js +0 -81
  145. package/dist/composition/profiles.js.map +0 -1
  146. package/dist/composition/reconcile.d.ts +0 -153
  147. package/dist/composition/reconcile.js +0 -282
  148. package/dist/composition/reconcile.js.map +0 -1
  149. package/dist/composition/recover.d.ts +0 -89
  150. package/dist/composition/recover.js +0 -407
  151. package/dist/composition/recover.js.map +0 -1
  152. package/dist/composition/resolve.d.ts +0 -2
  153. package/dist/composition/resolve.js +0 -208
  154. package/dist/composition/resolve.js.map +0 -1
  155. package/dist/dashboard/assets/index-BrC1AtZ1.js +0 -15
@@ -1,350 +0,0 @@
1
- /**
2
- * Execution (M5): apply one approved plan, exactly, against exactly the state it was planned on, and
3
- * prove what happened. The result (`feltkit.composition-execution/1`) is evidence, not an authority:
4
- * the record and lock stay the composition's authorities (generate.ts), the application stays the
5
- * authority for its own code (never written here).
6
- *
7
- * The approval is the plan's id (plan.ts): the hash of the whole plan, which carries the current
8
- * state (file hashes, fingerprints, reconciliation, the application sources' hashes) and the target.
9
- * Execution recomputes the plan from the same request and refuses unless the id is the approved one,
10
- * so an approval never applies to a plan that differs in any meaningful input. It executes only a
11
- * narrow, fully deterministic slice (EXECUTABLE), writes only the three generator-owned files, and
12
- * refuses a plan that needs a decision, is blocked, or contains anything else, before any write.
13
- *
14
- * Writes follow a staged protocol: every output computed and hashed in memory, a journal written
15
- * first (what is about to change, from which hashes to which), each file staged as a temporary file
16
- * in its own directory and verified, then committed in a fixed order with the journal updated after
17
- * each rename, then every byte verified, `checkFoundation` run, and `reconcile` required to be
18
- * CURRENT. Three renames are not one atomic operation, and this code does not claim they are: the
19
- * journal makes an interruption detectable, and an incomplete journal stops the next execution with
20
- * RECOVERY_REQUIRED, never a silent cleanup.
21
- */
22
- import { closeSync, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
23
- import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
24
- import { DECLARATION_PATH, GENERATED_PATHS, GENERATOR, LOCK_PATH, RECORD_PATH, canonical, checkFoundation, generateFoundation, sha256 } from "./generate.js";
25
- import { PLAN_FORMAT, PLAN_RULES, applicationSources, planComposition } from "./plan.js";
26
- import { RECONCILIATION_FORMAT, readGeneratedState, reconcile } from "./reconcile.js";
27
- export const EXECUTION_FORMAT = "feltkit.composition-execution/1";
28
- export const ENGINE = "feltkit-compose-apply/1";
29
- export const JOURNAL_FORMAT = "feltkit.composition-journal/1";
30
- /** Where a transaction's journal lives: under the project's own state directory, never among application files. */
31
- export const JOURNAL_DIR = ".feltkit/composition";
32
- export const JOURNAL_PATH = `${JOURNAL_DIR}/transaction.json`;
33
- /** Operation types this slice executes. Everything else is refused before any write. */
34
- export const EXECUTABLE = new Set([
35
- "resolve-target",
36
- "validate-target",
37
- "verify-current-state",
38
- "change-parameter",
39
- "add-capability",
40
- "update-capability",
41
- "change-declaration-path",
42
- "regenerate-declaration",
43
- "update-record",
44
- "update-lock",
45
- "revalidate-application",
46
- ]);
47
- const WRITE_TYPES = new Set(["regenerate-declaration", "update-record", "update-lock"]);
48
- /** A staged temporary file: `<file>.<pid>.<8 hex of the transaction>.tmp`, beside its target. */
49
- export const STAGED_TEMPORARY = /\.(\d+)\.([0-9a-f]{8})\.tmp$/;
50
- const COMMIT_ORDER = [DECLARATION_PATH, RECORD_PATH, LOCK_PATH];
51
- const hashOf = (dir, path) => (existsSync(join(dir, path)) ? sha256(readFileSync(join(dir, path), "utf8")) : null);
52
- function readJournal(projectDir) {
53
- const file = join(projectDir, JOURNAL_PATH);
54
- if (!existsSync(file))
55
- return null;
56
- try {
57
- const j = JSON.parse(readFileSync(file, "utf8"));
58
- return j && j.format === JOURNAL_FORMAT ? j : { format: JOURNAL_FORMAT, transaction: "unreadable", plan: "unreadable", engine: "unknown", phase: "committing", files: {}, committed: [], failure: "unreadable journal" };
59
- }
60
- catch {
61
- return { format: JOURNAL_FORMAT, transaction: "unreadable", plan: "unreadable", engine: "unknown", phase: "committing", files: {}, committed: [], failure: "unreadable journal" };
62
- }
63
- }
64
- /**
65
- * Write bytes to a temporary file beside `file`, flush them to the device, rename into place, and flush
66
- * the directory, so the rename is on disk before anything that depends on it. Best effort: platforms
67
- * that cannot fsync a directory are tolerated; the protocol's ordering of operations does not change.
68
- */
69
- function writeDurably(file, text, temporary) {
70
- writeFileSync(temporary, text);
71
- syncFile(temporary);
72
- renameSync(temporary, file);
73
- syncDirectory(dirname(file));
74
- }
75
- function syncFile(path) {
76
- const fd = openSync(path, "r+");
77
- try {
78
- fsyncSync(fd);
79
- }
80
- finally {
81
- closeSync(fd);
82
- }
83
- }
84
- function syncDirectory(dir) {
85
- try {
86
- const fd = openSync(dir, "r");
87
- try {
88
- fsyncSync(fd);
89
- }
90
- finally {
91
- closeSync(fd);
92
- }
93
- }
94
- catch {
95
- // Not every platform lets a directory be opened or synced.
96
- }
97
- }
98
- function writeJournal(projectDir, journal) {
99
- const file = join(projectDir, JOURNAL_PATH);
100
- mkdirSync(dirname(file), { recursive: true });
101
- writeDurably(file, `${JSON.stringify(journal, null, 2)}\n`, `${file}.${process.pid}.tmp`);
102
- }
103
- /** A generator-owned path, inside the project, not a symlink (and no symlinked parent): the only kind execution writes. */
104
- function ownedPathProblem(projectDir, path) {
105
- if (!GENERATED_PATHS.includes(path))
106
- return `${path} is not a generator-owned path (${GENERATED_PATHS.join(", ")}).`;
107
- if (isAbsolute(path) || path.split(/[\\/]/).includes(".."))
108
- return `${path} is not a plain relative path inside the project.`;
109
- const root = realpathSync(projectDir);
110
- const file = join(projectDir, path);
111
- // Every existing component from the project root down must be a real directory or file, not a link.
112
- let at = projectDir;
113
- for (const part of path.split("/")) {
114
- at = join(at, part);
115
- if (!existsSync(at))
116
- break;
117
- if (lstatSync(at).isSymbolicLink())
118
- return `${relative(projectDir, at)} is a symbolic link; execution writes only real files inside the project.`;
119
- }
120
- const real = existsSync(file) ? realpathSync(file) : realpathSync(dirname(existsSync(dirname(file)) ? file : join(projectDir, path.split("/")[0])));
121
- if (real !== root && !real.startsWith(root + sep))
122
- return `${path} resolves outside the project (${real}).`;
123
- return null;
124
- }
125
- /**
126
- * Execute the plan for `request` in `projectDir`, if `request.approve` is its exact id and every
127
- * operation is executable. Writes only the generator-owned files, and only after every precondition
128
- * holds; verifies everything afterwards.
129
- */
130
- export async function executePlan(projectDir, request, options = {}) {
131
- const { approve, ...planRequest } = request;
132
- const evidence = [];
133
- const preconditions = [];
134
- const postconditions = [];
135
- const filesBefore = Object.fromEntries(GENERATED_PATHS.map((p) => [p, hashOf(projectDir, p)]));
136
- const outcome = (files, extra, code, message, plan) => ({
137
- format: EXECUTION_FORMAT,
138
- engine: ENGINE,
139
- code,
140
- ok: code === "APPLIED" || code === "NO_CHANGE" || code === "ALREADY_CURRENT",
141
- message,
142
- approved: approve ?? null,
143
- plan: { id: plan?.id ?? null, format: PLAN_FORMAT, rules: PLAN_RULES, status: plan?.status ?? null },
144
- current: { composition: plan?.current.composition ?? null, inputs: plan?.current.inputs_hash ?? null },
145
- target: { composition: plan?.target.composition ?? null, inputs: plan?.target.inputs_hash ?? null },
146
- files,
147
- operations: { executed: [], skipped: [], refused: [] },
148
- preconditions,
149
- postconditions,
150
- reconciliation: { format: RECONCILIATION_FORMAT, state: plan?.current.reconciliation.state ?? null, findings: plan?.current.reconciliation.findings ?? [] },
151
- transaction: { id: null, journal: JOURNAL_PATH, outcome: "none" },
152
- evidence,
153
- ...extra,
154
- });
155
- const unchanged = () => Object.fromEntries(GENERATED_PATHS.map((p) => [p, { before: filesBefore[p], after: hashOf(projectDir, p), expected: null, written: false }]));
156
- // 0. An interrupted transaction is never stepped over.
157
- const journal = readJournal(projectDir);
158
- if (journal) {
159
- evidence.push(`journal ${JOURNAL_PATH}: phase ${journal.phase}, plan ${journal.plan}, committed ${journal.committed.join(", ") || "nothing"}${journal.failure ? `, failure: ${journal.failure}` : ""}`);
160
- for (const [path, f] of Object.entries(journal.files))
161
- evidence.push(`${path}: prior ${f.prior ?? "absent"}, expected ${f.expected}, on disk ${hashOf(projectDir, path) ?? "absent"}`);
162
- return outcome(unchanged(), { transaction: { id: journal.transaction, journal: JOURNAL_PATH, outcome: "interrupted" } }, "RECOVERY_REQUIRED", journal.phase === "verified"
163
- ? `A previous execution completed and verified, but its journal was not removed (${JOURNAL_PATH}). Run \`feltkit compose recover --inspect\` to confirm the files still verify, then remove the journal by hand. Nothing was changed now.`
164
- : `A previous execution did not complete (${JOURNAL_PATH}, phase ${journal.phase}). Run \`feltkit compose recover --inspect\`: it compares each file with the journal's prior and expected hashes and says which consistent state can be restored and how. Nothing was changed now.`, null);
165
- }
166
- // 1. Recompute the plan from the request: this is what the approval must name.
167
- const plan = await planComposition(projectDir, planRequest, options);
168
- evidence.push(`plan ${plan.id} (${plan.status}); reconciliation ${plan.current.reconciliation.state}${plan.current.reconciliation.findings.length ? ` [${plan.current.reconciliation.findings.join(", ")}]` : ""}`);
169
- if (plan.status === "NO_CHANGE") {
170
- return outcome(unchanged(), {}, "ALREADY_CURRENT", "The recorded composition already is the target; there is nothing to execute and nothing was written.", plan);
171
- }
172
- if (!approve) {
173
- return outcome(unchanged(), {}, "APPROVAL_REQUIRED", `No plan was approved. Review \`feltkit compose plan …\` for this target and, if it is what you want, run again with --approve ${plan.id}.`, plan);
174
- }
175
- if (approve !== plan.id) {
176
- return outcome(unchanged(), {}, "PLAN_MISMATCH", `The approved plan ${approve} is not the plan for this target against the current state (${plan.id}). The request differs from what was approved, or the application, its generated files, or FeltKit's definitions changed since: reconciliation is ${plan.current.reconciliation.state}. Review the plan again before approving it.`, plan);
177
- }
178
- // 2. The plan must be fully executable: no decision, blocker or unsupported change, and every operation in this slice.
179
- const refused = [];
180
- for (const o of plan.operations) {
181
- if (o.classification === "REVIEW_REQUIRED")
182
- refused.push({ id: o.id, reason: o.decision ?? "needs a decision" });
183
- else if (o.classification === "BLOCKED")
184
- refused.push({ id: o.id, reason: o.decision ?? "blocked" });
185
- else if (o.classification === "UNSUPPORTED")
186
- refused.push({ id: o.id, reason: o.decision ?? "unsupported target" });
187
- else if (!EXECUTABLE.has(o.type))
188
- refused.push({ id: o.id, reason: `${o.type} is not executed by ${ENGINE}: ${o.type === "remove-capability" ? "capability removal is outside this execution slice" : o.type === "adopt-generator" ? "a generator change is regenerated by `feltkit compose`, reviewed by hand" : "outside the executable set"}.` });
189
- }
190
- if (refused.length) {
191
- const code = plan.status === "REVIEW_REQUIRED" ? "REVIEW_REQUIRED" : plan.status === "BLOCKED" ? "BLOCKED" : "UNSUPPORTED_OPERATION";
192
- return outcome(unchanged(), { operations: { executed: [], skipped: [], refused } }, code, `${refused.length} operation(s) cannot be executed by ${ENGINE}; nothing was written. ${code === "REVIEW_REQUIRED" ? "Decide each one, express the decision in feltkit/app.ts or the composition inputs, and plan again." : ""}`.trim(), plan);
193
- }
194
- // 3. The write set: only generator-owned paths, inside the project, no links.
195
- const writeOps = plan.operations.filter((o) => WRITE_TYPES.has(o.type));
196
- const writeSet = writeOps.map((o) => o.target);
197
- for (const path of writeSet) {
198
- const problem = ownedPathProblem(projectDir, path);
199
- if (problem) {
200
- evidence.push(problem);
201
- return outcome(unchanged(), {}, "OWNERSHIP_VIOLATION", `Refused before any write: ${problem}`, plan);
202
- }
203
- }
204
- const sources = applicationSources(projectDir);
205
- for (const path of Object.keys(sources))
206
- if (writeSet.includes(path))
207
- return outcome(unchanged(), {}, "OWNERSHIP_VIOLATION", `Refused: ${path} is application-owned.`, plan);
208
- preconditions.push(`write set ${writeSet.join(", ")} ⊆ generator-owned paths, inside the project, no symbolic links`);
209
- if (!writeSet.length)
210
- return outcome(unchanged(), {}, "NO_CHANGE", "The plan changes no file.", plan);
211
- // 4. Freshness, immediately before writing: the state the plan describes is the state on disk now.
212
- options.hooks?.afterPlan?.();
213
- const stale = [];
214
- if (hashOf(projectDir, DECLARATION_PATH) !== plan.current.declaration)
215
- stale.push(`${DECLARATION_PATH} is ${hashOf(projectDir, DECLARATION_PATH) ?? "absent"}, the plan saw ${plan.current.declaration}`);
216
- const nowSources = applicationSources(projectDir);
217
- if (canonical(nowSources) !== canonical(plan.current.sources))
218
- stale.push(`application sources changed: ${Object.keys({ ...nowSources, ...plan.current.sources }).filter((k) => nowSources[k] !== plan.current.sources[k]).join(", ")}`);
219
- const state = readGeneratedState(projectDir);
220
- const check = checkFoundation(state, options.catalog, options.profiles);
221
- if (!check.ok)
222
- stale.push(`integrity: ${check.problems.map((p) => p.code).join(", ")}`);
223
- if (stale.length) {
224
- evidence.push(...stale);
225
- return outcome(unchanged(), {}, "STALE_STATE", `The application changed between planning and execution; nothing was written. Plan again.`, plan);
226
- }
227
- preconditions.push(`${DECLARATION_PATH} ${plan.current.declaration}`, `application sources ${Object.entries(plan.current.sources).map(([p, h]) => `${p} ${h.slice(0, 19)}…`).join(", ")}`, "`feltkit compose --check` passes on the current files");
228
- // 5. Outputs, fully in memory, and the target the plan promised.
229
- const generated = generateFoundation(plan.target.inputs, options.catalog, options.profiles);
230
- if (!generated.ok)
231
- return outcome(unchanged(), {}, "EXECUTION_FAILED", `The target no longer generates: ${generated.errors.map((e) => `${e.code} ${e.message}`).join("; ")}`, plan);
232
- if (generated.lock.files[DECLARATION_PATH].sha256 !== plan.target.declaration)
233
- return outcome(unchanged(), {}, "EXECUTION_FAILED", `The generated declaration (${generated.lock.files[DECLARATION_PATH].sha256}) is not the plan's target (${plan.target.declaration}).`, plan);
234
- if (generated.record.composition !== plan.target.composition)
235
- return outcome(unchanged(), {}, "EXECUTION_FAILED", "The generated composition is not the plan's target.", plan);
236
- preconditions.push(`target declaration ${plan.target.declaration}`, `target composition ${plan.target.composition}`);
237
- const expected = Object.fromEntries(GENERATED_PATHS.map((p) => [p, sha256(generated.files[p])]));
238
- const toWrite = COMMIT_ORDER.filter((p) => expected[p] !== filesBefore[p]);
239
- for (const path of writeSet)
240
- if (!toWrite.includes(path) && expected[path] === filesBefore[path])
241
- evidence.push(`${path}: planned, but its bytes are already the target's; not rewritten`);
242
- if (!toWrite.length) {
243
- return outcome(Object.fromEntries(GENERATED_PATHS.map((p) => [p, { before: filesBefore[p], after: filesBefore[p], expected: expected[p], written: false }])), {}, "NO_CHANGE", "Every generated file already holds the target bytes; nothing was written.", plan);
244
- }
245
- // 6. The transaction: journal, stage, verify, commit in order, verify.
246
- const transaction = sha256(canonical({ plan: plan.id, prior: filesBefore }));
247
- let journalState = { format: JOURNAL_FORMAT, transaction, plan: plan.id, engine: ENGINE, phase: "staged", files: Object.fromEntries(toWrite.map((p) => [p, { prior: filesBefore[p], expected: expected[p] }])), committed: [] };
248
- const staged = {};
249
- const executed = [];
250
- const files = () => Object.fromEntries(GENERATED_PATHS.map((p) => [p, { before: filesBefore[p], after: hashOf(projectDir, p), expected: expected[p], written: journalState.committed.includes(p) }]));
251
- const fail = (code, message, phase) => {
252
- journalState = { ...journalState, phase, failure: message };
253
- try {
254
- writeJournal(projectDir, journalState);
255
- }
256
- catch {
257
- // The journal itself could not be written: the result still says what happened.
258
- }
259
- for (const t of Object.values(staged))
260
- if (existsSync(t))
261
- rmSync(t, { force: true });
262
- return outcome(files(), { operations: { executed, skipped: [], refused: [] }, transaction: { id: transaction, journal: JOURNAL_PATH, outcome: journalState.committed.length ? "interrupted" : "aborted-before-write" } }, code, message, plan);
263
- };
264
- try {
265
- writeJournal(projectDir, journalState);
266
- options.hooks?.afterJournal?.();
267
- for (const path of toWrite) {
268
- const file = join(projectDir, path);
269
- mkdirSync(dirname(file), { recursive: true });
270
- const temporary = `${file}.${process.pid}.${transaction.slice(7, 15)}.tmp`;
271
- writeFileSync(temporary, generated.files[path]);
272
- syncFile(temporary);
273
- const observed = sha256(readFileSync(temporary, "utf8"));
274
- if (observed !== expected[path])
275
- throw new Error(`staged ${path} hashes to ${observed}, expected ${expected[path]}`);
276
- staged[path] = temporary;
277
- options.hooks?.afterStage?.(path);
278
- }
279
- }
280
- catch (error) {
281
- return fail("EXECUTION_FAILED", `Staging failed: ${error.message}. No generated file was changed.`, "staged");
282
- }
283
- journalState = { ...journalState, phase: "committing" };
284
- try {
285
- writeJournal(projectDir, journalState);
286
- for (const path of toWrite) {
287
- options.hooks?.beforeCommit?.(path, journalState.committed);
288
- // The file must still be what the plan saw: nothing else may have touched it meanwhile.
289
- if (hashOf(projectDir, path) !== filesBefore[path])
290
- throw new Error(`${path} changed during execution (${hashOf(projectDir, path) ?? "absent"}, expected ${filesBefore[path]})`);
291
- renameSync(staged[path], join(projectDir, path));
292
- syncDirectory(dirname(join(projectDir, path)));
293
- delete staged[path];
294
- journalState = { ...journalState, committed: [...journalState.committed, path] };
295
- writeJournal(projectDir, journalState);
296
- executed.push(...writeOps.filter((o) => o.target === path).map((o) => o.id));
297
- options.hooks?.afterCommit?.(path, journalState.committed);
298
- }
299
- }
300
- catch (error) {
301
- const message = error.message;
302
- return fail(journalState.committed.length ? "RECOVERY_REQUIRED" : "EXECUTION_FAILED", journalState.committed.length ? `Commit failed after ${journalState.committed.join(", ")} were written: ${message}. The generated files are in a mixed state; ${JOURNAL_PATH} records each file's prior and expected hash. Restore one consistent state (version control holds the prior one) and delete the journal.` : `Commit failed before any file was replaced: ${message}.`, "committing");
303
- }
304
- journalState = { ...journalState, phase: "committed" };
305
- writeJournal(projectDir, journalState);
306
- options.hooks?.beforeVerify?.();
307
- executed.push(...plan.operations.filter((o) => !WRITE_TYPES.has(o.type) && o.type !== "revalidate-application").map((o) => o.id));
308
- // 7. Postconditions: bytes, integrity, reconciliation, and nothing else changed.
309
- const problems = [];
310
- for (const path of GENERATED_PATHS) {
311
- const after = hashOf(projectDir, path);
312
- if (after !== expected[path])
313
- problems.push(`${path} is ${after ?? "absent"}, expected ${expected[path]}`);
314
- else
315
- postconditions.push(`${path} ${after}`);
316
- }
317
- const integrity = checkFoundation(readGeneratedState(projectDir), options.catalog, options.profiles);
318
- if (!integrity.ok)
319
- problems.push(`integrity: ${integrity.problems.map((p) => p.code).join(", ")}`);
320
- else
321
- postconditions.push("`feltkit compose --check` passes");
322
- const after = await reconcile(projectDir, options);
323
- if (after.state !== "CURRENT")
324
- problems.push(`reconciliation ${after.state}: ${after.findings.map((f) => f.code).join(", ")}`);
325
- else
326
- postconditions.push("reconciliation CURRENT");
327
- const sourcesAfter = applicationSources(projectDir);
328
- if (canonical(sourcesAfter) !== canonical(plan.current.sources))
329
- problems.push("application sources changed during execution");
330
- else
331
- postconditions.push("application sources byte-identical");
332
- const extra = Object.keys(sourcesAfter).filter((p) => !(p in plan.current.sources));
333
- if (extra.length)
334
- problems.push(`unexpected application files: ${extra.join(", ")}`);
335
- if (problems.length) {
336
- evidence.push(...problems);
337
- journalState = { ...journalState, failure: problems.join("; ") };
338
- writeJournal(projectDir, journalState);
339
- return outcome(files(), { operations: { executed, skipped: [], refused: [] }, transaction: { id: transaction, journal: JOURNAL_PATH, outcome: "committed" }, reconciliation: { format: RECONCILIATION_FORMAT, state: after.state, findings: after.findings.map((f) => f.code) } }, "POSTCONDITION_FAILED", `The files were written, but the result is not what the plan promised: ${problems.join("; ")}. ${JOURNAL_PATH} records prior and expected hashes; nothing was undone.`, plan);
340
- }
341
- // 8. Done: the journal is complete and removed (its evidence is in this result).
342
- journalState = { ...journalState, phase: "verified" };
343
- writeJournal(projectDir, journalState);
344
- options.hooks?.beforeJournalRemoval?.();
345
- unlinkSync(join(projectDir, JOURNAL_PATH));
346
- executed.push(...plan.operations.filter((o) => o.type === "revalidate-application").map((o) => o.id));
347
- const skipped = writeOps.filter((o) => !toWrite.includes(o.target)).map((o) => ({ id: o.id, reason: "bytes already the target's" }));
348
- return outcome(files(), { operations: { executed, skipped, refused: [] }, transaction: { id: transaction, journal: JOURNAL_PATH, outcome: "committed" }, reconciliation: { format: RECONCILIATION_FORMAT, state: after.state, findings: [] } }, "APPLIED", `Applied plan ${plan.id}: ${toWrite.join(", ")} written; integrity and reconciliation verified.`, plan);
349
- }
350
- //# sourceMappingURL=execute.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/composition/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtK,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7J,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAA4E,MAAM,WAAW,CAAC;AACnK,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,SAAS,EAA4B,MAAM,gBAAgB,CAAC;AAEhH,MAAM,CAAC,MAAM,gBAAgB,GAAG,iCAAiC,CAAC;AAClE,MAAM,CAAC,MAAM,MAAM,GAAG,yBAAyB,CAAC;AAChD,MAAM,CAAC,MAAM,cAAc,GAAG,+BAA+B,CAAC;AAC9D,mHAAmH;AACnH,MAAM,CAAC,MAAM,WAA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Ac,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,gBAAgB,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,kDAAkD,EAAE,IAAI,CAAC,CAAC;AACrW,CAAC"}
@@ -1,105 +0,0 @@
1
- import type { Capability, CapabilityId, CompositionError, Profile, ResolvedComposition } from "./contract.js";
2
- /** The generated-file format. A change to what the generator writes for the same resolution is a new version. */
3
- export declare const GENERATOR_VERSION = 1;
4
- export declare const GENERATOR = "feltkit-compose/1";
5
- export declare const RECORD_PATH = "feltkit.composition.json";
6
- export declare const LOCK_PATH = "feltkit.composition.lock.json";
7
- export declare const DECLARATION_PATH = "feltkit/_foundation/declaration.ts";
8
- export declare const GENERATED_PATHS: readonly ["feltkit/_foundation/declaration.ts", "feltkit.composition.json", "feltkit.composition.lock.json"];
9
- declare const RECORD_FORMAT = "feltkit.composition/1";
10
- declare const LOCK_FORMAT = "feltkit.composition-lock/1";
11
- /** What a developer chooses. Plain data only: it is written to the record. */
12
- export interface CompositionInputs {
13
- profile: string;
14
- include: string[];
15
- params: Record<string, Record<string, unknown>>;
16
- }
17
- export interface CompositionRecord {
18
- format: typeof RECORD_FORMAT;
19
- profile: {
20
- id: string;
21
- version: number;
22
- };
23
- include: string[];
24
- /** The parameters the developer gave (defaults are not repeated: they belong to the catalog). */
25
- params: Record<string, Record<string, unknown>>;
26
- capabilities: Array<{
27
- id: string;
28
- version: number;
29
- }>;
30
- /** What the profile requires that the declaration cannot enforce (owned by the application). */
31
- limitations: string[];
32
- /** What the platform enforces for every application (ENFORCED_GUARANTEES): not the application's to uphold. */
33
- enforced: string[];
34
- /** sha256 of the resolution: profile and each capability's version and resolved parameters. */
35
- composition: string;
36
- generator: string;
37
- /** FeltKit that generated it; the declaration is typed against this SDK's FeltKitOptions. */
38
- sdk: {
39
- feltkit: string;
40
- };
41
- inputs: string;
42
- outputs: Record<string, string>;
43
- }
44
- export interface CompositionLock {
45
- format: typeof LOCK_FORMAT;
46
- generator: string;
47
- profile: {
48
- id: string;
49
- version: number;
50
- fingerprint: string;
51
- };
52
- capabilities: Array<{
53
- id: string;
54
- version: number;
55
- fingerprint: string;
56
- }>;
57
- files: Record<string, {
58
- owner: "generator";
59
- sha256: string;
60
- }>;
61
- }
62
- export type GenerateResult = {
63
- ok: true;
64
- files: Record<(typeof GENERATED_PATHS)[number], string>;
65
- record: CompositionRecord;
66
- lock: CompositionLock;
67
- resolved: ResolvedComposition;
68
- } | {
69
- ok: false;
70
- errors: CompositionError[];
71
- };
72
- /** Where a value is not plain JSON data (a function, a schema, undefined, a non-finite number), or null. */
73
- export declare function nonDataAt(value: unknown, path?: string): string | null;
74
- /** JSON with object keys sorted at every level: the same data always serializes to the same bytes. */
75
- export declare function canonical(value: unknown): string;
76
- export declare const sha256: (text: string) => string;
77
- /** A capability's definition as data: what a change to it would alter (its functions show in the output hash). */
78
- export declare function capabilityFingerprint(c: Capability): string;
79
- export declare function profileFingerprint(p: Profile): string;
80
- /** The three generator-owned files for these inputs, or every error in the way. Pure and deterministic. */
81
- export declare function generateFoundation(inputs: CompositionInputs, catalog?: ReadonlyMap<CapabilityId, Capability>, profiles?: ReadonlyMap<string, Profile>): GenerateResult;
82
- export type IntegrityCode = "RECORD_MISSING" | "RECORD_MALFORMED" | "LOCK_MISSING" | "LOCK_MALFORMED" | "RECORD_MODIFIED" | "GENERATED_FILE_MISSING" | "GENERATED_FILE_MODIFIED" | "UNTRACKED_GENERATED_FILE" | "GENERATOR_CHANGED" | "PROFILE_CHANGED" | "CAPABILITY_CHANGED" | "COMPOSITION_INVALID" | "OUTPUT_CHANGED";
83
- export interface IntegrityProblem {
84
- code: IntegrityCode;
85
- message: string;
86
- file?: string;
87
- expected?: string;
88
- observed?: string;
89
- /** Safe ways forward, none of which discards anyone's change. */
90
- recovery: string[];
91
- }
92
- /** The files as they are on disk (null: absent). */
93
- export type GeneratedState = Partial<Record<(typeof GENERATED_PATHS)[number], string | null>>;
94
- /**
95
- * Whether the generator-owned files are exactly what the recorded composition produces now. Problems
96
- * are listed, never fixed: this function changes nothing.
97
- */
98
- export declare function checkFoundation(state: GeneratedState, catalog?: ReadonlyMap<CapabilityId, Capability>, profiles?: ReadonlyMap<string, Profile>): {
99
- ok: boolean;
100
- problems: IntegrityProblem[];
101
- record: CompositionRecord | null;
102
- lock: CompositionLock | null;
103
- regenerated: GenerateResult | null;
104
- };
105
- export {};