@forgeax/engine-ddc 0.1.2

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 (82) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +136 -0
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/__tests__/concurrency.integration.test.d.ts +2 -0
  5. package/dist/__tests__/concurrency.integration.test.d.ts.map +1 -0
  6. package/dist/__tests__/consumer-path.integration.test.d.ts +2 -0
  7. package/dist/__tests__/consumer-path.integration.test.d.ts.map +1 -0
  8. package/dist/__tests__/crash-recovery.integration.test.d.ts +2 -0
  9. package/dist/__tests__/crash-recovery.integration.test.d.ts.map +1 -0
  10. package/dist/__tests__/entry-store.integration.test.d.ts +2 -0
  11. package/dist/__tests__/entry-store.integration.test.d.ts.map +1 -0
  12. package/dist/__tests__/errors.unit.test.d.ts +2 -0
  13. package/dist/__tests__/errors.unit.test.d.ts.map +1 -0
  14. package/dist/__tests__/key.unit.test.d.ts +2 -0
  15. package/dist/__tests__/key.unit.test.d.ts.map +1 -0
  16. package/dist/__tests__/layout.unit.test.d.ts +2 -0
  17. package/dist/__tests__/layout.unit.test.d.ts.map +1 -0
  18. package/dist/__tests__/lifecycle.unit.test.d.ts +2 -0
  19. package/dist/__tests__/lifecycle.unit.test.d.ts.map +1 -0
  20. package/dist/__tests__/multiprocess-gc.integration.test.d.ts +2 -0
  21. package/dist/__tests__/multiprocess-gc.integration.test.d.ts.map +1 -0
  22. package/dist/__tests__/multiprocess-lifecycle.integration.test.d.ts +2 -0
  23. package/dist/__tests__/multiprocess-lifecycle.integration.test.d.ts.map +1 -0
  24. package/dist/__tests__/multiprocess-worker.d.ts +2 -0
  25. package/dist/__tests__/multiprocess-worker.d.ts.map +1 -0
  26. package/dist/__tests__/status-root-kind-owner.test-d.d.ts +2 -0
  27. package/dist/__tests__/status-root-kind-owner.test-d.d.ts.map +1 -0
  28. package/dist/__tests__/status.unit.test.d.ts +2 -0
  29. package/dist/__tests__/status.unit.test.d.ts.map +1 -0
  30. package/dist/entry-store.d.ts +52 -0
  31. package/dist/entry-store.d.ts.map +1 -0
  32. package/dist/entry-store.mjs +339 -0
  33. package/dist/entry-store.mjs.map +1 -0
  34. package/dist/errors.d.ts +58 -0
  35. package/dist/errors.d.ts.map +1 -0
  36. package/dist/errors.mjs +109 -0
  37. package/dist/errors.mjs.map +1 -0
  38. package/dist/gc.d.ts +13 -0
  39. package/dist/gc.d.ts.map +1 -0
  40. package/dist/index.d.ts +9 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.mjs +896 -0
  43. package/dist/index.mjs.map +1 -0
  44. package/dist/key.d.ts +13 -0
  45. package/dist/key.d.ts.map +1 -0
  46. package/dist/key.mjs +38 -0
  47. package/dist/key.mjs.map +1 -0
  48. package/dist/layout.d.ts +51 -0
  49. package/dist/layout.d.ts.map +1 -0
  50. package/dist/layout.mjs +68 -0
  51. package/dist/layout.mjs.map +1 -0
  52. package/dist/lifecycle.d.ts +55 -0
  53. package/dist/lifecycle.d.ts.map +1 -0
  54. package/dist/runtime-scope.d.ts +10 -0
  55. package/dist/runtime-scope.d.ts.map +1 -0
  56. package/dist/status.d.ts +39 -0
  57. package/dist/status.d.ts.map +1 -0
  58. package/dist/status.mjs +20 -0
  59. package/dist/status.mjs.map +1 -0
  60. package/package.json +98 -0
  61. package/src/__tests__/concurrency.integration.test.ts +53 -0
  62. package/src/__tests__/consumer-path.integration.test.ts +61 -0
  63. package/src/__tests__/crash-recovery.integration.test.ts +84 -0
  64. package/src/__tests__/entry-store.integration.test.ts +83 -0
  65. package/src/__tests__/errors.unit.test.ts +54 -0
  66. package/src/__tests__/key.unit.test.ts +49 -0
  67. package/src/__tests__/layout.unit.test.ts +50 -0
  68. package/src/__tests__/lifecycle.unit.test.ts +258 -0
  69. package/src/__tests__/multiprocess-gc.integration.test.ts +36 -0
  70. package/src/__tests__/multiprocess-lifecycle.integration.test.ts +109 -0
  71. package/src/__tests__/multiprocess-worker.ts +41 -0
  72. package/src/__tests__/status-root-kind-owner.test-d.ts +42 -0
  73. package/src/__tests__/status.unit.test.ts +56 -0
  74. package/src/entry-store.ts +307 -0
  75. package/src/errors.ts +164 -0
  76. package/src/gc.ts +34 -0
  77. package/src/index.ts +65 -0
  78. package/src/key.ts +46 -0
  79. package/src/layout.ts +132 -0
  80. package/src/lifecycle.ts +549 -0
  81. package/src/runtime-scope.ts +87 -0
  82. package/src/status.ts +58 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/key.ts","../src/entry-store.ts","../src/lifecycle.ts","../src/gc.ts","../src/layout.ts","../src/runtime-scope.ts","../src/status.ts"],"names":["createHash","join","mkdir","writeFile","rm","readFile","randomUUID","rename","readdir"],"mappings":";;;;;;;AAAO,IAAM,eAAA,GAAkB;AAAA,EAC7B,2BAAA;AAAA,EACA,qBAAA;AAAA,EACA,mBAAA;AAAA,EACA,yBAAA;AAAA,EACA,oBAAA;AAAA,EACA;AACF;AAmDA,IAAM,YAAA,GAA6C;AAAA,EACjD,2BAAA,EAA6B,kEAAA;AAAA,EAC7B,qBAAA,EAAuB,+DAAA;AAAA,EACvB,mBAAA,EAAqB,0DAAA;AAAA,EACrB,yBAAA,EAA2B,+DAAA;AAAA,EAC3B,oBAAA,EAAsB,uDAAA;AAAA,EACtB,mBAAA,EAAqB,kDAAA;AAAA,EACrB,sBAAA,EAAwB,+DAAA;AAAA,EACxB,mBAAA,EAAqB,6DAAA;AAAA,EACrB,oBAAA,EAAsB;AACxB,CAAA;AAEA,SAAS,gBAAgB,IAAA,EAA6B;AACpD,EAAA,IAAI,IAAA,KAAS,6BAA6B,OAAO,gBAAA;AACjD,EAAA,IAAI,IAAA,KAAS,sBAAA,IAA0B,IAAA,KAAS,mBAAA,EAAqB;AACnE,IAAA,OAAO,mEAAA;AAAA,EACT;AACA,EAAA,OAAO,2DAAA;AACT;AAEA,SAAS,eAAe,IAAA,EAAkD;AACxE,EAAA,QAAQ,IAA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c,YAAA,EAAc;AACpC,IAAA,MAAM,IAAI,aAAA,CAAc;AAAA,MACtB,IAAA,EAAM,oBAAA;AAAA,MACN,MAAA,EAAQ,yDAAA;AAAA,MACR,QAAA,EAAU,YAAA;AAAA,MACV,QAAQ,KAAA,CAAM,SAAA;AAAA,MACd,QAAA,EAAU,aAAA;AAAA,MACV,OAAO,KAAA,CAAM;AAAA,KACd,CAAA;AAAA,EACH;AACA,EAAA,OAAO,kBAAA,CAAmB,IAAA,EAAM,KAAA,CAAM,OAAO,CAAA;AAC/C;;;ACpFO,IAAM,iBAAA,GAAoB;AAwC1B,SAAS,mBAAmB,MAAA,EAA2B;AAC5D,EAAA,OAAO,IAAA,CAAK,UAAU,MAAM,CAAA;AAC9B;AAEO,SAAS,2BAA2B,MAAA,EAAqC;AAC9E,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,iBAAA;AAAA,IACf,QAAQ,MAAA,CAAO,MAAA;AAAA,IACf,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,MAAW;AAAA,MACpC,GAAG,KAAA;AAAA,MACH,OAAA,EAAS,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,CAAC,EAAE,WAAA,EAAa,YAAA,EAAc,GAAG,MAAA,EAAO,KAAM,MAAM;AAAA,KACjF,CAAE;AAAA,GACJ;AACF;AAEO,IAAM,kBAAA,GAAqB","file":"index.mjs","sourcesContent":["export const DDC_ERROR_CODES = [\n 'ddc-project-root-required',\n 'ddc-object-conflict',\n 'ddc-head-conflict',\n 'ddc-generation-conflict',\n 'ddc-scope-mismatch',\n 'ddc-lease-expired',\n] as const;\n\nexport type DdcContractErrorCode = (typeof DDC_ERROR_CODES)[number];\nexport type DdcEntryErrorCode = 'ddc-entry-incomplete' | 'ddc-entry-invalid' | 'ddc-entry-conflict';\nexport type DdcErrorCode = DdcContractErrorCode | DdcEntryErrorCode;\n\nexport type DdcErrorRootKind = 'build-cache' | 'project-ddc' | 'runtime';\n\nexport interface DdcRecoveryAction {\n readonly kind:\n | 'inspect'\n | 'allocate-generation'\n | 'retry'\n | 'cold-rebuild'\n | 'prune'\n | 'release-lease';\n readonly executable: boolean;\n readonly exactTarget?: string;\n readonly reason?: string;\n}\n\nexport interface DdcStoreErrorInit {\n readonly code: DdcErrorCode;\n readonly detail: string;\n readonly hint?: string;\n readonly expected?: unknown;\n readonly actual?: unknown;\n readonly owner?: string;\n readonly rootKind?: DdcErrorRootKind;\n readonly scope?: string;\n readonly generation?: number;\n readonly lease?: string;\n readonly revision?: number;\n readonly recoveryActions?: readonly DdcRecoveryAction[];\n readonly hostPath?: string;\n}\n\nexport interface DdcBrowserError {\n readonly code: DdcErrorCode;\n readonly hint: string;\n readonly expected: unknown;\n readonly actual?: unknown;\n readonly owner?: string;\n readonly rootKind?: DdcErrorRootKind;\n readonly scope?: string;\n readonly generation?: number;\n readonly lease?: string;\n readonly revision?: number;\n readonly recoveryActions: readonly Omit<DdcRecoveryAction, 'exactTarget'>[];\n}\n\nconst defaultHints: Record<DdcErrorCode, string> = {\n 'ddc-project-root-required': 'inject the canonical projectDdcRoot before serving or publishing',\n 'ddc-object-conflict': 'keep the verified object and reject the competing publication',\n 'ddc-head-conflict': 'inspect the current head and retry with a fresh revision',\n 'ddc-generation-conflict': 'allocate a new persistent generation; do not edit the counter',\n 'ddc-scope-mismatch': 'reinspect the canonical root and allocate a new scope',\n 'ddc-lease-expired': 'discard the stale commit and acquire a new lease',\n 'ddc-entry-incomplete': 'discard the partial entry and cold-cook from author authority',\n 'ddc-entry-invalid': 'preserve last-known-good, inspect the entry, then cold-cook',\n 'ddc-entry-conflict': 'keep the verified entry and reject the competing publication',\n};\n\nfunction defaultExpected(code: DdcErrorCode): unknown {\n if (code === 'ddc-project-root-required') return 'projectDdcRoot';\n if (code === 'ddc-entry-incomplete' || code === 'ddc-entry-invalid') {\n return 'a complete DDC entry whose receipt and integrity digests validate';\n }\n return 'a valid DDC owner, scope, generation, revision, and lease';\n}\n\nfunction defaultActions(code: DdcErrorCode): readonly DdcRecoveryAction[] {\n switch (code) {\n case 'ddc-project-root-required':\n case 'ddc-scope-mismatch':\n return [\n { kind: 'inspect', executable: true },\n { kind: 'retry', executable: true },\n ];\n case 'ddc-generation-conflict':\n return [{ kind: 'allocate-generation', executable: true }];\n case 'ddc-lease-expired':\n return [\n { kind: 'release-lease', executable: true },\n { kind: 'retry', executable: true },\n ];\n case 'ddc-object-conflict':\n case 'ddc-head-conflict':\n return [\n { kind: 'inspect', executable: true },\n { kind: 'retry', executable: true },\n ];\n case 'ddc-entry-incomplete':\n case 'ddc-entry-invalid':\n return [{ kind: 'cold-rebuild', executable: true }];\n case 'ddc-entry-conflict':\n return [{ kind: 'inspect', executable: true }];\n }\n}\n\nexport class DdcStoreError extends Error {\n public readonly code: DdcErrorCode;\n public readonly detail: string;\n public readonly hint: string;\n public readonly expected: unknown;\n public readonly actual: unknown;\n public readonly owner: string | undefined;\n public readonly rootKind: DdcErrorRootKind | undefined;\n public readonly scope: string | undefined;\n public readonly generation: number | undefined;\n public readonly lease: string | undefined;\n public readonly revision: number | undefined;\n public readonly recoveryActions: readonly DdcRecoveryAction[];\n public readonly hostPath: string | undefined;\n\n public constructor(code: DdcErrorCode, detail: string);\n public constructor(input: DdcStoreErrorInit);\n public constructor(inputOrCode: DdcStoreErrorInit | DdcErrorCode, legacyDetail?: string) {\n const input: DdcStoreErrorInit =\n typeof inputOrCode === 'string'\n ? { code: inputOrCode, detail: legacyDetail ?? inputOrCode }\n : inputOrCode;\n super(input.detail);\n this.name = 'DdcStoreError';\n this.code = input.code;\n this.detail = input.detail;\n this.hint = input.hint ?? defaultHints[input.code];\n this.expected = input.expected ?? defaultExpected(input.code);\n this.actual = input.actual;\n this.owner = input.owner;\n this.rootKind = input.rootKind;\n this.scope = input.scope;\n this.generation = input.generation;\n this.lease = input.lease;\n this.revision = input.revision;\n this.recoveryActions = input.recoveryActions ?? defaultActions(input.code);\n this.hostPath = input.hostPath;\n }\n\n public toBrowserProjection(): DdcBrowserError {\n return {\n code: this.code,\n hint: this.hint,\n expected: this.expected,\n ...(this.actual === undefined ? {} : { actual: this.actual }),\n ...(this.owner === undefined ? {} : { owner: this.owner }),\n ...(this.rootKind === undefined ? {} : { rootKind: this.rootKind }),\n ...(this.scope === undefined ? {} : { scope: this.scope }),\n ...(this.generation === undefined ? {} : { generation: this.generation }),\n ...(this.lease === undefined ? {} : { lease: this.lease }),\n ...(this.revision === undefined ? {} : { revision: this.revision }),\n recoveryActions: this.recoveryActions.map(\n ({ exactTarget: _exactTarget, ...action }) => action,\n ),\n };\n }\n}\n","import { createHash } from 'node:crypto';\n\nexport interface SemanticDdcInput {\n readonly schemaVersion: string;\n readonly importer: string;\n readonly codec: string;\n readonly settings: unknown;\n readonly sourceBytes: readonly Uint8Array[];\n readonly declaredGuids: readonly string[];\n readonly targetProfile: string;\n readonly producer: string;\n}\n\nexport function canonicalDdcJson(value: unknown): string {\n const sorted = sortValue(value);\n return JSON.stringify(sorted) ?? 'null';\n}\n\nfunction sortValue(value: unknown): unknown {\n if (value instanceof Uint8Array) {\n return { encoding: 'base64', bytes: Buffer.from(value).toString('base64') };\n }\n if (Array.isArray(value)) return value.map(sortValue);\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value as Record<string, unknown>).sort()) {\n result[key] = sortValue((value as Record<string, unknown>)[key]);\n }\n return result;\n }\n return value;\n}\n\nexport function semanticDdcKey(input: SemanticDdcInput): string {\n const semantic = {\n schemaVersion: input.schemaVersion,\n importer: input.importer,\n codec: input.codec,\n settings: input.settings,\n sourceBytes: input.sourceBytes,\n declaredGuids: [...input.declaredGuids].sort(),\n targetProfile: input.targetProfile,\n producer: input.producer,\n };\n return createHash('sha256').update(canonicalDdcJson(semantic)).digest('hex');\n}\n","import { createHash, randomUUID } from 'node:crypto';\nimport { mkdir, readdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { DdcStoreError } from './errors.js';\nimport { canonicalDdcJson } from './key.js';\n\nexport { DdcStoreError } from './errors.js';\n\nexport interface DdcArtifact {\n readonly mediaType: string;\n readonly bytes: Uint8Array;\n}\n\nexport interface DdcReceipt {\n readonly guid: string;\n readonly key: string;\n readonly producer: string;\n readonly inputFingerprint: string;\n readonly outputDigest: string;\n}\n\nexport interface DdcEntry {\n readonly key: string;\n readonly guid: string;\n readonly payload: unknown;\n readonly refs: readonly string[];\n readonly artifacts: Readonly<Record<string, DdcArtifact>>;\n readonly receipt: DdcReceipt;\n}\n\nexport interface StagedDdcEntry {\n readonly key: string;\n readonly path: string;\n}\n\nexport interface PublishDdcEntryResult {\n readonly result: 'published' | 'existing' | 'conflict';\n readonly key: string;\n}\n\ninterface ArtifactIntegrity {\n readonly mediaType: string;\n readonly byteLength: number;\n readonly digest: string;\n}\n\ninterface EntryIntegrity {\n readonly payload: string;\n readonly refs: string;\n readonly receipt: string;\n readonly artifacts: Readonly<Record<string, ArtifactIntegrity>>;\n readonly entry: string;\n}\n\nfunction digest(value: string | Uint8Array): string {\n return createHash('sha256').update(value).digest('hex');\n}\n\nfunction artifactFile(key: string): string {\n if (/^[A-Za-z0-9._-]+$/.test(key)) return key;\n return Buffer.from(key, 'utf8').toString('base64url');\n}\n\nfunction validateKey(key: string): void {\n if (!/^[a-f0-9]{64}$/.test(key)) {\n throw new DdcStoreError('ddc-entry-invalid', `invalid semantic key: ${key}`);\n }\n}\n\nfunction errorCode(error: unknown): string | undefined {\n if (error !== null && typeof error === 'object' && 'code' in error) {\n const code = (error as { readonly code?: unknown }).code;\n return typeof code === 'string' ? code : undefined;\n }\n return undefined;\n}\n\nfunction sortedArtifacts(entry: DdcEntry): readonly [string, DdcArtifact][] {\n return Object.entries(entry.artifacts).sort(([left], [right]) => left.localeCompare(right));\n}\n\n/** The one output identity shared by receipt validation and DDC publication. */\nexport function ddcOutputDigest(\n entry: Pick<DdcEntry, 'guid' | 'payload' | 'refs' | 'artifacts'>,\n): string {\n return `sha256:${digest(\n canonicalDdcJson({\n guid: entry.guid,\n payload: entry.payload,\n refs: entry.refs,\n artifacts: Object.fromEntries(\n sortedArtifacts(entry as DdcEntry).map(([key, artifact]) => [\n key,\n {\n mediaType: artifact.mediaType,\n bytes: artifact.bytes,\n },\n ]),\n ),\n }),\n )}`;\n}\n\nfunction existingResult(\n existing: DdcEntry,\n candidate: DdcEntry,\n key: string,\n): PublishDdcEntryResult {\n return canonicalDdcJson(existing) === canonicalDdcJson(candidate)\n ? { result: 'existing', key }\n : { result: 'conflict', key };\n}\n\nfunction entryShape(entry: DdcEntry): Record<string, unknown> {\n return {\n key: entry.key,\n guid: entry.guid,\n payload: entry.payload,\n refs: entry.refs,\n receipt: entry.receipt,\n artifacts: Object.fromEntries(\n sortedArtifacts(entry).map(([key, artifact]) => [\n key,\n { mediaType: artifact.mediaType, byteLength: artifact.bytes.byteLength },\n ]),\n ),\n };\n}\n\nfunction integrityFor(entry: DdcEntry): EntryIntegrity {\n const artifacts = Object.fromEntries(\n sortedArtifacts(entry).map(([key, artifact]) => [\n key,\n {\n mediaType: artifact.mediaType,\n byteLength: artifact.bytes.byteLength,\n digest: digest(artifact.bytes),\n },\n ]),\n );\n return {\n payload: digest(canonicalDdcJson(entry.payload)),\n refs: digest(canonicalDdcJson(entry.refs)),\n receipt: digest(canonicalDdcJson(entry.receipt)),\n artifacts,\n entry: digest(canonicalDdcJson(entryShape(entry))),\n };\n}\n\nasync function readJson<T>(path: string): Promise<T> {\n return JSON.parse(await readFile(path, 'utf8')) as T;\n}\n\nexport class DdcEntryStore {\n private readonly entries: string;\n private readonly staging: string;\n\n public constructor(root: string) {\n this.entries = join(root, 'entries');\n this.staging = join(root, 'staging');\n }\n\n public async stage(entry: DdcEntry): Promise<StagedDdcEntry> {\n validateKey(entry.key);\n if (entry.receipt.key !== entry.key || entry.receipt.guid !== entry.guid) {\n throw new DdcStoreError('ddc-entry-invalid', 'receipt identity does not match entry');\n }\n if (entry.receipt.outputDigest !== ddcOutputDigest(entry)) {\n throw new DdcStoreError('ddc-entry-invalid', 'receipt output digest does not match entry');\n }\n const path = join(this.staging, `${entry.key}-${randomUUID()}`);\n await mkdir(join(path, 'artifacts'), { recursive: true });\n await writeFile(join(path, 'payload.json'), canonicalDdcJson(entry.payload));\n await writeFile(join(path, 'refs.json'), canonicalDdcJson(entry.refs));\n await writeFile(join(path, 'receipt.json'), canonicalDdcJson(entry.receipt));\n const artifacts: Record<string, { mediaType: string; file: string }> = {};\n for (const [key, artifact] of sortedArtifacts(entry)) {\n const file = artifactFile(key);\n artifacts[key] = { mediaType: artifact.mediaType, file };\n await writeFile(join(path, 'artifacts', `${file}.bin`), artifact.bytes);\n }\n await writeFile(join(path, 'artifacts.json'), canonicalDdcJson(artifacts));\n await writeFile(join(path, 'integrity.json'), canonicalDdcJson(integrityFor(entry)));\n return { key: entry.key, path };\n }\n\n public async publish(staged: StagedDdcEntry): Promise<PublishDdcEntryResult> {\n validateKey(staged.key);\n const candidate = await this.readDirectory(staged.path, true);\n const target = join(this.entries, staged.key);\n await mkdir(this.entries, { recursive: true });\n try {\n await stat(target);\n const existing = await this.readDirectory(target, false);\n await rm(staged.path, { recursive: true, force: true });\n return existingResult(existing, candidate, staged.key);\n } catch (error) {\n if (error instanceof DdcStoreError) throw error;\n if (errorCode(error) !== 'ENOENT') throw error;\n }\n try {\n await rename(staged.path, target);\n return { result: 'published', key: staged.key };\n } catch (error) {\n if (!['EEXIST', 'ENOTEMPTY', 'EISDIR'].includes(errorCode(error) ?? '')) throw error;\n const existing = await this.readDirectory(target, false);\n await rm(staged.path, { recursive: true, force: true });\n return existingResult(existing, candidate, staged.key);\n }\n }\n\n public async write(entry: DdcEntry): Promise<PublishDdcEntryResult> {\n const staged = await this.stage(entry);\n return this.publish(staged);\n }\n\n public async read(key: string): Promise<DdcEntry | null> {\n try {\n validateKey(key);\n return await this.readDirectory(join(this.entries, key), false);\n } catch {\n return null;\n }\n }\n\n public async listKeys(): Promise<readonly string[]> {\n const entries = await readdir(this.entries, { withFileTypes: true }).catch(() => []);\n return entries\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort();\n }\n\n public async remove(key: string): Promise<void> {\n validateKey(key);\n await rm(join(this.entries, key), { recursive: true, force: false });\n }\n\n /** Read with a machine-readable corruption result for recovery tooling. */\n public async readChecked(\n key: string,\n ): Promise<\n | { readonly ok: true; readonly value: DdcEntry | null }\n | { readonly ok: false; readonly error: DdcStoreError }\n > {\n try {\n validateKey(key);\n try {\n await stat(join(this.entries, key));\n } catch (error) {\n if (errorCode(error) === 'ENOENT') return { ok: true, value: null };\n throw error;\n }\n try {\n return { ok: true, value: await this.readDirectory(join(this.entries, key), false) };\n } catch (error) {\n if (error instanceof DdcStoreError && error.code === 'ddc-entry-incomplete') {\n return { ok: true, value: null };\n }\n throw error;\n }\n } catch (error) {\n const normalized =\n error instanceof DdcStoreError\n ? error\n : new DdcStoreError('ddc-entry-invalid', 'entry is unreadable');\n return { ok: false, error: normalized };\n }\n }\n\n private async readDirectory(path: string, incompleteIsError: boolean): Promise<DdcEntry> {\n try {\n const payload = await readJson<unknown>(join(path, 'payload.json'));\n const refs = await readJson<readonly string[]>(join(path, 'refs.json'));\n const receipt = await readJson<DdcReceipt>(join(path, 'receipt.json'));\n const manifest = await readJson<\n Readonly<Record<string, { mediaType: string; file: string }>>\n >(join(path, 'artifacts.json'));\n const integrity = await readJson<EntryIntegrity>(join(path, 'integrity.json'));\n const artifacts: Record<string, DdcArtifact> = {};\n for (const [key, descriptor] of Object.entries(manifest).sort(([left], [right]) =>\n left.localeCompare(right),\n )) {\n const bytes = new Uint8Array(\n await readFile(join(path, 'artifacts', `${descriptor.file}.bin`)),\n );\n artifacts[key] = { mediaType: descriptor.mediaType, bytes };\n }\n const entry = { key: receipt.key, guid: receipt.guid, payload, refs, artifacts, receipt };\n if (entry.receipt.outputDigest !== ddcOutputDigest(entry)) {\n throw new DdcStoreError('ddc-entry-invalid', 'receipt output digest does not match entry');\n }\n const actual = integrityFor(entry);\n if (canonicalDdcJson(actual) !== canonicalDdcJson(integrity)) {\n throw new DdcStoreError('ddc-entry-invalid', 'entry integrity mismatch');\n }\n return entry;\n } catch (error) {\n if (incompleteIsError) {\n if (error instanceof DdcStoreError) throw error;\n throw new DdcStoreError('ddc-entry-incomplete', 'staged entry is incomplete');\n }\n if (error instanceof DdcStoreError) throw error;\n throw new DdcStoreError('ddc-entry-invalid', 'entry is unreadable');\n }\n }\n}\n","import { randomUUID } from 'node:crypto';\nimport { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { DdcEntryStore } from './entry-store.js';\nimport { DdcStoreError } from './errors.js';\n\nexport type DdcLifecycleState = 'missing' | 'cooking' | 'current' | 'stale' | 'failed';\n\nexport interface DdcLease {\n readonly guid: string;\n readonly desiredKey: string;\n readonly attempt: string;\n readonly generation: number;\n readonly expectedRevision: number;\n readonly instanceId: string;\n readonly expiresAt: number;\n}\n\nexport interface DdcHead {\n readonly guid: string;\n readonly desiredKey: string;\n readonly state: DdcLifecycleState;\n readonly currentKey: string | undefined;\n readonly lastKnownGoodKey: string | undefined;\n readonly revision?: number;\n readonly generation?: number;\n readonly activeLease?: DdcLease;\n readonly failure?: { readonly code: string; readonly detail: string };\n}\n\nexport interface DdcCommitResult {\n readonly result: 'current' | 'stale' | 'lease-lost' | 'invalid';\n readonly key: string;\n readonly revision?: number;\n}\n\ninterface HeadRecord {\n readonly guid: string;\n readonly desiredKey: string;\n readonly revision: number;\n readonly currentKey?: string;\n readonly lastKnownGoodKey?: string;\n readonly generation?: number;\n readonly active?: DdcLease;\n readonly supersededAttempts?: readonly string[];\n readonly stale?: boolean;\n readonly failure?: {\n readonly desiredKey: string;\n readonly code: string;\n readonly detail: string;\n };\n}\n\ninterface GenerationRecord {\n readonly schemaVersion: 'forgeax-ddc-generation/v2';\n readonly next: number;\n}\n\nconst LOCK_WAIT_MS = 10;\nconst LOCK_TIMEOUT_MS = 5000;\nconst LEASE_TTL_MS = 30_000;\n\nfunction headFile(heads: string, guid: string): string {\n return join(heads, `${encodeURIComponent(guid)}.json`);\n}\n\nfunction lockFile(root: string, name: string): string {\n return join(root, 'locks', `${encodeURIComponent(name)}.lock`);\n}\n\nfunction withRevision(\n result: Omit<DdcCommitResult, 'revision'>,\n revision: number,\n): DdcCommitResult {\n const value = { ...result } as DdcCommitResult;\n Object.defineProperty(value, 'revision', { value: revision, enumerable: false });\n return value;\n}\n\nasync function delay(ms: number): Promise<void> {\n await new Promise((resolveDelay) => setTimeout(resolveDelay, ms));\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\nfunction isNonNegativeInteger(value: unknown): value is number {\n return typeof value === 'number' && Number.isInteger(value) && value >= 0;\n}\n\nfunction isLeaseRecord(value: unknown): value is DdcLease {\n if (!isRecord(value)) return false;\n return (\n isString(value.guid) &&\n isString(value.desiredKey) &&\n isString(value.attempt) &&\n isNonNegativeInteger(value.generation) &&\n isNonNegativeInteger(value.expectedRevision) &&\n isString(value.instanceId) &&\n typeof value.expiresAt === 'number' &&\n Number.isFinite(value.expiresAt)\n );\n}\n\nfunction isHeadRecord(value: unknown): value is HeadRecord {\n if (!isRecord(value)) return false;\n if (\n !isString(value.guid) ||\n !isString(value.desiredKey) ||\n !isNonNegativeInteger(value.revision)\n ) {\n return false;\n }\n if (value.currentKey !== undefined && !isString(value.currentKey)) return false;\n if (value.lastKnownGoodKey !== undefined && !isString(value.lastKnownGoodKey)) return false;\n if (\n value.generation !== undefined &&\n (!isNonNegativeInteger(value.generation) || value.generation === 0)\n ) {\n return false;\n }\n if (value.active !== undefined && !isLeaseRecord(value.active)) return false;\n if (\n value.supersededAttempts !== undefined &&\n (!Array.isArray(value.supersededAttempts) || !value.supersededAttempts.every(isString))\n ) {\n return false;\n }\n if (value.stale !== undefined && typeof value.stale !== 'boolean') return false;\n if (value.failure !== undefined) {\n if (!isRecord(value.failure)) return false;\n if (\n !isString(value.failure.desiredKey) ||\n !isString(value.failure.code) ||\n !isString(value.failure.detail)\n ) {\n return false;\n }\n }\n return true;\n}\n\nfunction malformedHeadError(\n actual: 'syntax-invalid' | 'schema-invalid' | 'unreadable',\n): DdcStoreError {\n const detail =\n actual === 'syntax-invalid'\n ? 'DDC head JSON is syntactically invalid'\n : actual === 'schema-invalid'\n ? 'DDC head record does not match the lifecycle schema'\n : 'DDC head file is not readable';\n return new DdcStoreError({\n code: 'ddc-head-conflict',\n detail,\n expected: 'a valid DDC head record',\n actual,\n hint: 'inspect the current head and retry with a fresh revision',\n owner: 'engine-ddc',\n rootKind: 'project-ddc',\n recoveryActions: [\n { kind: 'inspect', executable: true },\n { kind: 'retry', executable: true },\n ],\n });\n}\n\n/** Cross-process mkdir lock; a lock owned by a dead PID is reclaimable. */\nexport async function withDdcLock<T>(\n root: string,\n name: string,\n operation: () => Promise<T>,\n): Promise<T> {\n const path = lockFile(root, name);\n await mkdir(join(root, 'locks'), { recursive: true });\n const deadline = Date.now() + LOCK_TIMEOUT_MS;\n while (true) {\n try {\n await mkdir(path);\n await writeFile(\n join(path, 'owner.json'),\n JSON.stringify({ pid: process.pid, acquiredAt: Date.now() }),\n );\n try {\n return await operation();\n } finally {\n await rm(path, { recursive: true, force: true });\n }\n } catch (error) {\n if ((error as { code?: string }).code !== 'EEXIST') throw error;\n let ownerPid: number | undefined;\n try {\n ownerPid = (\n JSON.parse(await readFile(join(path, 'owner.json'), 'utf8')) as { pid?: number }\n ).pid;\n } catch {\n ownerPid = undefined;\n }\n // mkdir() publishes the lock directory before the owner record can be\n // written. Treat that short publication window as an in-flight lock,\n // not as a dead owner: reclaiming it here lets two processes enter the\n // same critical section and loses the superseded-attempt fence.\n if (ownerPid === undefined) {\n if (Date.now() >= deadline) {\n throw new DdcStoreError({\n code: 'ddc-lease-expired',\n detail: `DDC lock ${name} did not publish an owner record`,\n hint: 'inspect the lock owner and retry after the incomplete instance exits',\n expected: 'a lock owner record',\n actual: { path },\n rootKind: 'project-ddc',\n });\n }\n await delay(LOCK_WAIT_MS);\n continue;\n }\n let alive = false;\n try {\n process.kill(ownerPid, 0);\n alive = true;\n } catch {\n alive = false;\n }\n if (!alive) {\n await rm(path, { recursive: true, force: true });\n continue;\n }\n if (Date.now() >= deadline) {\n throw new DdcStoreError({\n code: 'ddc-lease-expired',\n detail: `DDC lock ${name} remained owned by process ${ownerPid}`,\n hint: 'inspect the owner and retry after the stale instance exits',\n expected: 'an available project lock',\n actual: { ownerPid },\n rootKind: 'project-ddc',\n lease: String(ownerPid),\n });\n }\n await delay(LOCK_WAIT_MS);\n }\n }\n}\n\nexport class DdcLifecycle {\n private readonly heads: string;\n private readonly entries: DdcEntryStore;\n private readonly root: string;\n private readonly leaseTtlMs: number;\n\n public constructor(root: string, options?: { readonly leaseTtlMs?: number }) {\n this.root = root;\n this.heads = join(root, 'heads');\n this.entries = new DdcEntryStore(root);\n this.leaseTtlMs = options?.leaseTtlMs ?? LEASE_TTL_MS;\n }\n\n public async inspect(guid: string, desiredKey: string): Promise<DdcHead> {\n const record = await this.read(guid);\n if (record === null) {\n return {\n guid,\n desiredKey,\n state: 'missing',\n currentKey: undefined,\n lastKnownGoodKey: undefined,\n revision: 0,\n };\n }\n const recordedFailure =\n record.failure?.desiredKey === desiredKey\n ? { code: record.failure.code, detail: record.failure.detail }\n : undefined;\n const currentEntry =\n record.currentKey === undefined ? null : await this.entries.readChecked(record.currentKey);\n const entryFailure =\n currentEntry !== null && !currentEntry.ok\n ? { code: currentEntry.error.code, detail: currentEntry.error.detail }\n : undefined;\n const failure = recordedFailure ?? entryFailure;\n const currentValue = currentEntry?.ok === true ? currentEntry.value : null;\n const state: DdcLifecycleState =\n failure !== undefined\n ? 'failed'\n : record.currentKey === desiredKey && currentValue?.guid === guid\n ? 'current'\n : record.stale === true\n ? 'stale'\n : record.active?.desiredKey === desiredKey\n ? 'cooking'\n : 'stale';\n return {\n guid,\n desiredKey,\n state,\n currentKey: record.currentKey,\n lastKnownGoodKey: record.lastKnownGoodKey,\n revision: record.revision,\n ...(record.generation === undefined ? {} : { generation: record.generation }),\n ...(record.active === undefined ? {} : { activeLease: record.active }),\n ...(failure === undefined ? {} : { failure }),\n };\n }\n\n public async begin(guid: string, desiredKey: string): Promise<DdcLease> {\n return withDdcLock(this.root, `head-${guid}`, async () => {\n const previous = await this.read(guid);\n const generation = await this.allocateGeneration();\n const lease: DdcLease = {\n guid,\n desiredKey,\n attempt: randomUUID(),\n generation,\n expectedRevision: previous?.revision ?? 0,\n instanceId: `${process.pid}:${randomUUID()}`,\n expiresAt: Date.now() + this.leaseTtlMs,\n };\n const lastKnownGoodKey =\n previous?.currentKey !== undefined && previous.currentKey !== desiredKey\n ? previous.currentKey\n : previous?.lastKnownGoodKey;\n const supersededAttempts = [\n ...(previous?.supersededAttempts ?? []),\n ...(previous?.active === undefined ? [] : [previous.active.attempt]),\n ];\n await this.write({\n guid,\n desiredKey,\n revision: previous?.revision ?? 0,\n generation,\n active: lease,\n ...(previous?.currentKey === undefined ? {} : { currentKey: previous.currentKey }),\n ...(supersededAttempts.length === 0 ? {} : { supersededAttempts }),\n ...(lastKnownGoodKey === undefined ? {} : { lastKnownGoodKey }),\n });\n return lease;\n });\n }\n\n public async commit(lease: DdcLease, validatedKey: string): Promise<DdcCommitResult> {\n return withDdcLock(this.root, `head-${lease.guid}`, async () => {\n const current = await this.read(lease.guid);\n if (current?.active?.attempt !== lease.attempt) {\n if (current?.supersededAttempts?.includes(lease.attempt)) {\n await this.write({ ...current, stale: true });\n return withRevision({ result: 'stale', key: validatedKey }, current.revision);\n }\n return withRevision({ result: 'lease-lost', key: validatedKey }, current?.revision ?? 0);\n }\n if (Date.now() > lease.expiresAt) {\n throw new DdcStoreError({\n code: 'ddc-lease-expired',\n detail: 'cook lease expired before commit fencing',\n expected: { attempt: lease.attempt, revision: lease.expectedRevision },\n actual: { revision: current.revision },\n owner: 'engine-ddc',\n rootKind: 'project-ddc',\n generation: lease.generation,\n lease: lease.attempt,\n revision: current.revision,\n });\n }\n if (\n current.revision !== lease.expectedRevision ||\n current.desiredKey !== lease.desiredKey ||\n validatedKey !== lease.desiredKey\n ) {\n await this.write({ ...current, stale: true });\n return withRevision({ result: 'stale', key: validatedKey }, current.revision);\n }\n const entry = await this.entries.read(validatedKey);\n if (entry === null || entry.guid !== lease.guid || entry.receipt.key !== validatedKey) {\n await this.write({\n guid: lease.guid,\n desiredKey: lease.desiredKey,\n revision: current.revision + 1,\n generation: lease.generation,\n ...(current.lastKnownGoodKey === undefined\n ? {}\n : { lastKnownGoodKey: current.lastKnownGoodKey }),\n failure: {\n desiredKey: lease.desiredKey,\n code: 'entry-invalid',\n detail: 'validated DDC key has no readable entry for this asset',\n },\n });\n return withRevision({ result: 'invalid', key: validatedKey }, current.revision + 1);\n }\n const lastKnownGoodKey =\n current.currentKey !== undefined && current.currentKey !== validatedKey\n ? current.currentKey\n : current.lastKnownGoodKey;\n const nextRevision = current.revision + 1;\n await this.write({\n guid: lease.guid,\n desiredKey: lease.desiredKey,\n revision: nextRevision,\n generation: lease.generation,\n currentKey: validatedKey,\n stale: false,\n ...(current.supersededAttempts === undefined\n ? {}\n : { supersededAttempts: current.supersededAttempts }),\n ...(lastKnownGoodKey === undefined ? {} : { lastKnownGoodKey }),\n });\n return withRevision({ result: 'current', key: validatedKey }, nextRevision);\n });\n }\n\n public async fail(\n lease: DdcLease,\n failure: { readonly code: string; readonly detail: string },\n ): Promise<void> {\n await withDdcLock(this.root, `head-${lease.guid}`, async () => {\n const current = await this.read(lease.guid);\n if (current?.active?.attempt !== lease.attempt) return;\n await this.write({\n guid: lease.guid,\n desiredKey: lease.desiredKey,\n revision: current.revision + 1,\n generation: lease.generation,\n ...(current.currentKey === undefined ? {} : { currentKey: current.currentKey }),\n ...(current.lastKnownGoodKey === undefined\n ? {}\n : { lastKnownGoodKey: current.lastKnownGoodKey }),\n failure: { desiredKey: lease.desiredKey, ...failure },\n });\n });\n }\n\n public async heartbeat(lease: DdcLease): Promise<DdcLease> {\n return withDdcLock(this.root, `head-${lease.guid}`, async () => {\n const current = await this.read(lease.guid);\n if (current?.active?.attempt !== lease.attempt) {\n throw new DdcStoreError({\n code: 'ddc-lease-expired',\n detail: 'heartbeat belongs to a stale lease',\n expected: lease.attempt,\n actual: current?.active?.attempt,\n lease: lease.attempt,\n generation: lease.generation,\n rootKind: 'project-ddc',\n });\n }\n const refreshed = { ...lease, expiresAt: Date.now() + this.leaseTtlMs };\n await this.write({ ...current, active: refreshed });\n return refreshed;\n });\n }\n\n public async close(lease: DdcLease): Promise<void> {\n await withDdcLock(this.root, `head-${lease.guid}`, async () => {\n const current = await this.read(lease.guid);\n if (current?.active?.instanceId !== lease.instanceId) return;\n const { active: _active, ...withoutActive } = current;\n await this.write({\n ...withoutActive,\n revision: current.revision + 1,\n stale: current.currentKey === undefined,\n });\n });\n }\n\n public async revoke(lease: DdcLease): Promise<void> {\n await this.fail(lease, {\n code: 'lease-lost',\n detail: 'cook lease was revoked before validation',\n });\n }\n\n public async recover(guid: string, desiredKey: string): Promise<DdcHead> {\n return withDdcLock(this.root, `head-${guid}`, async () => {\n const current = await this.read(guid);\n if (current?.active?.desiredKey === desiredKey) {\n await this.write({\n guid,\n desiredKey,\n revision: current.revision + 1,\n ...(current.lastKnownGoodKey === undefined\n ? {}\n : { lastKnownGoodKey: current.lastKnownGoodKey }),\n failure: {\n desiredKey,\n code: 'writer-crashed',\n detail: 'active cook attempt was recovered after process interruption',\n },\n });\n }\n return this.inspect(guid, desiredKey);\n });\n }\n\n private async allocateGeneration(): Promise<number> {\n const path = join(this.root, 'generations', 'counter.json');\n await mkdir(join(this.root, 'generations'), { recursive: true });\n let next = 1;\n try {\n const record = JSON.parse(await readFile(path, 'utf8')) as GenerationRecord;\n if (record.schemaVersion === 'forgeax-ddc-generation/v2' && Number.isInteger(record.next))\n next = Math.max(1, record.next);\n } catch {\n // A missing counter is the first allocation, not an implicit legacy fallback.\n }\n const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;\n await writeFile(\n temporary,\n JSON.stringify({ schemaVersion: 'forgeax-ddc-generation/v2', next: next + 1 }),\n );\n await rename(temporary, path);\n return next;\n }\n\n private async read(guid: string): Promise<HeadRecord | null> {\n const path = headFile(this.heads, guid);\n let source: string;\n try {\n source = await readFile(path, 'utf8');\n } catch (error) {\n if (\n error !== null &&\n typeof error === 'object' &&\n 'code' in error &&\n (error as { readonly code?: unknown }).code === 'ENOENT'\n ) {\n return null;\n }\n throw malformedHeadError('unreadable');\n }\n let value: unknown;\n try {\n value = JSON.parse(source);\n } catch {\n throw malformedHeadError('syntax-invalid');\n }\n if (!isHeadRecord(value) || value.guid !== guid) throw malformedHeadError('schema-invalid');\n return value;\n }\n\n private async write(record: HeadRecord): Promise<void> {\n await mkdir(this.heads, { recursive: true });\n const path = headFile(this.heads, record.guid);\n const temporary = `${path}.${randomUUID()}.tmp`;\n await writeFile(temporary, JSON.stringify(record));\n await rename(temporary, path);\n }\n}\n","import { readdir, rm } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { withDdcLock } from './lifecycle.js';\n\nexport interface DdcGcInput {\n readonly currentKeys: readonly string[];\n readonly lastKnownGoodKeys: readonly string[];\n readonly activeLeaseKeys: readonly string[];\n readonly scopeIds?: readonly string[];\n}\n\nexport interface DdcGcResult {\n readonly deleted: readonly string[];\n readonly protected: readonly string[];\n}\n\n/** Mark current/LKG/lease roots, then sweep only the same project root. */\nexport async function collectDdcGarbage(root: string, input: DdcGcInput): Promise<DdcGcResult> {\n return withDdcLock(root, 'gc', async () => {\n const protectedKeys = new Set([\n ...input.currentKeys,\n ...input.lastKnownGoodKeys,\n ...input.activeLeaseKeys,\n ]);\n const entries = await readdir(join(root, 'entries'), { withFileTypes: true }).catch(() => []);\n const deleted: string[] = [];\n for (const entry of entries) {\n if (!entry.isDirectory() || protectedKeys.has(entry.name)) continue;\n await rm(join(root, 'entries', entry.name), { recursive: true, force: false });\n deleted.push(entry.name);\n }\n return { deleted, protected: [...protectedKeys].sort() };\n });\n}\n","import { isAbsolute, normalize } from 'node:path';\n\nexport const DDC_LAYOUT_VERSION = 'v2' as const;\n\nexport interface DdcBuildOptions {\n readonly buildCacheRoot: string;\n}\n\nexport interface DdcServeOptions extends DdcBuildOptions {\n readonly projectDdcRoot?: string;\n}\n\nexport interface DdcBuildLayout {\n readonly objects: string;\n readonly staging: string;\n}\n\nexport interface DdcProjectLayout {\n readonly root: string;\n readonly scope: string;\n readonly heads: string;\n readonly generations: string;\n readonly leases: string;\n readonly staging: string;\n}\n\nexport interface DdcLayout {\n readonly version: typeof DDC_LAYOUT_VERSION;\n readonly buildCacheRoot: string;\n readonly projectDdcRoot: string;\n readonly build: DdcBuildLayout;\n readonly project: DdcProjectLayout;\n}\n\nexport interface DdcBuildLayoutResult {\n readonly ok: true;\n readonly value: DdcBuildLayout;\n}\n\nexport interface DdcLayoutError {\n readonly code: 'ddc-project-root-required' | 'ddc-root-absolute-required';\n readonly detail: string;\n readonly hint: string;\n readonly expected: string;\n readonly actual?: string;\n}\n\nexport interface DdcLayoutResult {\n readonly ok: true;\n readonly value: DdcLayout;\n}\n\nexport interface DdcLayoutFailure {\n readonly ok: false;\n readonly error: DdcLayoutError;\n}\n\ntype ClosedLayoutResult = DdcLayoutResult | DdcLayoutFailure;\n\nfunction rootOrError(root: string, name: string): string | DdcLayoutError {\n if (!isAbsolute(root)) {\n return {\n code: 'ddc-root-absolute-required',\n detail: `${name} must be an absolute injected path`,\n hint: `inject the canonical ${name} from the host root policy`,\n expected: 'an absolute filesystem path',\n actual: root,\n };\n }\n const normalized = normalize(root);\n return normalized.replace(/[\\\\/]+$/, '') || normalized;\n}\n\nfunction buildLayout(root: string): DdcBuildLayout {\n return { objects: `${root}/objects`, staging: `${root}/staging` };\n}\n\nfunction projectLayout(root: string): DdcProjectLayout {\n return {\n root,\n scope: `${root}/scope.json`,\n heads: `${root}/heads`,\n generations: `${root}/generations`,\n leases: `${root}/leases`,\n staging: `${root}/staging`,\n };\n}\n\nexport function resolveBuildDdcLayout(\n options: DdcBuildOptions,\n): DdcBuildLayoutResult | DdcLayoutFailure {\n const root = rootOrError(options.buildCacheRoot, 'buildCacheRoot');\n return typeof root === 'string'\n ? { ok: true, value: buildLayout(root) }\n : { ok: false, error: root };\n}\n\nexport function resolveDdcLayout(options: DdcServeOptions): ClosedLayoutResult {\n const buildRoot = rootOrError(options.buildCacheRoot, 'buildCacheRoot');\n if (typeof buildRoot !== 'string') return { ok: false, error: buildRoot };\n if (options.projectDdcRoot === undefined || options.projectDdcRoot.trim().length === 0) {\n return {\n ok: false,\n error: {\n code: 'ddc-project-root-required',\n detail: 'serve and publication require an explicitly injected projectDdcRoot',\n hint: 'canonicalize the game directory in the host and inject its .forgeax/ddc/v2 root',\n expected: 'projectDdcRoot',\n },\n };\n }\n const projectRoot = rootOrError(options.projectDdcRoot, 'projectDdcRoot');\n if (typeof projectRoot !== 'string') return { ok: false, error: projectRoot };\n return {\n ok: true,\n value: {\n version: DDC_LAYOUT_VERSION,\n buildCacheRoot: buildRoot,\n projectDdcRoot: projectRoot,\n build: buildLayout(buildRoot),\n project: projectLayout(projectRoot),\n },\n };\n}\n\nexport function isDdcLayout(value: unknown): value is DdcLayout {\n return (\n value !== null &&\n typeof value === 'object' &&\n (value as { readonly version?: unknown }).version === DDC_LAYOUT_VERSION\n );\n}\n","import { createHash } from 'node:crypto';\nimport { mkdir, readFile, rename, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { DdcStoreError } from './errors.js';\n\nexport interface DdcRuntimeScope {\n readonly scopeId: string;\n readonly scopeHash: string;\n readonly root: string;\n readonly metadataPath: string;\n}\n\ninterface ScopeMetadata {\n readonly schemaVersion: 'forgeax-ddc-scope/v2';\n readonly scopeId: string;\n readonly scopeHash: string;\n}\n\nfunction scopeHash(scopeId: string): string {\n return createHash('sha256').update(scopeId, 'utf8').digest('hex');\n}\n\nexport function runtimeScopeHash(scopeId: string): string {\n return scopeHash(scopeId);\n}\n\nexport async function createRuntimeScope(root: string, scopeId: string): Promise<DdcRuntimeScope> {\n if (scopeId.length === 0) {\n throw new DdcStoreError({\n code: 'ddc-scope-mismatch',\n detail: 'runtime scope id must not be empty',\n expected: 'a non-empty original scope id',\n actual: scopeId,\n rootKind: 'project-ddc',\n });\n }\n const hash = scopeHash(scopeId);\n const scopeRoot = join(root, 'scopes', hash);\n const metadataPath = join(scopeRoot, 'scope.json');\n await mkdir(scopeRoot, { recursive: true });\n const expected: ScopeMetadata = {\n schemaVersion: 'forgeax-ddc-scope/v2',\n scopeId,\n scopeHash: hash,\n };\n try {\n const actual = JSON.parse(await readFile(metadataPath, 'utf8')) as Partial<ScopeMetadata>;\n if (\n actual.schemaVersion !== expected.schemaVersion ||\n actual.scopeId !== expected.scopeId ||\n actual.scopeHash !== expected.scopeHash\n ) {\n throw new DdcStoreError({\n code: 'ddc-scope-mismatch',\n detail: 'runtime scope metadata does not match the requested scope',\n expected,\n actual,\n rootKind: 'project-ddc',\n scope: scopeId,\n });\n }\n } catch (error) {\n if (error instanceof DdcStoreError) throw error;\n const temporary = `${metadataPath}.${process.pid}.tmp`;\n await writeFile(temporary, JSON.stringify(expected));\n await rename(temporary, metadataPath);\n }\n return { scopeId, scopeHash: hash, root: scopeRoot, metadataPath };\n}\n\nexport async function assertRuntimeScope(\n root: string,\n scope: Pick<DdcRuntimeScope, 'scopeId' | 'scopeHash'>,\n): Promise<DdcRuntimeScope> {\n const expectedHash = scopeHash(scope.scopeId);\n if (scope.scopeHash !== expectedHash) {\n throw new DdcStoreError({\n code: 'ddc-scope-mismatch',\n detail: 'runtime scope hash does not match the original scope id',\n expected: expectedHash,\n actual: scope.scopeHash,\n rootKind: 'project-ddc',\n scope: scope.scopeId,\n });\n }\n return createRuntimeScope(root, scope.scopeId);\n}\n","import type { DdcErrorRootKind } from './errors.js';\n\nexport const DDC_STATUS_SCHEMA = 'forgeax-ddc-status/v2' as const;\n\nexport type DdcStatusHealth = 'ready' | 'blocked' | 'missing' | 'stale' | 'failed';\nexport type DdcStatusLayerKind = 'build' | 'project' | 'runtime';\nexport type DdcStatusRootKind = DdcErrorRootKind;\n\nexport interface DdcRecoveryAction {\n readonly kind: 'inspect' | 'allocate-generation' | 'retry' | 'cold-rebuild' | 'prune';\n readonly executable: boolean;\n readonly exactTarget?: string;\n readonly reason?: string;\n}\n\nexport interface DdcStatusLayer {\n readonly kind: DdcStatusLayerKind;\n readonly owner: 'engine-ddc' | 'engine-pack' | 'plugin' | 'runtime';\n readonly rootKind: DdcStatusRootKind;\n readonly scopeId?: string;\n readonly current?: number | string;\n readonly lastKnownGood?: number | string;\n readonly protection: readonly string[];\n readonly actions: readonly DdcRecoveryAction[];\n}\n\nexport interface DdcStatus {\n readonly schemaVersion: typeof DDC_STATUS_SCHEMA;\n readonly health: DdcStatusHealth;\n readonly layers: readonly DdcStatusLayer[];\n readonly gameDir?: string;\n readonly projectDdcRoot?: string;\n}\n\nexport type BrowserDdcRecoveryAction = Omit<DdcRecoveryAction, 'exactTarget'>;\nexport type BrowserDdcStatusLayer = Omit<DdcStatusLayer, 'actions'> & {\n readonly actions: readonly BrowserDdcRecoveryAction[];\n};\nexport type BrowserDdcStatus = Omit<DdcStatus, 'gameDir' | 'projectDdcRoot' | 'layers'> & {\n readonly layers: readonly BrowserDdcStatusLayer[];\n};\n\nexport function serializeDdcStatus(status: DdcStatus): string {\n return JSON.stringify(status);\n}\n\nexport function projectDdcStatusForBrowser(status: DdcStatus): BrowserDdcStatus {\n return {\n schemaVersion: DDC_STATUS_SCHEMA,\n health: status.health,\n layers: status.layers.map((layer) => ({\n ...layer,\n actions: layer.actions.map(({ exactTarget: _exactTarget, ...action }) => action),\n })),\n };\n}\n\nexport const toBrowserDdcStatus = projectDdcStatusForBrowser;\n"]}
package/dist/key.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ export interface SemanticDdcInput {
2
+ readonly schemaVersion: string;
3
+ readonly importer: string;
4
+ readonly codec: string;
5
+ readonly settings: unknown;
6
+ readonly sourceBytes: readonly Uint8Array[];
7
+ readonly declaredGuids: readonly string[];
8
+ readonly targetProfile: string;
9
+ readonly producer: string;
10
+ }
11
+ export declare function canonicalDdcJson(value: unknown): string;
12
+ export declare function semanticDdcKey(input: SemanticDdcInput): string;
13
+ //# sourceMappingURL=key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../src/key.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGvD;AAiBD,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAY9D"}
package/dist/key.mjs ADDED
@@ -0,0 +1,38 @@
1
+ import { createHash } from 'crypto';
2
+
3
+ // src/key.ts
4
+ function canonicalDdcJson(value) {
5
+ const sorted = sortValue(value);
6
+ return JSON.stringify(sorted) ?? "null";
7
+ }
8
+ function sortValue(value) {
9
+ if (value instanceof Uint8Array) {
10
+ return { encoding: "base64", bytes: Buffer.from(value).toString("base64") };
11
+ }
12
+ if (Array.isArray(value)) return value.map(sortValue);
13
+ if (value !== null && typeof value === "object") {
14
+ const result = {};
15
+ for (const key of Object.keys(value).sort()) {
16
+ result[key] = sortValue(value[key]);
17
+ }
18
+ return result;
19
+ }
20
+ return value;
21
+ }
22
+ function semanticDdcKey(input) {
23
+ const semantic = {
24
+ schemaVersion: input.schemaVersion,
25
+ importer: input.importer,
26
+ codec: input.codec,
27
+ settings: input.settings,
28
+ sourceBytes: input.sourceBytes,
29
+ declaredGuids: [...input.declaredGuids].sort(),
30
+ targetProfile: input.targetProfile,
31
+ producer: input.producer
32
+ };
33
+ return createHash("sha256").update(canonicalDdcJson(semantic)).digest("hex");
34
+ }
35
+
36
+ export { canonicalDdcJson, semanticDdcKey };
37
+ //# sourceMappingURL=key.mjs.map
38
+ //# sourceMappingURL=key.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/key.ts"],"names":[],"mappings":";;;AAaO,SAAS,iBAAiB,KAAA,EAAwB;AACvD,EAAA,MAAM,MAAA,GAAS,UAAU,KAAK,CAAA;AAC9B,EAAA,OAAO,IAAA,CAAK,SAAA,CAAU,MAAM,CAAA,IAAK,MAAA;AACnC;AAEA,SAAS,UAAU,KAAA,EAAyB;AAC1C,EAAA,IAAI,iBAAiB,UAAA,EAAY;AAC/B,IAAA,OAAO,EAAE,QAAA,EAAU,QAAA,EAAU,KAAA,EAAO,MAAA,CAAO,KAAK,KAAK,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAA,EAAE;AAAA,EAC5E;AACA,EAAA,IAAI,MAAM,OAAA,CAAQ,KAAK,GAAG,OAAO,KAAA,CAAM,IAAI,SAAS,CAAA;AACpD,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,QAAA,EAAU;AAC/C,IAAA,MAAM,SAAkC,EAAC;AACzC,IAAA,KAAA,MAAW,OAAO,MAAA,CAAO,IAAA,CAAK,KAAgC,CAAA,CAAE,MAAK,EAAG;AACtE,MAAA,MAAA,CAAO,GAAG,CAAA,GAAI,SAAA,CAAW,KAAA,CAAkC,GAAG,CAAC,CAAA;AAAA,IACjE;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA;AACT;AAEO,SAAS,eAAe,KAAA,EAAiC;AAC9D,EAAA,MAAM,QAAA,GAAW;AAAA,IACf,eAAe,KAAA,CAAM,aAAA;AAAA,IACrB,UAAU,KAAA,CAAM,QAAA;AAAA,IAChB,OAAO,KAAA,CAAM,KAAA;AAAA,IACb,UAAU,KAAA,CAAM,QAAA;AAAA,IAChB,aAAa,KAAA,CAAM,WAAA;AAAA,IACnB,eAAe,CAAC,GAAG,KAAA,CAAM,aAAa,EAAE,IAAA,EAAK;AAAA,IAC7C,eAAe,KAAA,CAAM,aAAA;AAAA,IACrB,UAAU,KAAA,CAAM;AAAA,GAClB;AACA,EAAA,OAAO,UAAA,CAAW,QAAQ,CAAA,CAAE,MAAA,CAAO,iBAAiB,QAAQ,CAAC,CAAA,CAAE,MAAA,CAAO,KAAK,CAAA;AAC7E","file":"key.mjs","sourcesContent":["import { createHash } from 'node:crypto';\n\nexport interface SemanticDdcInput {\n readonly schemaVersion: string;\n readonly importer: string;\n readonly codec: string;\n readonly settings: unknown;\n readonly sourceBytes: readonly Uint8Array[];\n readonly declaredGuids: readonly string[];\n readonly targetProfile: string;\n readonly producer: string;\n}\n\nexport function canonicalDdcJson(value: unknown): string {\n const sorted = sortValue(value);\n return JSON.stringify(sorted) ?? 'null';\n}\n\nfunction sortValue(value: unknown): unknown {\n if (value instanceof Uint8Array) {\n return { encoding: 'base64', bytes: Buffer.from(value).toString('base64') };\n }\n if (Array.isArray(value)) return value.map(sortValue);\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value as Record<string, unknown>).sort()) {\n result[key] = sortValue((value as Record<string, unknown>)[key]);\n }\n return result;\n }\n return value;\n}\n\nexport function semanticDdcKey(input: SemanticDdcInput): string {\n const semantic = {\n schemaVersion: input.schemaVersion,\n importer: input.importer,\n codec: input.codec,\n settings: input.settings,\n sourceBytes: input.sourceBytes,\n declaredGuids: [...input.declaredGuids].sort(),\n targetProfile: input.targetProfile,\n producer: input.producer,\n };\n return createHash('sha256').update(canonicalDdcJson(semantic)).digest('hex');\n}\n"]}
@@ -0,0 +1,51 @@
1
+ export declare const DDC_LAYOUT_VERSION: "v2";
2
+ export interface DdcBuildOptions {
3
+ readonly buildCacheRoot: string;
4
+ }
5
+ export interface DdcServeOptions extends DdcBuildOptions {
6
+ readonly projectDdcRoot?: string;
7
+ }
8
+ export interface DdcBuildLayout {
9
+ readonly objects: string;
10
+ readonly staging: string;
11
+ }
12
+ export interface DdcProjectLayout {
13
+ readonly root: string;
14
+ readonly scope: string;
15
+ readonly heads: string;
16
+ readonly generations: string;
17
+ readonly leases: string;
18
+ readonly staging: string;
19
+ }
20
+ export interface DdcLayout {
21
+ readonly version: typeof DDC_LAYOUT_VERSION;
22
+ readonly buildCacheRoot: string;
23
+ readonly projectDdcRoot: string;
24
+ readonly build: DdcBuildLayout;
25
+ readonly project: DdcProjectLayout;
26
+ }
27
+ export interface DdcBuildLayoutResult {
28
+ readonly ok: true;
29
+ readonly value: DdcBuildLayout;
30
+ }
31
+ export interface DdcLayoutError {
32
+ readonly code: 'ddc-project-root-required' | 'ddc-root-absolute-required';
33
+ readonly detail: string;
34
+ readonly hint: string;
35
+ readonly expected: string;
36
+ readonly actual?: string;
37
+ }
38
+ export interface DdcLayoutResult {
39
+ readonly ok: true;
40
+ readonly value: DdcLayout;
41
+ }
42
+ export interface DdcLayoutFailure {
43
+ readonly ok: false;
44
+ readonly error: DdcLayoutError;
45
+ }
46
+ type ClosedLayoutResult = DdcLayoutResult | DdcLayoutFailure;
47
+ export declare function resolveBuildDdcLayout(options: DdcBuildOptions): DdcBuildLayoutResult | DdcLayoutFailure;
48
+ export declare function resolveDdcLayout(options: DdcServeOptions): ClosedLayoutResult;
49
+ export declare function isDdcLayout(value: unknown): value is DdcLayout;
50
+ export {};
51
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.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AC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC;AAED,KAAK,kBAAkB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AA+B7D,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,eAAe,GACvB,oBAAoB,GAAG,gBAAgB,CAKzC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,kBAAkB,CA0B7E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAM9D"}
@@ -0,0 +1,68 @@
1
+ import { isAbsolute, normalize } from 'path';
2
+
3
+ // src/layout.ts
4
+ var DDC_LAYOUT_VERSION = "v2";
5
+ function rootOrError(root, name) {
6
+ if (!isAbsolute(root)) {
7
+ return {
8
+ code: "ddc-root-absolute-required",
9
+ detail: `${name} must be an absolute injected path`,
10
+ hint: `inject the canonical ${name} from the host root policy`,
11
+ expected: "an absolute filesystem path",
12
+ actual: root
13
+ };
14
+ }
15
+ const normalized = normalize(root);
16
+ return normalized.replace(/[\\/]+$/, "") || normalized;
17
+ }
18
+ function buildLayout(root) {
19
+ return { objects: `${root}/objects`, staging: `${root}/staging` };
20
+ }
21
+ function projectLayout(root) {
22
+ return {
23
+ root,
24
+ scope: `${root}/scope.json`,
25
+ heads: `${root}/heads`,
26
+ generations: `${root}/generations`,
27
+ leases: `${root}/leases`,
28
+ staging: `${root}/staging`
29
+ };
30
+ }
31
+ function resolveBuildDdcLayout(options) {
32
+ const root = rootOrError(options.buildCacheRoot, "buildCacheRoot");
33
+ return typeof root === "string" ? { ok: true, value: buildLayout(root) } : { ok: false, error: root };
34
+ }
35
+ function resolveDdcLayout(options) {
36
+ const buildRoot = rootOrError(options.buildCacheRoot, "buildCacheRoot");
37
+ if (typeof buildRoot !== "string") return { ok: false, error: buildRoot };
38
+ if (options.projectDdcRoot === void 0 || options.projectDdcRoot.trim().length === 0) {
39
+ return {
40
+ ok: false,
41
+ error: {
42
+ code: "ddc-project-root-required",
43
+ detail: "serve and publication require an explicitly injected projectDdcRoot",
44
+ hint: "canonicalize the game directory in the host and inject its .forgeax/ddc/v2 root",
45
+ expected: "projectDdcRoot"
46
+ }
47
+ };
48
+ }
49
+ const projectRoot = rootOrError(options.projectDdcRoot, "projectDdcRoot");
50
+ if (typeof projectRoot !== "string") return { ok: false, error: projectRoot };
51
+ return {
52
+ ok: true,
53
+ value: {
54
+ version: DDC_LAYOUT_VERSION,
55
+ buildCacheRoot: buildRoot,
56
+ projectDdcRoot: projectRoot,
57
+ build: buildLayout(buildRoot),
58
+ project: projectLayout(projectRoot)
59
+ }
60
+ };
61
+ }
62
+ function isDdcLayout(value) {
63
+ return value !== null && typeof value === "object" && value.version === DDC_LAYOUT_VERSION;
64
+ }
65
+
66
+ export { DDC_LAYOUT_VERSION, isDdcLayout, resolveBuildDdcLayout, resolveDdcLayout };
67
+ //# sourceMappingURL=layout.mjs.map
68
+ //# sourceMappingURL=layout.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/layout.ts"],"names":[],"mappings":";;;AAEO,IAAM,kBAAA,GAAqB;AAyDlC,SAAS,WAAA,CAAY,MAAc,IAAA,EAAuC;AACxE,EAAA,IAAI,CAAC,UAAA,CAAW,IAAI,CAAA,EAAG;AACrB,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,4BAAA;AAAA,MACN,MAAA,EAAQ,GAAG,IAAI,CAAA,kCAAA,CAAA;AAAA,MACf,IAAA,EAAM,wBAAwB,IAAI,CAAA,0BAAA,CAAA;AAAA,MAClC,QAAA,EAAU,6BAAA;AAA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,IAAA,EAAK,CAAE,WAAW,CAAA,EAAG;AACtF,IAAA,OAAO;AAAA,MACL,EAAA,EAAI,KAAA;AAAA,MACJ,KAAA,EAAO;AAAA,QACL,IAAA,EAAM,2BAAA;AAAA,QACN,MAAA,EAAQ,qEAAA;AAAA,QACR,IAAA,EAAM,iFAAA;AAAA,QACN,QAAA,EAAU;AAAA;AACZ,KACF;AAAA,EACF;AACA,EAAA,MAAM,WAAA,GAAc,WAAA,CAAY,OAAA,CAAQ,cAAA,EAAgB,gBAAgB,CAAA;AACxE,EAAA,IAAI,OAAO,gBAAgB,QAAA,EAAU,OAAO,EAAE,EAAA,EAAI,KAAA,EAAO,OAAO,WAAA,EAAY;AAC5E,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,IAAA;AAAA,IACJ,KAAA,EAAO;AAAA,MACL,OAAA,EAAS,kBAAA;AAAA,MACT,cAAA,EAAgB,SAAA;AAAA,MAChB,cAAA,EAAgB,WAAA;AAAA,MAChB,KAAA,EAAO,YAAY,SAAS,CAAA;AAAA,MAC5B,OAAA,EAAS,cAAc,WAAW;AAAA;AACpC,GACF;AACF;AAEO,SAAS,YAAY,KAAA,EAAoC;AAC9D,EAAA,OACE,UAAU,IAAA,IACV,OAAO,KAAA,KAAU,QAAA,IAChB,MAAyC,OAAA,KAAY,kBAAA;AAE1D","file":"layout.mjs","sourcesContent":["import { isAbsolute, normalize } from 'node:path';\n\nexport const DDC_LAYOUT_VERSION = 'v2' as const;\n\nexport interface DdcBuildOptions {\n readonly buildCacheRoot: string;\n}\n\nexport interface DdcServeOptions extends DdcBuildOptions {\n readonly projectDdcRoot?: string;\n}\n\nexport interface DdcBuildLayout {\n readonly objects: string;\n readonly staging: string;\n}\n\nexport interface DdcProjectLayout {\n readonly root: string;\n readonly scope: string;\n readonly heads: string;\n readonly generations: string;\n readonly leases: string;\n readonly staging: string;\n}\n\nexport interface DdcLayout {\n readonly version: typeof DDC_LAYOUT_VERSION;\n readonly buildCacheRoot: string;\n readonly projectDdcRoot: string;\n readonly build: DdcBuildLayout;\n readonly project: DdcProjectLayout;\n}\n\nexport interface DdcBuildLayoutResult {\n readonly ok: true;\n readonly value: DdcBuildLayout;\n}\n\nexport interface DdcLayoutError {\n readonly code: 'ddc-project-root-required' | 'ddc-root-absolute-required';\n readonly detail: string;\n readonly hint: string;\n readonly expected: string;\n readonly actual?: string;\n}\n\nexport interface DdcLayoutResult {\n readonly ok: true;\n readonly value: DdcLayout;\n}\n\nexport interface DdcLayoutFailure {\n readonly ok: false;\n readonly error: DdcLayoutError;\n}\n\ntype ClosedLayoutResult = DdcLayoutResult | DdcLayoutFailure;\n\nfunction rootOrError(root: string, name: string): string | DdcLayoutError {\n if (!isAbsolute(root)) {\n return {\n code: 'ddc-root-absolute-required',\n detail: `${name} must be an absolute injected path`,\n hint: `inject the canonical ${name} from the host root policy`,\n expected: 'an absolute filesystem path',\n actual: root,\n };\n }\n const normalized = normalize(root);\n return normalized.replace(/[\\\\/]+$/, '') || normalized;\n}\n\nfunction buildLayout(root: string): DdcBuildLayout {\n return { objects: `${root}/objects`, staging: `${root}/staging` };\n}\n\nfunction projectLayout(root: string): DdcProjectLayout {\n return {\n root,\n scope: `${root}/scope.json`,\n heads: `${root}/heads`,\n generations: `${root}/generations`,\n leases: `${root}/leases`,\n staging: `${root}/staging`,\n };\n}\n\nexport function resolveBuildDdcLayout(\n options: DdcBuildOptions,\n): DdcBuildLayoutResult | DdcLayoutFailure {\n const root = rootOrError(options.buildCacheRoot, 'buildCacheRoot');\n return typeof root === 'string'\n ? { ok: true, value: buildLayout(root) }\n : { ok: false, error: root };\n}\n\nexport function resolveDdcLayout(options: DdcServeOptions): ClosedLayoutResult {\n const buildRoot = rootOrError(options.buildCacheRoot, 'buildCacheRoot');\n if (typeof buildRoot !== 'string') return { ok: false, error: buildRoot };\n if (options.projectDdcRoot === undefined || options.projectDdcRoot.trim().length === 0) {\n return {\n ok: false,\n error: {\n code: 'ddc-project-root-required',\n detail: 'serve and publication require an explicitly injected projectDdcRoot',\n hint: 'canonicalize the game directory in the host and inject its .forgeax/ddc/v2 root',\n expected: 'projectDdcRoot',\n },\n };\n }\n const projectRoot = rootOrError(options.projectDdcRoot, 'projectDdcRoot');\n if (typeof projectRoot !== 'string') return { ok: false, error: projectRoot };\n return {\n ok: true,\n value: {\n version: DDC_LAYOUT_VERSION,\n buildCacheRoot: buildRoot,\n projectDdcRoot: projectRoot,\n build: buildLayout(buildRoot),\n project: projectLayout(projectRoot),\n },\n };\n}\n\nexport function isDdcLayout(value: unknown): value is DdcLayout {\n return (\n value !== null &&\n typeof value === 'object' &&\n (value as { readonly version?: unknown }).version === DDC_LAYOUT_VERSION\n );\n}\n"]}
@@ -0,0 +1,55 @@
1
+ export type DdcLifecycleState = 'missing' | 'cooking' | 'current' | 'stale' | 'failed';
2
+ export interface DdcLease {
3
+ readonly guid: string;
4
+ readonly desiredKey: string;
5
+ readonly attempt: string;
6
+ readonly generation: number;
7
+ readonly expectedRevision: number;
8
+ readonly instanceId: string;
9
+ readonly expiresAt: number;
10
+ }
11
+ export interface DdcHead {
12
+ readonly guid: string;
13
+ readonly desiredKey: string;
14
+ readonly state: DdcLifecycleState;
15
+ readonly currentKey: string | undefined;
16
+ readonly lastKnownGoodKey: string | undefined;
17
+ readonly revision?: number;
18
+ readonly generation?: number;
19
+ readonly activeLease?: DdcLease;
20
+ readonly failure?: {
21
+ readonly code: string;
22
+ readonly detail: string;
23
+ };
24
+ }
25
+ export interface DdcCommitResult {
26
+ readonly result: 'current' | 'stale' | 'lease-lost' | 'invalid';
27
+ readonly key: string;
28
+ readonly revision?: number;
29
+ }
30
+ /** Cross-process mkdir lock; a lock owned by a dead PID is reclaimable. */
31
+ export declare function withDdcLock<T>(root: string, name: string, operation: () => Promise<T>): Promise<T>;
32
+ export declare class DdcLifecycle {
33
+ private readonly heads;
34
+ private readonly entries;
35
+ private readonly root;
36
+ private readonly leaseTtlMs;
37
+ constructor(root: string, options?: {
38
+ readonly leaseTtlMs?: number;
39
+ });
40
+ inspect(guid: string, desiredKey: string): Promise<DdcHead>;
41
+ begin(guid: string, desiredKey: string): Promise<DdcLease>;
42
+ commit(lease: DdcLease, validatedKey: string): Promise<DdcCommitResult>;
43
+ fail(lease: DdcLease, failure: {
44
+ readonly code: string;
45
+ readonly detail: string;
46
+ }): Promise<void>;
47
+ heartbeat(lease: DdcLease): Promise<DdcLease>;
48
+ close(lease: DdcLease): Promise<void>;
49
+ revoke(lease: DdcLease): Promise<void>;
50
+ recover(guid: string, desiredKey: string): Promise<DdcHead>;
51
+ private allocateGeneration;
52
+ private read;
53
+ private write;
54
+ }
55
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEvF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAA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C,eAAe,CAAC;IAsEvE,IAAI,CACf,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAC1D,OAAO,CAAC,IAAI,CAAC;IAkBH,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAoB7C,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAarC,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;YAsB1D,kBAAkB;YAoBlB,IAAI;YA0BJ,KAAK;CAOpB"}
@@ -0,0 +1,10 @@
1
+ export interface DdcRuntimeScope {
2
+ readonly scopeId: string;
3
+ readonly scopeHash: string;
4
+ readonly root: string;
5
+ readonly metadataPath: string;
6
+ }
7
+ export declare function runtimeScopeHash(scopeId: string): string;
8
+ export declare function createRuntimeScope(root: string, scopeId: string): Promise<DdcRuntimeScope>;
9
+ export declare function assertRuntimeScope(root: string, scope: Pick<DdcRuntimeScope, 'scopeId' | 'scopeHash'>): Promise<DdcRuntimeScope>;
10
+ //# sourceMappingURL=runtime-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-scope.d.ts","sourceRoot":"","sources":["../src/runtime-scope.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAYD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CA0ChG;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,WAAW,CAAC,GACpD,OAAO,CAAC,eAAe,CAAC,CAa1B"}
@@ -0,0 +1,39 @@
1
+ import type { DdcErrorRootKind } from './errors.js';
2
+ export declare const DDC_STATUS_SCHEMA: "forgeax-ddc-status/v2";
3
+ export type DdcStatusHealth = 'ready' | 'blocked' | 'missing' | 'stale' | 'failed';
4
+ export type DdcStatusLayerKind = 'build' | 'project' | 'runtime';
5
+ export type DdcStatusRootKind = DdcErrorRootKind;
6
+ export interface DdcRecoveryAction {
7
+ readonly kind: 'inspect' | 'allocate-generation' | 'retry' | 'cold-rebuild' | 'prune';
8
+ readonly executable: boolean;
9
+ readonly exactTarget?: string;
10
+ readonly reason?: string;
11
+ }
12
+ export interface DdcStatusLayer {
13
+ readonly kind: DdcStatusLayerKind;
14
+ readonly owner: 'engine-ddc' | 'engine-pack' | 'plugin' | 'runtime';
15
+ readonly rootKind: DdcStatusRootKind;
16
+ readonly scopeId?: string;
17
+ readonly current?: number | string;
18
+ readonly lastKnownGood?: number | string;
19
+ readonly protection: readonly string[];
20
+ readonly actions: readonly DdcRecoveryAction[];
21
+ }
22
+ export interface DdcStatus {
23
+ readonly schemaVersion: typeof DDC_STATUS_SCHEMA;
24
+ readonly health: DdcStatusHealth;
25
+ readonly layers: readonly DdcStatusLayer[];
26
+ readonly gameDir?: string;
27
+ readonly projectDdcRoot?: string;
28
+ }
29
+ export type BrowserDdcRecoveryAction = Omit<DdcRecoveryAction, 'exactTarget'>;
30
+ export type BrowserDdcStatusLayer = Omit<DdcStatusLayer, 'actions'> & {
31
+ readonly actions: readonly BrowserDdcRecoveryAction[];
32
+ };
33
+ export type BrowserDdcStatus = Omit<DdcStatus, 'gameDir' | 'projectDdcRoot' | 'layers'> & {
34
+ readonly layers: readonly BrowserDdcStatusLayer[];
35
+ };
36
+ export declare function serializeDdcStatus(status: DdcStatus): string;
37
+ export declare function projectDdcStatusForBrowser(status: DdcStatus): BrowserDdcStatus;
38
+ export declare const toBrowserDdcStatus: typeof projectDdcStatusForBrowser;
39
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,iBAAiB,EAAG,uBAAgC,CAAC;AAElE,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AACnF,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AACjE,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAEjD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,GAAG,OAAO,GAAG,cAAc,GAAG,OAAO,CAAC;IACtF,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAC;IACpE,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAChD;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,aAAa,EAAE,OAAO,iBAAiB,CAAC;IACjD,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG;IACpE,QAAQ,CAAC,OAAO,EAAE,SAAS,wBAAwB,EAAE,CAAC;CACvD,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,gBAAgB,GAAG,QAAQ,CAAC,GAAG;IACxF,QAAQ,CAAC,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACnD,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAE5D;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,gBAAgB,CAS9E;AAED,eAAO,MAAM,kBAAkB,mCAA6B,CAAC"}
@@ -0,0 +1,20 @@
1
+ // src/status.ts
2
+ var DDC_STATUS_SCHEMA = "forgeax-ddc-status/v2";
3
+ function serializeDdcStatus(status) {
4
+ return JSON.stringify(status);
5
+ }
6
+ function projectDdcStatusForBrowser(status) {
7
+ return {
8
+ schemaVersion: DDC_STATUS_SCHEMA,
9
+ health: status.health,
10
+ layers: status.layers.map((layer) => ({
11
+ ...layer,
12
+ actions: layer.actions.map(({ exactTarget: _exactTarget, ...action }) => action)
13
+ }))
14
+ };
15
+ }
16
+ var toBrowserDdcStatus = projectDdcStatusForBrowser;
17
+
18
+ export { DDC_STATUS_SCHEMA, projectDdcStatusForBrowser, serializeDdcStatus, toBrowserDdcStatus };
19
+ //# sourceMappingURL=status.mjs.map
20
+ //# sourceMappingURL=status.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/status.ts"],"names":[],"mappings":";AAEO,IAAM,iBAAA,GAAoB;AAwC1B,SAAS,mBAAmB,MAAA,EAA2B;AAC5D,EAAA,OAAO,IAAA,CAAK,UAAU,MAAM,CAAA;AAC9B;AAEO,SAAS,2BAA2B,MAAA,EAAqC;AAC9E,EAAA,OAAO;AAAA,IACL,aAAA,EAAe,iBAAA;AAAA,IACf,QAAQ,MAAA,CAAO,MAAA;AAAA,IACf,MAAA,EAAQ,MAAA,CAAO,MAAA,CAAO,GAAA,CAAI,CAAC,KAAA,MAAW;AAAA,MACpC,GAAG,KAAA;AAAA,MACH,OAAA,EAAS,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,CAAC,EAAE,WAAA,EAAa,YAAA,EAAc,GAAG,MAAA,EAAO,KAAM,MAAM;AAAA,KACjF,CAAE;AAAA,GACJ;AACF;AAEO,IAAM,kBAAA,GAAqB","file":"status.mjs","sourcesContent":["import type { DdcErrorRootKind } from './errors.js';\n\nexport const DDC_STATUS_SCHEMA = 'forgeax-ddc-status/v2' as const;\n\nexport type DdcStatusHealth = 'ready' | 'blocked' | 'missing' | 'stale' | 'failed';\nexport type DdcStatusLayerKind = 'build' | 'project' | 'runtime';\nexport type DdcStatusRootKind = DdcErrorRootKind;\n\nexport interface DdcRecoveryAction {\n readonly kind: 'inspect' | 'allocate-generation' | 'retry' | 'cold-rebuild' | 'prune';\n readonly executable: boolean;\n readonly exactTarget?: string;\n readonly reason?: string;\n}\n\nexport interface DdcStatusLayer {\n readonly kind: DdcStatusLayerKind;\n readonly owner: 'engine-ddc' | 'engine-pack' | 'plugin' | 'runtime';\n readonly rootKind: DdcStatusRootKind;\n readonly scopeId?: string;\n readonly current?: number | string;\n readonly lastKnownGood?: number | string;\n readonly protection: readonly string[];\n readonly actions: readonly DdcRecoveryAction[];\n}\n\nexport interface DdcStatus {\n readonly schemaVersion: typeof DDC_STATUS_SCHEMA;\n readonly health: DdcStatusHealth;\n readonly layers: readonly DdcStatusLayer[];\n readonly gameDir?: string;\n readonly projectDdcRoot?: string;\n}\n\nexport type BrowserDdcRecoveryAction = Omit<DdcRecoveryAction, 'exactTarget'>;\nexport type BrowserDdcStatusLayer = Omit<DdcStatusLayer, 'actions'> & {\n readonly actions: readonly BrowserDdcRecoveryAction[];\n};\nexport type BrowserDdcStatus = Omit<DdcStatus, 'gameDir' | 'projectDdcRoot' | 'layers'> & {\n readonly layers: readonly BrowserDdcStatusLayer[];\n};\n\nexport function serializeDdcStatus(status: DdcStatus): string {\n return JSON.stringify(status);\n}\n\nexport function projectDdcStatusForBrowser(status: DdcStatus): BrowserDdcStatus {\n return {\n schemaVersion: DDC_STATUS_SCHEMA,\n health: status.health,\n layers: status.layers.map((layer) => ({\n ...layer,\n actions: layer.actions.map(({ exactTarget: _exactTarget, ...action }) => action),\n })),\n };\n}\n\nexport const toBrowserDdcStatus = projectDdcStatusForBrowser;\n"]}