farseer-cli 1.16.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +328 -0
  2. package/dist/commands/code.js +104 -0
  3. package/dist/commands/code.js.map +7 -0
  4. package/dist/index.js +16 -0
  5. package/dist/index.js.map +2 -2
  6. package/dist/pipeline/service.js +1 -1
  7. package/dist/pipeline/service.js.map +2 -2
  8. package/dist/services/codefirst/api.js +269 -0
  9. package/dist/services/codefirst/api.js.map +7 -0
  10. package/dist/services/codefirst/binaryDisk.js +67 -0
  11. package/dist/services/codefirst/binaryDisk.js.map +7 -0
  12. package/dist/services/codefirst/byteHashes.js +129 -0
  13. package/dist/services/codefirst/byteHashes.js.map +7 -0
  14. package/dist/services/codefirst/documents.js +563 -0
  15. package/dist/services/codefirst/documents.js.map +7 -0
  16. package/dist/services/codefirst/layoutBinaryProjection.js +974 -0
  17. package/dist/services/codefirst/layoutBinaryProjection.js.map +7 -0
  18. package/dist/services/codefirst/layoutCompose.js +593 -0
  19. package/dist/services/codefirst/layoutCompose.js.map +7 -0
  20. package/dist/services/codefirst/layoutCore.js +260 -0
  21. package/dist/services/codefirst/layoutCore.js.map +7 -0
  22. package/dist/services/codefirst/layoutPaths.js +492 -0
  23. package/dist/services/codefirst/layoutPaths.js.map +7 -0
  24. package/dist/services/codefirst/layoutProjection.js +995 -0
  25. package/dist/services/codefirst/layoutProjection.js.map +7 -0
  26. package/dist/services/codefirst/layoutReadback.js +2552 -0
  27. package/dist/services/codefirst/layoutReadback.js.map +7 -0
  28. package/dist/services/codefirst/layoutReadbackPlacement.js +1517 -0
  29. package/dist/services/codefirst/layoutReadbackPlacement.js.map +7 -0
  30. package/dist/services/codefirst/layoutReceipt.js +1592 -0
  31. package/dist/services/codefirst/layoutReceipt.js.map +7 -0
  32. package/dist/services/codefirst/layoutScan.js +882 -0
  33. package/dist/services/codefirst/layoutScan.js.map +7 -0
  34. package/dist/services/codefirst/output.js +179 -0
  35. package/dist/services/codefirst/output.js.map +7 -0
  36. package/dist/services/codefirst/types.js +17 -0
  37. package/dist/services/codefirst/types.js.map +7 -0
  38. package/dist/services/codefirst/workflow.js +581 -0
  39. package/dist/services/codefirst/workflow.js.map +7 -0
  40. package/dist/services/codefirst/workspace.js +310 -0
  41. package/dist/services/codefirst/workspace.js.map +7 -0
  42. package/dist/services/codefirst/workspaceLock.js +148 -0
  43. package/dist/services/codefirst/workspaceLock.js.map +7 -0
  44. package/dist/services/codefirst/workspaceRoot.js +147 -0
  45. package/dist/services/codefirst/workspaceRoot.js.map +7 -0
  46. package/dist/utils/logger.js +9 -3
  47. package/dist/utils/logger.js.map +2 -2
  48. package/package.json +3 -2
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/services/codefirst/layoutReadbackPlacement.ts"],
4
+ "sourcesContent": ["/**\n * Authoritative readback placement: it allocates every destination a decided set needs and extracts\n * the damage evidence a selected Head carries. It takes decisions; it never takes them.\n */\nimport {\n AuthoritativeOwnerAttachmentInsertion,\n BinaryFragmentSelector,\n ComposeBinaryLayoutResult,\n DetachedFileProof,\n OwnerFieldProjection,\n RawFileSelector,\n RawFileWireSourceMapping,\n} from './layoutBinaryProjection';\nimport {\n attachmentField,\n blocked,\n canonicalFragmentHash,\n diagnostic,\n groupBySource,\n indexBySource,\n ITEM_KINDS,\n object,\n own,\n ownerKey as groupOwnerKey,\n RESOURCE_ID,\n samePath,\n sameSelector,\n SHA256,\n sourceIdentityKey,\n TREE_DOCUMENT_KINDS as GROUPED_FOLDER_KINDS,\n validBlob,\n type JsonObject,\n} from './layoutCore';\nimport {\n AllocatedLayoutPath,\n encodeLayoutSegment,\n folderDirectory,\n isPortableWorkspacePointer,\n layoutCollisionKey,\n LayoutPathAllocationError,\n LayoutPathAllocator,\n LayoutPathClaim,\n LayoutPathRequest,\n parentDirectory,\n rawSidecarPath,\n} from './layoutPaths';\nimport {\n CurrentFolderPlacement,\n CurrentLayoutPlacement,\n CurrentLayoutPlacementInput,\n DetachedDocumentProof,\n} from './layoutCompose';\nimport {\n ComposeGroupedLayoutResult,\n derivedSourceSelectorHash,\n FragmentSelector,\n GroupOwnerSelector,\n ProjectionDiagnostic,\n SourceIdentity,\n WireSourceMapping,\n} from './layoutProjection';\nimport { LayoutArtifact } from './layoutScan';\nimport { Document, Head, type HeadDiagnostic, type Json } from './types';\ntype AttachmentField = 'icon' | 'template';\n\nexport type AuthoritativeCurrentSource =\n | { codec: 'grouped'; mapping: WireSourceMapping }\n | { codec: 'raw'; mapping: RawFileWireSourceMapping };\n\nexport type AuthoritativePlacementIntent =\n | {\n mode: 'insert-authoritative';\n documentIndex: number;\n documentKey: string;\n /** `pull --force` re-inserts a resource the workspace deleted locally but still tracks. */\n reinsert?: boolean;\n }\n | {\n mode: 'replace-proven';\n documentIndex: number;\n documentKey: string;\n current: AuthoritativeCurrentSource;\n expectedCurrentHash: string;\n };\n\nexport interface AllocatedGroupedCorrespondence {\n mode: AuthoritativePlacementIntent['mode'];\n documentKey: string;\n mapping: WireSourceMapping;\n destination: FragmentSelector;\n}\n\nexport interface AllocatedRawCorrespondence {\n mode: AuthoritativePlacementIntent['mode'];\n documentKey: string;\n mapping: RawFileWireSourceMapping;\n destination: RawFileSelector;\n bytes: string;\n}\n\nexport interface AllocatedAttachmentCorrespondence {\n source: Extract<SourceIdentity, { type: 'resource' }>;\n field: AttachmentField;\n current?: OwnerFieldProjection;\n destination: { ownerFile: string; field: AttachmentField; bytes?: string };\n}\n\nexport type AuthoritativeDamagePlacement =\n | {\n codec: 'grouped';\n evidence: AuthoritativeDamageEvidence;\n destination: FragmentSelector;\n }\n | {\n codec: 'raw';\n evidence: AuthoritativeDamageEvidence;\n destination: RawFileSelector;\n bytes: string;\n };\n\nexport interface PlanAuthoritativePlacementInput extends CurrentLayoutPlacementInput {\n /** Inspected once by the composition that produced `currentGrouped`. This planner never re-inspects. */\n placement: CurrentLayoutPlacement;\n head?: Head;\n /** The map `documents.headDocuments` produced for `head`. It is required whenever `head` is supplied. */\n headDocuments?: ReadonlyMap<string, Document>;\n documents: readonly Document[];\n documentKeys: readonly string[];\n intents: readonly AuthoritativePlacementIntent[];\n currentGrouped: ComposeGroupedLayoutResult;\n currentBinary: ComposeBinaryLayoutResult;\n}\n\nexport type PlanAuthoritativePlacementResult =\n | {\n status: 'complete';\n groupedDocuments: readonly Document[];\n groupedDocumentKeys: readonly string[];\n groupedSources: readonly AllocatedGroupedCorrespondence[];\n rawDocuments: readonly Document[];\n rawSources: readonly AllocatedRawCorrespondence[];\n attachments: readonly AllocatedAttachmentCorrespondence[];\n ownerInsertions: readonly AuthoritativeOwnerAttachmentInsertion[];\n allocations: readonly { source: SourceIdentity; path: AllocatedLayoutPath }[];\n detachedDocumentProofs: Readonly<Record<string, DetachedDocumentProof>>;\n detachedFileProofs: Readonly<Record<string, DetachedFileProof>>;\n damagePlacements: readonly AuthoritativeDamagePlacement[];\n }\n | { status: 'blocked'; diagnostics: readonly ProjectionDiagnostic[] };\n\ninterface NormalizedIntent {\n intent: AuthoritativePlacementIntent;\n document: Document;\n documentKey: string;\n source: Extract<SourceIdentity, { type: 'resource' }>;\n current?: AuthoritativeCurrentSource;\n currentDocument?: Document;\n outputIndex: number;\n damage?: AuthoritativeDamageEvidence;\n}\n\ninterface OccupancyEntry {\n claim: LayoutPathClaim;\n sources: Set<string>;\n opaque?: boolean;\n}\n\ntype PlannedFolder =\n | { type: 'normal'; source: SourceIdentity; semanticPath: readonly string[]; directory: string }\n | {\n type: 'detached-representation';\n source: SourceIdentity;\n semanticPath: readonly string[];\n semanticPathHash: string;\n };\n\nconst FLAT_ROOTS: Readonly<Record<string, string>> = {\n user_group: 'access/groups',\n label: 'access/labels',\n dataset: 'definitions/datasets',\n export_configuration: 'definitions/exports',\n};\nfunction sameBinarySelector(left: BinaryFragmentSelector, right: BinaryFragmentSelector): boolean {\n if (left.slot !== right.slot) return false;\n if (left.slot === 'file-entry' && right.slot === 'file-entry') return left.sidecar === right.sidecar;\n return (\n left.slot === 'owner-attachment' &&\n right.slot === 'owner-attachment' &&\n left.ownerFile === right.ownerFile &&\n left.field === right.field\n );\n}\n\n/** A numeric identity, or the committed local key a caller inserts a brand-new resource under. */\nfunction sourceFor(documentKey: string, document: Document): Extract<SourceIdentity, { type: 'resource' }> | undefined {\n const separator = documentKey.indexOf('/');\n if (separator <= 0 || separator === documentKey.length - 1) return undefined;\n const kind = documentKey.slice(0, separator);\n const id = documentKey.slice(separator + 1);\n if (kind !== document.kind) return undefined;\n if (id.startsWith('key:')) {\n const key = id.slice('key:'.length);\n if (!key || document.id !== undefined || document.key !== key) return undefined;\n return { type: 'resource', resource: { kind, key } };\n }\n if (!RESOURCE_ID.test(id)) return undefined;\n if (typeof document.id === 'string' && document.id !== id) return undefined;\n return { type: 'resource', resource: { kind, id } };\n}\n\nfunction semanticPath(document: Document): string[] | undefined {\n const value = document as JsonObject;\n if (document.kind === 'folder') {\n if (!Array.isArray(value.path) || value.path.some((part) => typeof part !== 'string' || !part))\n return undefined;\n return value.path as string[];\n }\n if (['variable', 'dimension_table', 'sheet', 'dashboard', 'remote_job', 'file'].includes(document.kind)) {\n const folder = value.folder === null ? [] : value.folder;\n if (\n typeof value.name !== 'string' ||\n !value.name ||\n !Array.isArray(folder) ||\n folder.some((part) => typeof part !== 'string' || !part)\n )\n return undefined;\n return [...(folder as string[]), value.name];\n }\n return undefined;\n}\n\nfunction placementSignature(document: Document | undefined): string | undefined {\n if (!document) return undefined;\n const value = document as JsonObject;\n if (document.kind === 'folder') return canonicalFragmentHash({ path: value.path ?? null });\n if (['variable', 'dimension_table', 'sheet', 'dashboard', 'remote_job', 'file'].includes(document.kind)) {\n const folder = value.folder === null ? [] : value.folder;\n return canonicalFragmentHash({ name: value.name ?? null, folder: folder ?? null });\n }\n if (document.kind === 'share') return canonicalFragmentHash({ owner: value.owner ?? null });\n if (document.kind === 'dimension_members') return canonicalFragmentHash({ table: value.table ?? null });\n if (own(value, 'name')) return canonicalFragmentHash({ name: value.name ?? null });\n if (document.kind === 'user_permissions') return canonicalFragmentHash({ user: value.user ?? null });\n return canonicalFragmentHash({ kind: document.kind });\n}\n\nfunction identityValue(source: Extract<SourceIdentity, { type: 'resource' }>): string {\n return 'id' in source.resource ? source.resource.id : source.resource.key;\n}\n\nfunction currentCanBecome(\n current: SourceIdentity,\n authoritative: Extract<SourceIdentity, { type: 'resource' }>,\n currentDocument: Document,\n): boolean {\n if (currentDocument.kind !== authoritative.resource.kind) return false;\n if (current.type === 'transient') return true;\n if (current.type !== 'resource' || current.resource.kind !== authoritative.resource.kind) return false;\n if ('key' in current.resource) return true;\n return 'id' in authoritative.resource && current.resource.id === authoritative.resource.id;\n}\n\nfunction requiresIdentityReallocation(candidate: NormalizedIntent): boolean {\n if (\n !candidate.current ||\n sourceIdentityKey(candidate.current.mapping.source) === sourceIdentityKey(candidate.source)\n )\n return false;\n return candidate.current.codec === 'raw'\n ? candidate.current.mapping.detached\n : candidate.current.mapping.selector.file.startsWith('detached/');\n}\n\nfunction selectedHeadDamage(\n input: PlanAuthoritativePlacementInput,\n diagnostics: ProjectionDiagnostic[],\n): ReadonlyMap<string, AuthoritativeDamageEvidence> {\n if (!input.head) return new Map();\n try {\n const authoritative = input.headDocuments;\n if (!authoritative) throw new Error('Selected Head was not validated');\n const damage = extractAuthoritativeDamageEvidence(input.head, authoritative);\n if (\n input.documents.length !== input.documentKeys.length ||\n new Set(input.documentKeys).size !== input.documentKeys.length\n )\n throw new Error('Selected documents are missing, duplicated or misaligned');\n for (const [index, document] of input.documents.entries()) {\n const documentKey = input.documentKeys[index];\n const expected = authoritative.get(documentKey);\n if (\n !expected ||\n canonicalFragmentHash({ documentKey, document }) !==\n canonicalFragmentHash({ documentKey, document: expected })\n )\n throw new Error(`Selected document does not match Head: ${documentKey}`);\n }\n return damage;\n } catch (error) {\n diagnostics.push(\n diagnostic(\n 'invalid-authoritative-head',\n '.',\n error instanceof Error ? error.message : 'Selected Head is invalid',\n ),\n );\n return new Map();\n }\n}\n\nfunction pathInside(path: string, root: string): boolean {\n const candidate = layoutCollisionKey(path);\n const ancestor = layoutCollisionKey(root);\n return candidate === ancestor || candidate.startsWith(`${ancestor}/`);\n}\n\n/** A transient combined table shares one token between its definition and member set, so match the selector too. */\nfunction currentGroupedMapping(\n supplied: WireSourceMapping,\n index: ReadonlyMap<string, WireSourceMapping[]>,\n): WireSourceMapping | undefined {\n const matches = (index.get(sourceIdentityKey(supplied.source)) ?? []).filter(\n (candidate) =>\n sameSelector(candidate.selector, supplied.selector) &&\n samePath(candidate.sourcePath, supplied.sourcePath) &&\n candidate.documentIndex === supplied.documentIndex &&\n candidate.derivedSelectorHash === supplied.derivedSelectorHash &&\n JSON.stringify(candidate.groupOwner) === JSON.stringify(supplied.groupOwner),\n );\n return matches.length === 1 ? matches[0] : undefined;\n}\n\nfunction currentRawMapping(\n supplied: RawFileWireSourceMapping,\n index: ReadonlyMap<string, RawFileWireSourceMapping>,\n): RawFileWireSourceMapping | undefined {\n const candidate = index.get(sourceIdentityKey(supplied.source));\n return candidate &&\n sameBinarySelector(candidate.selector, supplied.selector) &&\n samePath(candidate.sourcePath, supplied.sourcePath) &&\n candidate.bytes === supplied.bytes &&\n candidate.documentIndex === supplied.documentIndex &&\n candidate.detached === supplied.detached &&\n candidate.nameOverride === supplied.nameOverride\n ? candidate\n : undefined;\n}\n\nfunction groupOwner(document: Document): GroupOwnerSelector | undefined {\n const owner = object(document.owner);\n if (!owner || typeof owner.kind !== 'string') return undefined;\n if (typeof owner.id === 'string' && RESOURCE_ID.test(owner.id)) return { kind: owner.kind, id: owner.id };\n if (typeof owner.key === 'string' && owner.key) return { kind: owner.kind, key: owner.key };\n if (typeof owner.dangling === 'string' && RESOURCE_ID.test(owner.dangling))\n return { kind: owner.kind, dangling: owner.dangling };\n return undefined;\n}\n\nfunction hasExplicitDamageShape(document: Document): boolean {\n const value = document as JsonObject;\n if (document.kind === 'folder') return value.path === null && typeof object(value.parent)?.dangling === 'string';\n if (document.kind === 'share') return typeof object(value.owner)?.dangling === 'string';\n return (\n ['variable', 'dimension_table', 'sheet', 'dashboard', 'remote_job', 'file'].includes(document.kind) &&\n typeof object(value.folder)?.dangling === 'string'\n );\n}\n\n/**\n * The sources routed to each present artifact, in the order the compositions list them. Built once\n * per placement, so classifying every artifact never rescans every mapping.\n */\nfunction artifactRouteSourceIndex(\n grouped: ComposeGroupedLayoutResult,\n binary: ComposeBinaryLayoutResult,\n): (artifact: LayoutArtifact) => SourceIdentity[] {\n const push = (map: Map<string, SourceIdentity[]>, key: string, source: SourceIdentity) => {\n const list = map.get(key);\n if (list) list.push(source);\n else map.set(key, [source]);\n };\n const bySidecar = new Map<string, SourceIdentity[]>();\n const byRawBytes = new Map<string, SourceIdentity[]>();\n for (const mapping of binary.rawSources) {\n push(bySidecar, mapping.selector.sidecar, mapping.source);\n push(byRawBytes, JSON.stringify([mapping.selector.sidecar, mapping.bytes]), mapping.source);\n }\n const byAttachment = new Map<string, SourceIdentity[]>();\n for (const observation of binary.attachmentObservations)\n if (observation.currentHash !== undefined && observation.bytes !== undefined)\n push(byAttachment, observation.bytes, observation.source);\n const byFile = new Map<string, SourceIdentity[]>();\n for (const mapping of grouped.sources) push(byFile, mapping.selector.file, mapping.source);\n const observedByFile = new Map<string, SourceIdentity[]>();\n for (const observation of grouped.observations)\n if (observation.currentHash !== undefined) push(observedByFile, observation.selector.file, observation.source);\n return (artifact) => {\n if (artifact.role === 'raw-metadata') return [...(bySidecar.get(artifact.path) ?? [])];\n if (artifact.role === 'raw')\n return [...(byRawBytes.get(JSON.stringify([artifact.source, artifact.path])) ?? [])];\n if (artifact.role === 'attachment') return [...(byAttachment.get(artifact.path) ?? [])];\n return [...(byFile.get(artifact.path) ?? []), ...(observedByFile.get(artifact.path) ?? [])];\n };\n}\n\nfunction occupancy(input: PlanAuthoritativePlacementInput, diagnostics: ProjectionDiagnostic[]): OccupancyEntry[] {\n const entries: OccupancyEntry[] = [];\n const classified = new Set<string>();\n const artifactRouteSources = artifactRouteSourceIndex(input.currentGrouped, input.currentBinary);\n for (const artifact of input.scan.artifacts) {\n if (!artifact.present) continue;\n const sources = artifactRouteSources(artifact);\n if (sources.length === 0 && artifact.role !== 'raw-metadata') {\n diagnostics.push(\n diagnostic(\n 'unclassified-layout-occupancy',\n artifact.path,\n 'A present managed artifact has no source route',\n ),\n );\n continue;\n }\n const claimPath = artifact.role === 'folder-control' ? folderDirectory(artifact.path) : artifact.path;\n const classification = `${claimPath}\\0${artifact.role === 'folder-control' ? 'directory' : 'file'}`;\n if (classified.has(classification))\n throw new Error(`Managed path ${JSON.stringify(claimPath)} has more than one classification`);\n classified.add(classification);\n entries.push({\n claim: {\n path: claimPath,\n kind: artifact.role === 'folder-control' ? 'directory' : 'file',\n role:\n artifact.role === 'folder-control'\n ? 'directory'\n : artifact.role === 'raw'\n ? 'raw'\n : artifact.role === 'attachment'\n ? 'attachment'\n : artifact.role === 'raw-metadata'\n ? 'control'\n : 'document',\n identity: `current:${claimPath}`,\n },\n sources: new Set(sources.map(sourceIdentityKey)),\n });\n }\n // A local-only file never carries a managed name, so an unportable one is ignored, not refused.\n for (const path of input.scan.localOnlyFiles)\n if (isPortableWorkspacePointer(path))\n entries.push({\n claim: { path, kind: 'file', role: 'raw', identity: `local:${path}` },\n sources: new Set(),\n });\n // An interrupted write stages a directory under a temporary name; it is local-only too.\n for (const path of input.scan.opaqueDirectories)\n if (isPortableWorkspacePointer(path))\n entries.push({\n claim: { path, kind: 'directory', role: 'directory', identity: `opaque:${path}` },\n sources: new Set(),\n opaque: true,\n });\n return entries;\n}\n\n/** Plan inactive authoritative readback correspondence. This function does not write or accept patches. */\nexport function planAuthoritativePlacement(input: PlanAuthoritativePlacementInput): PlanAuthoritativePlacementResult {\n const diagnostics: ProjectionDiagnostic[] = [\n ...input.scan.diagnostics.map((entry) => ({ ...entry })),\n ...input.currentGrouped.diagnostics,\n ...input.currentBinary.diagnostics,\n ];\n const authoritativeDamage = selectedHeadDamage(input, diagnostics);\n const placement = input.placement;\n if (diagnostics.length > 0) return blocked(diagnostics);\n const groupedBySource = groupBySource(input.currentGrouped.sources, (mapping) => sourceIdentityKey(mapping.source));\n const rawBySource = indexBySource(\n input.currentBinary.rawSources,\n (mapping) => sourceIdentityKey(mapping.source),\n 'The current binary layout',\n );\n const groupedObservationsBySource = groupBySource(input.currentGrouped.observations, (observation) =>\n sourceIdentityKey(observation.source),\n );\n const rawObservationsBySource = groupBySource(input.currentBinary.rawObservations, (observation) =>\n sourceIdentityKey(observation.source),\n );\n const currentSourceKeys = new Set([\n ...groupedBySource.keys(),\n ...rawBySource.keys(),\n ...groupedObservationsBySource.keys(),\n ...rawObservationsBySource.keys(),\n ...input.currentBinary.attachmentObservations.map((observation) => sourceIdentityKey(observation.source)),\n ]);\n\n const normalized: NormalizedIntent[] = [];\n const usedIndexes = new Set<number>();\n const usedKeys = new Set<string>();\n const usedSources = new Set<string>();\n const usedCurrentCorrespondences = new Set<string>();\n for (const intent of input.intents) {\n const document = input.documents[intent.documentIndex];\n const documentKey = input.documentKeys[intent.documentIndex];\n const source = document && documentKey === intent.documentKey ? sourceFor(documentKey, document) : undefined;\n if (\n !document ||\n !source ||\n usedIndexes.has(intent.documentIndex) ||\n usedKeys.has(intent.documentKey) ||\n usedSources.has(sourceIdentityKey(source))\n ) {\n diagnostics.push(\n diagnostic(\n 'invalid-authoritative-intent',\n intent.documentKey,\n 'Intent identity is invalid or duplicated',\n ),\n );\n continue;\n }\n usedIndexes.add(intent.documentIndex);\n usedKeys.add(intent.documentKey);\n usedSources.add(sourceIdentityKey(source));\n const damage = authoritativeDamage.get(documentKey);\n if (hasExplicitDamageShape(document) && !damage) {\n diagnostics.push(\n diagnostic(\n 'missing-authoritative-damage-evidence',\n intent.documentKey,\n 'Explicit damage requires evidence from the selected Head',\n ),\n );\n continue;\n }\n let current: AuthoritativeCurrentSource | undefined;\n let currentDocument: Document | undefined;\n if (intent.mode === 'replace-proven') {\n if (typeof intent.expectedCurrentHash !== 'string' || !intent.expectedCurrentHash) {\n diagnostics.push(\n diagnostic('invalid-authoritative-intent', intent.documentKey, 'Replacement hash is missing'),\n );\n continue;\n }\n if (intent.current.codec === 'grouped') {\n const mapping = currentGroupedMapping(intent.current.mapping, groupedBySource);\n const observations = mapping\n ? (groupedObservationsBySource.get(sourceIdentityKey(mapping.source)) ?? []).filter(\n (observation) =>\n sameSelector(observation.selector, mapping.selector) &&\n observation.currentHash === intent.expectedCurrentHash,\n )\n : [];\n if (!mapping || observations.length !== 1) {\n diagnostics.push(\n diagnostic(\n 'stale-authoritative-source',\n intent.documentKey,\n 'Grouped replacement source is not exact',\n ),\n );\n continue;\n }\n current = { codec: 'grouped', mapping };\n currentDocument = input.currentGrouped.documents[mapping.documentIndex];\n } else {\n const mapping = currentRawMapping(intent.current.mapping, rawBySource);\n const observations = mapping\n ? (rawObservationsBySource.get(sourceIdentityKey(mapping.source)) ?? []).filter(\n (observation) =>\n sameBinarySelector(observation.selector, mapping.selector) &&\n observation.currentHash === intent.expectedCurrentHash,\n )\n : [];\n if (!mapping || observations.length !== 1) {\n diagnostics.push(\n diagnostic(\n 'stale-authoritative-source',\n intent.documentKey,\n 'Raw replacement source is not exact',\n ),\n );\n continue;\n }\n current = { codec: 'raw', mapping };\n currentDocument = input.currentBinary.rawDocuments[mapping.documentIndex];\n }\n if (!currentDocument) {\n diagnostics.push(\n diagnostic('stale-authoritative-source', intent.documentKey, 'Current source has no document'),\n );\n continue;\n }\n if (!currentCanBecome(current.mapping.source, source, currentDocument)) {\n diagnostics.push(\n diagnostic(\n 'stale-authoritative-source',\n intent.documentKey,\n 'Current source cannot bind this identity',\n ),\n );\n continue;\n }\n } else {\n const key = sourceIdentityKey(source);\n const semanticAssociation =\n document.kind !== 'share' &&\n [\n ...input.currentGrouped.sources.map((mapping) => ({\n document: input.currentGrouped.documents[mapping.documentIndex],\n source: mapping.source,\n })),\n ...input.currentBinary.rawSources.map((mapping) => ({\n document: input.currentBinary.rawDocuments[mapping.documentIndex],\n source: mapping.source,\n })),\n ].some(\n (current) =>\n (current.source.type === 'transient' ||\n (current.source.type === 'resource' && 'key' in current.source.resource)) &&\n current.document?.kind === document.kind &&\n placementSignature(current.document) === placementSignature(document),\n );\n const priorAssociation =\n input.groupedRoutes.some((route) => sourceIdentityKey(route.source) === key) ||\n currentSourceKeys.has(key) ||\n own(input.canonicalBaseline as JsonObject, intent.documentKey) ||\n input.scan.tracked.some((tracked) => tracked.route === intent.documentKey);\n // A forced re-insert discards the local deletion; another artifact's claim still refuses.\n if (semanticAssociation || (priorAssociation && !intent.reinsert)) {\n diagnostics.push(\n diagnostic('invalid-insertion-authority', intent.documentKey, 'A prior source association exists'),\n );\n continue;\n }\n }\n const raw = document.kind === 'file';\n if ((raw && current?.codec === 'grouped') || (!raw && current?.codec === 'raw')) {\n diagnostics.push(\n diagnostic('invalid-authoritative-intent', intent.documentKey, 'Intent uses the wrong codec'),\n );\n continue;\n }\n if (current) {\n const currentKey = JSON.stringify([\n current.codec,\n sourceIdentityKey(current.mapping.source),\n current.mapping.selector,\n current.mapping.sourcePath,\n ]);\n if (usedCurrentCorrespondences.has(currentKey)) {\n diagnostics.push(\n diagnostic(\n 'invalid-authoritative-intent',\n intent.documentKey,\n 'Current correspondence is used by more than one intent',\n ),\n );\n continue;\n }\n usedCurrentCorrespondences.add(currentKey);\n }\n normalized.push({\n intent,\n document,\n documentKey,\n source,\n current,\n currentDocument,\n outputIndex: -1,\n damage,\n });\n }\n const semanticOwners = new Map<string, string>();\n for (const candidate of normalized) {\n if (candidate.damage) continue;\n const path = semanticPath(candidate.document);\n if (!path || candidate.document.kind === 'dimension_members') continue;\n const key = canonicalFragmentHash(path);\n const previous = semanticOwners.get(key);\n if (previous)\n diagnostics.push(\n diagnostic(\n 'duplicate-semantic-target',\n candidate.documentKey,\n `Semantic target is also owned by ${previous}`,\n ),\n );\n else semanticOwners.set(key, candidate.documentKey);\n }\n if (diagnostics.length > 0) return blocked(diagnostics);\n\n const groupedIntents = normalized\n .filter((candidate) => candidate.document.kind !== 'file')\n .sort((left, right) => left.intent.documentIndex - right.intent.documentIndex);\n const rawIntents = normalized\n .filter((candidate) => candidate.document.kind === 'file')\n .sort((left, right) => left.intent.documentIndex - right.intent.documentIndex);\n groupedIntents.forEach((candidate, index) => (candidate.outputIndex = index));\n rawIntents.forEach((candidate, index) => (candidate.outputIndex = index));\n const assignedResourcesByCurrent = new Map<string, Extract<SourceIdentity, { type: 'resource' }>>();\n for (const candidate of normalized) {\n const currentSource = candidate.current?.mapping.source;\n if (\n candidate.intent.mode === 'replace-proven' &&\n currentSource?.type === 'resource' &&\n 'key' in currentSource.resource &&\n sourceIdentityKey(currentSource) !== sourceIdentityKey(candidate.source)\n )\n assignedResourcesByCurrent.set(sourceIdentityKey(currentSource), candidate.source);\n }\n const finalGroupOwner = (owner: GroupOwnerSelector): GroupOwnerSelector => {\n if (!('key' in owner)) return owner;\n const assigned = assignedResourcesByCurrent.get(\n sourceIdentityKey({ type: 'resource', resource: { kind: owner.kind, key: owner.key } }),\n );\n return assigned && 'id' in assigned.resource\n ? { kind: assigned.resource.kind, id: assigned.resource.id }\n : owner;\n };\n const finalGroupOwnerKey = (owner: GroupOwnerSelector): string => groupOwnerKey(finalGroupOwner(owner));\n const currentHasDamageProof = (candidate: NormalizedIntent): boolean => {\n if (candidate.current?.codec === 'grouped' && candidate.current.mapping.selector.file.startsWith('detached/'))\n return input.detachedDocumentProofs[candidate.current.mapping.selector.file]?.reason === 'damage-proof';\n if (candidate.current?.codec === 'raw' && candidate.current.mapping.detached)\n return input.detachedFileProofs[candidate.current.mapping.selector.sidecar]?.reason === 'damage-proof';\n return false;\n };\n\n const releasedClaims = new Map<string, Set<string>>();\n const vacatedFolderSources = new Set<string>();\n for (const candidate of normalized) {\n if (\n candidate.intent.mode !== 'replace-proven' ||\n !candidate.current ||\n (!candidate.damage &&\n !(input.head && currentHasDamageProof(candidate)) &&\n placementSignature(candidate.document) === placementSignature(candidate.currentDocument) &&\n !requiresIdentityReallocation(candidate))\n )\n continue;\n const sourceKey = sourceIdentityKey(candidate.current.mapping.source);\n // A raw file releases its bytes and the sidecar beside them; they always travel together.\n const claimPaths =\n candidate.current.codec === 'raw'\n ? [candidate.current.mapping.bytes, candidate.current.mapping.selector.sidecar]\n : [\n candidate.document.kind === 'folder' &&\n candidate.current.mapping.selector.file.endsWith('/_folder.json')\n ? folderDirectory(candidate.current.mapping.selector.file)\n : candidate.current.mapping.selector.file,\n ];\n releasedClaims.set(sourceKey, new Set([...(releasedClaims.get(sourceKey) ?? []), ...claimPaths]));\n if (candidate.document.kind === 'folder') vacatedFolderSources.add(sourceKey);\n }\n const occupied = occupancy(input, diagnostics);\n if (diagnostics.length > 0) return blocked(diagnostics);\n const retainedClaims = occupied\n .filter(\n (entry) =>\n entry.sources.size === 0 ||\n [...entry.sources].some((source) => !releasedClaims.get(source)?.has(entry.claim.path)),\n )\n .map((entry) => entry.claim);\n let allocator: LayoutPathAllocator;\n try {\n allocator = new LayoutPathAllocator(retainedClaims);\n } catch (error) {\n return blocked([diagnostic('invalid-layout-occupancy', '.', (error as Error).message)]);\n }\n const opaqueRoots = occupied.filter((entry) => entry.opaque).map((entry) => entry.claim.path);\n const forbidden = (path: string) => opaqueRoots.some((root) => pathInside(path, root));\n const allocations: { source: SourceIdentity; path: AllocatedLayoutPath }[] = [];\n const detachedDocumentProofs: Record<string, DetachedDocumentProof> = {};\n const detachedFileProofs: Record<string, DetachedFileProof> = {};\n const groupedSources: AllocatedGroupedCorrespondence[] = [];\n const rawSources: AllocatedRawCorrespondence[] = [];\n const attachments: AllocatedAttachmentCorrespondence[] = [];\n const ownerInsertions: AuthoritativeOwnerAttachmentInsertion[] = [];\n const plannedFolders = new Map<string, PlannedFolder>();\n const destinationBySource = new Map<string, FragmentSelector>();\n\n const claimFixed = (claim: LayoutPathClaim): boolean => {\n if (forbidden(claim.path)) {\n diagnostics.push(diagnostic('opaque-layout-target', claim.path, 'Target is inside an opaque subtree'));\n return false;\n }\n try {\n allocator.claim(claim);\n return true;\n } catch (error) {\n diagnostics.push(diagnostic('occupied-layout-target', claim.path, (error as Error).message));\n return false;\n }\n };\n const reserveControl = (path: string, identity: string): boolean => {\n const existing = allocator.snapshot().filter((claim) => claim.path === path);\n if (existing.length > 0) {\n if (existing.length === 1 && existing[0].kind === 'file' && existing[0].role === 'control') return true;\n diagnostics.push(\n diagnostic('occupied-layout-target', path, 'Reserved control path has competing ownership'),\n );\n return false;\n }\n return claimFixed({ path, kind: 'file', role: 'control', identity });\n };\n const resolveParent = (\n path: readonly string[],\n childKey: string,\n ): PlannedFolder | { type: 'normal'; directory: 'tree' } | undefined => {\n if (path.length === 0) return { type: 'normal', directory: 'tree' };\n const key = canonicalFragmentHash([...path]);\n const planned = plannedFolders.get(key);\n if (planned) return planned;\n const current = placement.folderPlacement(path);\n if (!current || current.type === 'damaged' || vacatedFolderSources.has(sourceIdentityKey(current.source))) {\n diagnostics.push(\n diagnostic('missing-layout-parent', childKey, 'Semantic parent is missing, ambiguous, or damaged'),\n );\n return undefined;\n }\n return current;\n };\n const resolveInheritedFinalParent = (\n candidate: NormalizedIntent,\n path: readonly string[],\n proof: DetachedDocumentProof | DetachedFileProof | undefined,\n ):\n | { required: false }\n | {\n required: true;\n parent: PlannedFolder | CurrentFolderPlacement | { type: 'normal'; directory: 'tree' } | undefined;\n } => {\n const required =\n candidate.intent.mode === 'replace-proven' &&\n !requiresIdentityReallocation(candidate) &&\n proof?.reason === 'representation-fallback' &&\n proof.inheritedFrom !== undefined;\n return required\n ? { required: true, parent: resolveParent(path.slice(0, -1), candidate.documentKey) }\n : { required: false };\n };\n /** The five facts that let a replacement keep its current physical route. */\n const placementUnchanged = (candidate: NormalizedIntent, inheritedRequired: boolean): boolean =>\n candidate.intent.mode === 'replace-proven' &&\n !requiresIdentityReallocation(candidate) &&\n !(input.head && !candidate.damage && currentHasDamageProof(candidate)) &&\n !inheritedRequired &&\n placementSignature(candidate.document) === placementSignature(candidate.currentDocument);\n const inheritedProof = (\n candidate: NormalizedIntent,\n parent: Extract<PlannedFolder | CurrentFolderPlacement, { type: 'detached-representation' }>,\n ): DetachedDocumentProof => ({\n reason: 'representation-fallback',\n sourceKey: sourceIdentityKey(candidate.source),\n inheritedFrom: {\n sourceKey: sourceIdentityKey(parent.source),\n semanticPathHash: parent.semanticPathHash,\n },\n });\n const allocateAttachmentBytes = (\n candidate: NormalizedIntent,\n ownerFile: string,\n field: AttachmentField,\n ): string | undefined => {\n try {\n const allocated = allocator.allocate({\n directory: parentDirectory(ownerFile),\n name: String(candidate.document.name),\n extension: field === 'icon' ? '.icon' : '.xlsx',\n role: 'attachment',\n identity: `${identityValue(candidate.source)}/${field}`,\n });\n allocations.push({ source: candidate.source, path: allocated });\n return allocated.path;\n } catch (error) {\n diagnostics.push(diagnostic('invalid-attachment-target', candidate.documentKey, (error as Error).message));\n return undefined;\n }\n };\n const detachedPath = (source: Extract<SourceIdentity, { type: 'resource' }>): string =>\n `detached/${source.resource.kind}/${encodeLayoutSegment(identityValue(source))}.json`;\n const damagedGroupedDestination = (\n candidate: NormalizedIntent,\n slot: 'document' | 'table-definition',\n ): FragmentSelector | undefined => {\n const path = detachedPath(candidate.source);\n if (\n candidate.intent.mode === 'replace-proven' &&\n candidate.current?.codec === 'grouped' &&\n candidate.current.mapping.selector.file === path &&\n candidate.current.mapping.selector.slot === slot\n ) {\n if (forbidden(path)) {\n diagnostics.push(diagnostic('opaque-layout-target', path, 'Target is inside an opaque subtree'));\n return undefined;\n }\n return candidate.current.mapping.selector;\n }\n return claimFixed({ path, kind: 'file', role: 'document', identity: sourceIdentityKey(candidate.source) })\n ? { file: path, slot }\n : undefined;\n };\n const inheritedDocument = (\n candidate: NormalizedIntent,\n parent: Extract<PlannedFolder | CurrentFolderPlacement, { type: 'detached-representation' }>,\n ): FragmentSelector | undefined => {\n const path = detachedPath(candidate.source);\n if (!claimFixed({ path, kind: 'file', role: 'document', identity: sourceIdentityKey(candidate.source) }))\n return undefined;\n detachedDocumentProofs[path] = inheritedProof(candidate, parent);\n return { file: path, slot: candidate.document.kind === 'dimension_table' ? 'table-definition' : 'document' };\n };\n const allocateDocument = (\n candidate: NormalizedIntent,\n request: LayoutPathRequest,\n slot: 'document' | 'table-definition',\n ): FragmentSelector | undefined => {\n if (forbidden(request.directory)) {\n diagnostics.push(\n diagnostic('opaque-layout-target', request.directory, 'Parent is inside an opaque subtree'),\n );\n return undefined;\n }\n const before = allocator.snapshot();\n try {\n const allocated = allocator.allocate(request);\n if (forbidden(allocated.path)) {\n diagnostics.push(\n diagnostic('opaque-layout-target', allocated.path, 'Target is inside an opaque subtree'),\n );\n return undefined;\n }\n allocations.push({ source: candidate.source, path: allocated });\n return { file: allocated.path, slot };\n } catch (error) {\n if (!(error instanceof LayoutPathAllocationError) || error.reason !== 'unrepresentable') {\n diagnostics.push(diagnostic('invalid-layout-request', candidate.documentKey, (error as Error).message));\n return undefined;\n }\n if (!ITEM_KINDS.has(candidate.document.kind)) {\n diagnostics.push(\n diagnostic(\n 'unrepresentable-layout-target',\n candidate.documentKey,\n 'This resource kind cannot use detached representation',\n ),\n );\n return undefined;\n }\n const path = detachedPath(candidate.source);\n if (!claimFixed({ path, kind: 'file', role: 'document', identity: sourceIdentityKey(candidate.source) }))\n return undefined;\n detachedDocumentProofs[path] = {\n reason: 'representation-fallback',\n sourceKey: sourceIdentityKey(candidate.source),\n request,\n existingClaims: before,\n };\n return { file: path, slot };\n }\n };\n\n for (const candidate of groupedIntents.filter(\n (item) => item.document.kind === 'folder' && item.damage !== undefined,\n )) {\n const destination = damagedGroupedDestination(candidate, 'document');\n if (destination) destinationBySource.set(sourceIdentityKey(candidate.source), destination);\n }\n\n const folderIntents = groupedIntents\n .filter((candidate) => candidate.document.kind === 'folder' && !candidate.damage)\n .sort((left, right) => {\n const leftPath = semanticPath(left.document)?.length ?? Number.MAX_SAFE_INTEGER;\n const rightPath = semanticPath(right.document)?.length ?? Number.MAX_SAFE_INTEGER;\n return (\n leftPath - rightPath || sourceIdentityKey(left.source).localeCompare(sourceIdentityKey(right.source))\n );\n });\n for (const candidate of folderIntents) {\n const path = semanticPath(candidate.document);\n if (!path || path.length === 0) {\n diagnostics.push(diagnostic('invalid-layout-semantics', candidate.documentKey, 'Folder path is invalid'));\n continue;\n }\n const key = canonicalFragmentHash(path);\n if (plannedFolders.has(key)) {\n diagnostics.push(\n diagnostic('duplicate-folder-target', candidate.documentKey, 'Folder semantic path is duplicated'),\n );\n continue;\n }\n const currentAtPath = placement.folderPlacement(path);\n // Folder paths are exact but directories fold case, so the guard compares folded segments.\n const owner = sourceIdentityKey(candidate.current?.mapping.source ?? candidate.source);\n const colliding = placement\n .collidingFolderPlacements(path)\n .filter(\n (folder) =>\n !vacatedFolderSources.has(sourceIdentityKey(folder.source)) &&\n sourceIdentityKey(folder.source) !== owner,\n );\n if (colliding.length > 0) {\n diagnostics.push(\n diagnostic(\n 'ambiguous-folder-target',\n candidate.documentKey,\n 'Semantic folder path is still owned by another current source',\n ),\n );\n continue;\n }\n const currentDetachedProof =\n candidate.current?.codec === 'grouped' && candidate.current.mapping.selector.file.startsWith('detached/')\n ? input.detachedDocumentProofs[candidate.current.mapping.selector.file]\n : undefined;\n const inherited = resolveInheritedFinalParent(candidate, path, currentDetachedProof);\n const unchanged =\n placementUnchanged(candidate, inherited.required) &&\n currentAtPath !== undefined &&\n sourceIdentityKey(currentAtPath.source) === sourceIdentityKey(candidate.current!.mapping.source);\n let destination: FragmentSelector | undefined;\n let folder: PlannedFolder | undefined;\n if (unchanged && currentAtPath?.type === 'normal') {\n destination = { file: `${currentAtPath.directory}/_folder.json`, slot: 'document' };\n folder = currentAtPath;\n } else if (unchanged && currentAtPath?.type === 'detached-representation') {\n destination = candidate.current?.codec === 'grouped' ? candidate.current.mapping.selector : undefined;\n folder = currentAtPath;\n const proof = destination && input.detachedDocumentProofs[destination.file];\n if (destination && proof) detachedDocumentProofs[destination.file] = proof;\n } else if (\n inherited.required &&\n inherited.parent?.type === 'detached-representation' &&\n candidate.current?.codec === 'grouped'\n ) {\n destination = candidate.current.mapping.selector;\n folder = {\n type: 'detached-representation',\n source: candidate.source,\n semanticPath: path,\n semanticPathHash: canonicalFragmentHash(path),\n };\n detachedDocumentProofs[destination.file] = inheritedProof(candidate, inherited.parent);\n } else if (\n candidate.intent.mode === 'replace-proven' &&\n currentAtPath?.type === 'damaged' &&\n sourceIdentityKey(currentAtPath.source) === sourceIdentityKey(candidate.current!.mapping.source) &&\n placementSignature(candidate.document) === placementSignature(candidate.currentDocument) &&\n !input.head\n ) {\n diagnostics.push(\n diagnostic('damaged-current-placement', candidate.documentKey, 'Damaged placement requires repair'),\n );\n } else {\n const parent = inherited.required\n ? inherited.parent\n : resolveParent(path.slice(0, -1), candidate.documentKey);\n if (parent?.type === 'detached-representation') {\n destination = inheritedDocument(candidate, parent);\n if (destination)\n folder = {\n type: 'detached-representation',\n source: candidate.source,\n semanticPath: path,\n semanticPathHash: canonicalFragmentHash(path),\n };\n } else if (parent?.type === 'normal') {\n const request: LayoutPathRequest = {\n directory: parent.directory,\n name: path.at(-1)!,\n role: 'directory',\n identity: identityValue(candidate.source),\n requiredChildren: ['_folder.json'],\n };\n const selector = allocateDocument(candidate, request, 'document');\n if (selector) {\n if (selector.file.startsWith('detached/')) {\n destination = selector;\n folder = {\n type: 'detached-representation',\n source: candidate.source,\n semanticPath: path,\n semanticPathHash: canonicalFragmentHash(path),\n };\n } else {\n const directory = selector.file;\n if (\n reserveControl(`${directory}/_folder.json`, `folder:${sourceIdentityKey(candidate.source)}`)\n ) {\n destination = { file: `${directory}/_folder.json`, slot: 'document' };\n folder = { type: 'normal', source: candidate.source, semanticPath: path, directory };\n }\n }\n }\n }\n }\n if (!destination || !folder) continue;\n plannedFolders.set(key, folder);\n destinationBySource.set(sourceIdentityKey(candidate.source), destination);\n }\n\n const damageBucketAvailable = (candidate: NormalizedIntent, bucket: string): boolean => {\n if (forbidden(bucket)) {\n diagnostics.push(diagnostic('opaque-layout-target', bucket, 'Target is inside an opaque subtree'));\n return false;\n }\n const occupants = occupied.filter((entry) => pathInside(entry.claim.path, bucket));\n if (occupants.length === 0) return true;\n const current = candidate.current?.codec === 'raw' ? candidate.current.mapping : undefined;\n const currentSource = current && sourceIdentityKey(current.source);\n const bucketSources = input.currentBinary.rawSources.filter(\n (mapping) => parentDirectory(mapping.selector.sidecar) === bucket,\n );\n const exactCurrent =\n current?.detached === true &&\n parentDirectory(current.selector.sidecar) === bucket &&\n current.selector.sidecar === rawSidecarPath(current.bytes) &&\n bucketSources.length === 1 &&\n sourceIdentityKey(bucketSources[0].source) === currentSource &&\n sameBinarySelector(bucketSources[0].selector, current.selector) &&\n bucketSources[0].bytes === current.bytes;\n const exclusivelyCurrent =\n currentSource !== undefined &&\n occupants.every((entry) => !entry.opaque && entry.sources.size === 1 && entry.sources.has(currentSource));\n if (exactCurrent && exclusivelyCurrent) return true;\n diagnostics.push(\n diagnostic('occupied-layout-target', bucket, 'Detached file bucket belongs to another layout source'),\n );\n return false;\n };\n const allocateDetachedRaw = (\n candidate: NormalizedIntent,\n parent?: Extract<PlannedFolder | CurrentFolderPlacement, { type: 'detached-representation' }>,\n direct?: { request: LayoutPathRequest; claims: LayoutPathClaim[] },\n ): { selector: RawFileSelector; bytes: string } | undefined => {\n const bucketRequest: LayoutPathRequest = {\n directory: 'detached/files',\n name: identityValue(candidate.source),\n role: 'directory',\n identity: sourceIdentityKey(candidate.source),\n };\n let bucket: AllocatedLayoutPath;\n try {\n bucket = allocator.allocate(bucketRequest);\n allocations.push({ source: candidate.source, path: bucket });\n } catch (error) {\n diagnostics.push(\n diagnostic('unrepresentable-detached-target', candidate.documentKey, (error as Error).message),\n );\n return undefined;\n }\n if (forbidden(bucket.path)) {\n diagnostics.push(diagnostic('opaque-layout-target', bucket.path, 'Target is inside an opaque subtree'));\n return undefined;\n }\n const path = semanticPath(candidate.document)!;\n let allocated: AllocatedLayoutPath;\n try {\n allocated = allocator.allocate({\n directory: bucket.path,\n name: path.at(-1)!,\n role: 'raw',\n identity: identityValue(candidate.source),\n });\n } catch (error) {\n diagnostics.push(\n diagnostic('unrepresentable-detached-target', candidate.documentKey, (error as Error).message),\n );\n return undefined;\n }\n allocations.push({ source: candidate.source, path: allocated });\n const selector: RawFileSelector = {\n sidecar: rawSidecarPath(allocated.path),\n slot: 'file-entry',\n identity: { id: identityValue(candidate.source) },\n };\n detachedFileProofs[selector.sidecar] = parent\n ? inheritedProof(candidate, parent)\n : {\n reason: 'representation-fallback',\n sourceKey: sourceIdentityKey(candidate.source),\n request: direct!.request,\n existingClaims: direct!.claims,\n };\n return { selector, bytes: allocated.path };\n };\n const rawDestinations = new Map<string, { selector: RawFileSelector; bytes: string }>();\n for (const candidate of [...rawIntents].sort((left, right) =>\n sourceIdentityKey(left.source).localeCompare(sourceIdentityKey(right.source)),\n )) {\n if (candidate.damage) {\n const bucket = `detached/files/${encodeLayoutSegment(identityValue(candidate.source))}`;\n if (!damageBucketAvailable(candidate, bucket)) continue;\n const bucketClaim: AllocatedLayoutPath = {\n path: bucket,\n kind: 'directory',\n role: 'directory',\n identity: sourceIdentityKey(candidate.source),\n fallback: false,\n };\n if (!claimFixed(bucketClaim)) continue;\n allocations.push({ source: candidate.source, path: bucketClaim });\n const name = candidate.document.name;\n if (typeof name !== 'string' || !name) {\n diagnostics.push(\n diagnostic('invalid-layout-semantics', candidate.documentKey, 'Damaged raw name is invalid'),\n );\n continue;\n }\n try {\n const allocated = allocator.allocate({\n directory: bucket,\n name,\n role: 'raw',\n identity: identityValue(candidate.source),\n });\n allocations.push({ source: candidate.source, path: allocated });\n rawDestinations.set(sourceIdentityKey(candidate.source), {\n selector: {\n sidecar: rawSidecarPath(allocated.path),\n slot: 'file-entry',\n identity: { id: identityValue(candidate.source) },\n },\n bytes: allocated.path,\n });\n } catch (error) {\n diagnostics.push(\n diagnostic('unrepresentable-detached-target', candidate.documentKey, (error as Error).message),\n );\n }\n continue;\n }\n const path = semanticPath(candidate.document);\n if (!path) {\n diagnostics.push(diagnostic('invalid-layout-semantics', candidate.documentKey, 'Raw placement is invalid'));\n continue;\n }\n let destination: { selector: RawFileSelector; bytes: string } | undefined;\n const currentDetachedProof =\n candidate.current?.codec === 'raw' && candidate.current.mapping.detached\n ? input.detachedFileProofs[candidate.current.mapping.selector.sidecar]\n : undefined;\n const inherited = resolveInheritedFinalParent(candidate, path, currentDetachedProof);\n const unchanged = placementUnchanged(candidate, inherited.required);\n if (unchanged && candidate.current?.codec === 'raw') {\n destination = {\n selector: {\n ...candidate.current.mapping.selector,\n identity: { id: identityValue(candidate.source) },\n },\n bytes: candidate.current.mapping.bytes,\n };\n if (candidate.current.mapping.detached) {\n const proof = input.detachedFileProofs[candidate.current.mapping.selector.sidecar];\n if (proof) detachedFileProofs[candidate.current.mapping.selector.sidecar] = proof;\n }\n } else if (\n inherited.required &&\n inherited.parent?.type === 'detached-representation' &&\n candidate.current?.codec === 'raw'\n ) {\n destination = {\n selector: {\n ...candidate.current.mapping.selector,\n identity: { id: identityValue(candidate.source) },\n },\n bytes: candidate.current.mapping.bytes,\n };\n detachedFileProofs[candidate.current.mapping.selector.sidecar] = inheritedProof(\n candidate,\n inherited.parent,\n );\n } else {\n const parent = inherited.required\n ? inherited.parent\n : resolveParent(path.slice(0, -1), candidate.documentKey);\n if (parent?.type === 'detached-representation') destination = allocateDetachedRaw(candidate, parent);\n else if (parent?.type === 'normal') {\n if (forbidden(parent.directory)) {\n diagnostics.push(\n diagnostic('opaque-layout-target', parent.directory, 'Parent is inside an opaque subtree'),\n );\n continue;\n }\n const request: LayoutPathRequest = {\n directory: parent.directory,\n name: path.at(-1)!,\n role: 'raw',\n identity: identityValue(candidate.source),\n };\n const before = allocator.snapshot();\n try {\n const allocated = allocator.allocate(request);\n allocations.push({ source: candidate.source, path: allocated });\n destination = {\n selector: {\n sidecar: rawSidecarPath(allocated.path),\n slot: 'file-entry',\n identity: { id: identityValue(candidate.source) },\n },\n bytes: allocated.path,\n };\n } catch (error) {\n if (error instanceof LayoutPathAllocationError && error.reason === 'unrepresentable')\n destination = allocateDetachedRaw(candidate, undefined, { request, claims: before });\n else\n diagnostics.push(\n diagnostic('invalid-layout-request', candidate.documentKey, (error as Error).message),\n );\n }\n }\n }\n if (destination) rawDestinations.set(sourceIdentityKey(candidate.source), destination);\n }\n\n const groupedNonFolders = groupedIntents.filter((candidate) => candidate.document.kind !== 'folder');\n const tableDestinations = new Map<string, FragmentSelector>();\n const ordinary: {\n candidate: NormalizedIntent;\n request: LayoutPathRequest;\n slot: 'document' | 'table-definition';\n }[] = [];\n for (const candidate of groupedNonFolders) {\n const document = candidate.document;\n if (document.kind === 'dimension_members' || document.kind === 'share') continue;\n let destination: FragmentSelector | undefined;\n if (candidate.damage) {\n destination = damagedGroupedDestination(\n candidate,\n document.kind === 'dimension_table' ? 'table-definition' : 'document',\n );\n } else {\n const itemPath = ITEM_KINDS.has(document.kind) ? semanticPath(document) : undefined;\n const currentDetachedProof =\n candidate.current?.codec === 'grouped' &&\n candidate.current.mapping.selector.file.startsWith('detached/')\n ? input.detachedDocumentProofs[candidate.current.mapping.selector.file]\n : undefined;\n const inherited = itemPath\n ? resolveInheritedFinalParent(candidate, itemPath, currentDetachedProof)\n : { required: false as const };\n const unchanged = placementUnchanged(candidate, inherited.required);\n if (unchanged && candidate.current?.codec === 'grouped') destination = candidate.current.mapping.selector;\n else if (\n inherited.required &&\n inherited.parent?.type === 'detached-representation' &&\n candidate.current?.codec === 'grouped'\n ) {\n destination = candidate.current.mapping.selector;\n detachedDocumentProofs[destination.file] = inheritedProof(candidate, inherited.parent);\n } else if (ITEM_KINDS.has(document.kind)) {\n const path = itemPath;\n if (!path) {\n diagnostics.push(\n diagnostic('invalid-layout-semantics', candidate.documentKey, 'Item placement is invalid'),\n );\n continue;\n }\n const parent = inherited.required\n ? inherited.parent\n : resolveParent(path.slice(0, -1), candidate.documentKey);\n if (parent?.type === 'detached-representation') destination = inheritedDocument(candidate, parent);\n else if (parent?.type === 'normal')\n ordinary.push({\n candidate,\n request: {\n directory: parent.directory,\n name: path.at(-1)!,\n extension: '.json',\n role: 'document',\n identity: identityValue(candidate.source),\n },\n slot: document.kind === 'dimension_table' ? 'table-definition' : 'document',\n });\n } else if (document.kind === 'settings') {\n const path = 'definitions/settings.json';\n if (\n claimFixed({\n path,\n kind: 'file',\n role: 'document',\n identity: sourceIdentityKey(candidate.source),\n })\n )\n destination = { file: path, slot: 'document' };\n } else if (document.kind === 'user_permissions') {\n // A Keycloak user is a bare id under `users/`; a service user is `{service: name}`.\n const user = object(document.user);\n const fields =\n typeof document.user === 'string' ? [['users', document.user]] : user ? Object.entries(user) : [];\n if (fields.length !== 1 || typeof fields[0][1] !== 'string' || !fields[0][1]) {\n diagnostics.push(\n diagnostic('invalid-layout-semantics', candidate.documentKey, 'Grant selector is invalid'),\n );\n continue;\n }\n ordinary.push({\n candidate,\n request: {\n directory: `access/grants/${encodeLayoutSegment(fields[0][0])}`,\n name: fields[0][1],\n extension: '.json',\n role: 'document',\n identity: identityValue(candidate.source),\n },\n slot: 'document',\n });\n } else {\n const root = FLAT_ROOTS[document.kind];\n const name = document.name;\n if (!root || typeof name !== 'string' || !name) {\n diagnostics.push(\n diagnostic(\n 'unsupported-layout-kind',\n candidate.documentKey,\n 'Document kind has no placement rule',\n ),\n );\n continue;\n }\n ordinary.push({\n candidate,\n request: {\n directory: root,\n name,\n extension: '.json',\n role: 'document',\n identity: identityValue(candidate.source),\n },\n slot: 'document',\n });\n }\n }\n if (destination) {\n destinationBySource.set(sourceIdentityKey(candidate.source), destination);\n if (destination.file.startsWith('detached/') && !detachedDocumentProofs[destination.file]) {\n const proof = input.detachedDocumentProofs[destination.file];\n if (proof) detachedDocumentProofs[destination.file] = proof;\n }\n if (document.kind === 'dimension_table')\n tableDestinations.set(identityValue(candidate.source), destination);\n }\n }\n ordinary.sort((left, right) =>\n sourceIdentityKey(left.candidate.source).localeCompare(sourceIdentityKey(right.candidate.source)),\n );\n for (const item of ordinary) {\n const destination = allocateDocument(item.candidate, item.request, item.slot);\n if (!destination) continue;\n destinationBySource.set(sourceIdentityKey(item.candidate.source), destination);\n if (item.candidate.document.kind === 'dimension_table')\n tableDestinations.set(identityValue(item.candidate.source), destination);\n }\n\n for (const candidate of groupedNonFolders.filter((item) => item.document.kind === 'dimension_members')) {\n const id = identityValue(candidate.source);\n let destination = tableDestinations.get(id);\n if (!destination) {\n const tableSource = `resource/dimension_table/id/${id}`;\n const table = input.currentGrouped.sources.filter(\n (mapping) =>\n sourceIdentityKey(mapping.source) === tableSource && mapping.selector.slot === 'table-definition',\n );\n const file =\n table.length === 1\n ? table[0].selector.file\n : candidate.current?.codec === 'grouped'\n ? candidate.current.mapping.selector.file\n : undefined;\n if (file) destination = { file, slot: 'member-set' };\n } else destination = { file: destination.file, slot: 'member-set' };\n if (!destination)\n diagnostics.push(\n diagnostic('missing-table-placement', candidate.documentKey, 'Member set has no table placement'),\n );\n else destinationBySource.set(sourceIdentityKey(candidate.source), destination);\n }\n\n const shareGroups = new Map<string, { owner: GroupOwnerSelector; file: string; nextIndex: number }>();\n for (const observation of input.currentGrouped.observations) {\n if (\n observation.selector.slot !== 'share-group-owner' ||\n observation.source.type !== 'group' ||\n observation.currentHash === undefined\n )\n continue;\n const key = finalGroupOwnerKey(observation.source.owner);\n const existing = shareGroups.get(key);\n if (!existing)\n shareGroups.set(key, {\n owner: observation.source.owner,\n file: observation.selector.file,\n nextIndex: 0,\n });\n else if (existing.file !== observation.selector.file)\n diagnostics.push(\n diagnostic('ambiguous-share-group', observation.selector.file, 'Owner has more than one share group'),\n );\n }\n for (const mapping of input.currentGrouped.sources) {\n if (mapping.selector.slot !== 'share-entry' || !mapping.groupOwner) continue;\n const key = finalGroupOwnerKey(mapping.groupOwner);\n const index = typeof mapping.sourcePath[1] === 'number' ? mapping.sourcePath[1] : -1;\n const existing = shareGroups.get(key);\n if (!existing)\n shareGroups.set(key, { owner: mapping.groupOwner, file: mapping.selector.file, nextIndex: index + 1 });\n else if (existing.file === mapping.selector.file) existing.nextIndex = Math.max(existing.nextIndex, index + 1);\n else\n diagnostics.push(\n diagnostic('ambiguous-share-group', mapping.selector.file, 'Owner has more than one share group'),\n );\n }\n const pendingShareGroups = new Map<string, NormalizedIntent[]>();\n const shareSourcePaths = new Map<string, (string | number)[]>();\n const shareMappingOwners = new Map<string, GroupOwnerSelector>();\n for (const candidate of groupedNonFolders.filter((item) => item.document.kind === 'share')) {\n const owner = groupOwner(candidate.document);\n if (!owner) {\n diagnostics.push(\n diagnostic('invalid-share-owner', candidate.documentKey, 'Share owner is not a stable selector'),\n );\n continue;\n }\n const key = groupOwnerKey(owner);\n if (candidate.current?.codec === 'grouped') {\n if (candidate.current.mapping.selector.slot !== 'share-entry') {\n diagnostics.push(\n diagnostic('invalid-share-source', candidate.documentKey, 'Current share selector is invalid'),\n );\n continue;\n }\n const currentOwner = candidate.current.mapping.groupOwner;\n if (!currentOwner || finalGroupOwnerKey(currentOwner) !== key) {\n diagnostics.push(diagnostic('owner-transfer', candidate.documentKey, 'Share owner cannot change'));\n continue;\n }\n destinationBySource.set(sourceIdentityKey(candidate.source), {\n ...candidate.current.mapping.selector,\n identity: { id: identityValue(candidate.source) },\n });\n } else pendingShareGroups.set(key, [...(pendingShareGroups.get(key) ?? []), candidate]);\n }\n for (const [key, candidates] of [...pendingShareGroups].sort(([left], [right]) => left.localeCompare(right))) {\n const owner = groupOwner(candidates[0].document)!;\n let group = shareGroups.get(key);\n if (!group) {\n const variant = 'id' in owner ? owner.id : 'key' in owner ? owner.key : owner.dangling;\n const request: LayoutPathRequest = {\n directory: 'access/shares',\n name: `${owner.kind}-${variant}`,\n extension: '.json',\n role: 'document',\n identity: key,\n };\n const representative = candidates[0];\n const destination = allocateDocument(representative, request, 'document');\n if (!destination) continue;\n group = { owner, file: destination.file, nextIndex: 0 };\n shareGroups.set(key, group);\n }\n for (const candidate of candidates.sort((left, right) =>\n sourceIdentityKey(left.source).localeCompare(sourceIdentityKey(right.source)),\n )) {\n const id = identityValue(candidate.source);\n shareMappingOwners.set(sourceIdentityKey(candidate.source), group.owner);\n destinationBySource.set(sourceIdentityKey(candidate.source), {\n file: group.file,\n slot: 'share-entry',\n identity: { id },\n });\n shareSourcePaths.set(sourceIdentityKey(candidate.source), ['shares', group.nextIndex]);\n group.nextIndex += 1;\n }\n }\n\n for (const candidate of rawIntents) {\n const path = semanticPath(candidate.document)!;\n const destination = rawDestinations.get(sourceIdentityKey(candidate.source));\n if (!destination) continue;\n const current = candidate.current?.codec === 'raw' ? candidate.current.mapping : undefined;\n const detached = destination.selector.sidecar.startsWith('detached/files/');\n const component = destination.bytes.slice(destination.bytes.lastIndexOf('/') + 1);\n const mapping: RawFileWireSourceMapping = current\n ? { ...current, documentIndex: candidate.outputIndex }\n : {\n documentIndex: candidate.outputIndex,\n source: candidate.source,\n selector: destination.selector,\n sourcePath: [],\n bytes: destination.bytes,\n detached,\n nameOverride: detached || component !== path.at(-1),\n };\n rawSources.push({\n mode: candidate.intent.mode,\n documentKey: candidate.documentKey,\n mapping,\n destination: destination.selector,\n bytes: destination.bytes,\n });\n }\n\n for (const candidate of groupedIntents) {\n const destination = destinationBySource.get(sourceIdentityKey(candidate.source));\n if (!destination) continue;\n const current = candidate.current?.codec === 'grouped' ? candidate.current.mapping : undefined;\n const owner = candidate.document.kind === 'share' ? groupOwner(candidate.document) : undefined;\n const mappingOwner = shareMappingOwners.get(sourceIdentityKey(candidate.source)) ?? owner;\n const mapping: WireSourceMapping = current\n ? {\n ...current,\n documentIndex: candidate.outputIndex,\n ...(candidate.document.kind === 'user_permissions'\n ? { derivedSelectorHash: derivedSourceSelectorHash(candidate.document) }\n : {}),\n }\n : {\n documentIndex: candidate.outputIndex,\n sourcePath: candidate.document.kind === 'dimension_members' ? ['members'] : [],\n source: candidate.source,\n selector: destination,\n ...(candidate.document.kind === 'user_permissions'\n ? { derivedSelectorHash: derivedSourceSelectorHash(candidate.document) }\n : {}),\n ...(mappingOwner\n ? {\n groupOwner: mappingOwner,\n wireOwner: object(candidate.document.owner),\n sourcePath: shareSourcePaths.get(sourceIdentityKey(candidate.source)) ?? ['shares', 0],\n }\n : {}),\n };\n groupedSources.push({ mode: candidate.intent.mode, documentKey: candidate.documentKey, mapping, destination });\n }\n\n for (const candidate of groupedIntents) {\n const field = attachmentField(candidate.document);\n if (!field) continue;\n const sourceKey = sourceIdentityKey(candidate.source);\n const destination = destinationBySource.get(sourceKey);\n if (!destination || destination.slot !== 'document') continue;\n const authored = candidate.document[field];\n if (field === 'template' && authored === undefined) {\n diagnostics.push(\n diagnostic(\n 'incomplete-attachment-input',\n candidate.documentKey,\n 'Template omission has no authoritative value',\n ),\n );\n continue;\n }\n if (authored !== null && authored !== undefined && !validBlob(authored)) {\n diagnostics.push(\n diagnostic('invalid-attachment-content', candidate.documentKey, 'Attachment descriptor is invalid'),\n );\n continue;\n }\n const currentOwnerSource = candidate.current?.mapping.source ?? candidate.source;\n const currentFields = input.currentBinary.ownerFields.filter(\n (projection) =>\n projection.field === field &&\n sourceIdentityKey(projection.ownerSource) === sourceIdentityKey(currentOwnerSource),\n );\n const current = currentFields.length === 1 ? currentFields[0] : undefined;\n if (candidate.intent.mode === 'replace-proven' && current && current.status !== 'value') {\n if (authored !== undefined && authored !== null)\n diagnostics.push(\n diagnostic(\n 'missing-current-attachment',\n candidate.documentKey,\n 'Non-null replacement has no current attachment association',\n ),\n );\n continue;\n }\n if (candidate.intent.mode === 'replace-proven' && current) {\n let bytes = authored !== null && authored !== undefined ? current.bytes : undefined;\n if (authored !== null && authored !== undefined && !bytes) {\n bytes = allocateAttachmentBytes(candidate, destination.file, field);\n if (!bytes) continue;\n }\n attachments.push({\n source: candidate.source,\n field,\n current,\n destination: {\n ownerFile: destination.file,\n field,\n ...(bytes ? { bytes } : {}),\n },\n });\n continue;\n }\n if (candidate.intent.mode === 'replace-proven' && authored !== null && authored !== undefined) {\n diagnostics.push(\n diagnostic(\n 'missing-current-attachment',\n candidate.documentKey,\n 'Replacement has no current attachment association',\n ),\n );\n continue;\n }\n if (candidate.intent.mode !== 'insert-authoritative' || authored === null || authored === undefined) continue;\n const bytes = allocateAttachmentBytes(candidate, destination.file, field);\n if (!bytes) continue;\n attachments.push({\n source: candidate.source,\n field,\n destination: { ownerFile: destination.file, field, bytes },\n });\n ownerInsertions.push({\n source: candidate.source,\n documentKey: candidate.documentKey,\n ownerFile: destination.file,\n ownerDocument: candidate.document,\n field,\n groupedSelector: { file: destination.file, slot: 'document' },\n });\n }\n\n const groupedTargetKeys = new Set<string>();\n const groupedFileOwners = new Map<string, AllocatedGroupedCorrespondence[]>();\n for (const correspondence of groupedSources) {\n const selector = correspondence.destination;\n const key =\n selector.slot === 'share-entry'\n ? JSON.stringify([selector.file, selector.slot, selector.identity])\n : JSON.stringify([selector.file, selector.slot]);\n if (groupedTargetKeys.has(key))\n diagnostics.push(\n diagnostic('duplicate-layout-target', selector.file, 'Grouped destination has competing ownership'),\n );\n groupedTargetKeys.add(key);\n const fileKey = layoutCollisionKey(selector.file);\n groupedFileOwners.set(fileKey, [...(groupedFileOwners.get(fileKey) ?? []), correspondence]);\n }\n for (const owners of groupedFileOwners.values()) {\n if (owners.length < 2) continue;\n const files = new Set(owners.map((owner) => owner.destination.file));\n const allShares =\n files.size === 1 &&\n owners.every((owner) => owner.destination.slot === 'share-entry' && owner.mapping.groupOwner) &&\n new Set(owners.map((owner) => finalGroupOwnerKey(owner.mapping.groupOwner!))).size === 1;\n const tableSlots = new Set(owners.map((owner) => owner.destination.slot));\n const tableDocuments = owners.map((owner) => owner.documentKey.split('/'));\n const tablePair =\n owners.length === 2 &&\n files.size === 1 &&\n tableSlots.has('table-definition') &&\n tableSlots.has('member-set') &&\n new Set(tableDocuments.map(([kind]) => kind)).size === 2 &&\n tableDocuments.some(([kind]) => kind === 'dimension_table') &&\n tableDocuments.some(([kind]) => kind === 'dimension_members') &&\n new Set(tableDocuments.map(([, id]) => id)).size === 1;\n if (!allShares && !tablePair)\n diagnostics.push(\n diagnostic(\n 'duplicate-layout-target',\n owners[0].destination.file,\n 'Grouped file has competing container ownership',\n ),\n );\n }\n const rawTargetKeys = new Set<string>();\n const physicalTargets = new Map<string, { path: string; kind: 'grouped' | 'sidecar' | 'bytes' }>();\n for (const owners of groupedFileOwners.values()) {\n const path = owners[0].destination.file;\n physicalTargets.set(layoutCollisionKey(path), { path, kind: 'grouped' });\n }\n const claimPhysicalTarget = (path: string, kind: 'sidecar' | 'bytes'): boolean => {\n const key = layoutCollisionKey(path);\n const existing = physicalTargets.get(key);\n if (!existing) {\n physicalTargets.set(key, { path, kind });\n return true;\n }\n diagnostics.push(\n diagnostic('duplicate-layout-target', path, `Physical target conflicts with ${existing.path}`),\n );\n return false;\n };\n for (const correspondence of rawSources) {\n const key = correspondence.destination.sidecar;\n if (rawTargetKeys.has(key))\n diagnostics.push(\n diagnostic('duplicate-layout-target', correspondence.bytes, 'Raw destination has competing ownership'),\n );\n rawTargetKeys.add(key);\n claimPhysicalTarget(correspondence.destination.sidecar, 'sidecar');\n claimPhysicalTarget(correspondence.bytes, 'bytes');\n }\n for (const correspondence of attachments) {\n const bytes = correspondence.destination.bytes;\n if (!bytes) continue;\n claimPhysicalTarget(bytes, 'bytes');\n }\n if (\n groupedSources.length !== groupedIntents.length ||\n rawSources.length !== rawIntents.length ||\n diagnostics.length > 0\n )\n return blocked(\n diagnostics.length > 0\n ? diagnostics\n : [diagnostic('incomplete-layout-placement', '.', 'Placement did not produce every requested mapping')],\n );\n\n groupedSources.sort((left, right) => left.mapping.documentIndex - right.mapping.documentIndex);\n rawSources.sort((left, right) => left.mapping.documentIndex - right.mapping.documentIndex);\n const groupedDamage = groupedSources.flatMap((correspondence): AuthoritativeDamagePlacement[] => {\n const evidence = authoritativeDamage.get(correspondence.documentKey);\n return evidence ? [{ codec: 'grouped', evidence, destination: correspondence.destination }] : [];\n });\n const rawDamage = rawSources.flatMap((correspondence): AuthoritativeDamagePlacement[] => {\n const evidence = authoritativeDamage.get(correspondence.documentKey);\n return evidence\n ? [\n {\n codec: 'raw',\n evidence,\n destination: correspondence.destination,\n bytes: correspondence.bytes,\n },\n ]\n : [];\n });\n return {\n status: 'complete',\n groupedDocuments: groupedIntents.map((candidate) => candidate.document),\n groupedDocumentKeys: groupedIntents.map((candidate) => candidate.documentKey),\n groupedSources,\n rawDocuments: rawIntents.map((candidate) => candidate.document),\n rawSources,\n attachments,\n ownerInsertions,\n allocations,\n detachedDocumentProofs,\n detachedFileProofs,\n damagePlacements: [...groupedDamage, ...rawDamage],\n };\n}\ntype StableResourceSource = Extract<SourceIdentity, { type: 'resource' }> & {\n resource: { kind: string; id: string };\n};\ntype NullLocationCode = 'orphan' | 'pending-item-node' | 'item-node-path-invalid';\n\nexport type AuthoritativeDamageCause =\n | { type: 'null-location'; code: NullLocationCode }\n | { type: 'dangling-folder'; folderId: string }\n | { type: 'dangling-folder-parent'; parentId: string }\n | { type: 'damaged-share-owner'; owner: GroupOwnerSelector; code?: 'share-owner-damaged' };\n\nexport interface AuthoritativeDamageEvidence {\n documentKey: string;\n source: StableResourceSource;\n canonicalHash: string;\n serverDocumentHash: string;\n locationHash: string;\n cause: AuthoritativeDamageCause;\n}\n\nconst MAX_RESOURCE_ID = 9223372036854775807n;\nconst ID_FREE_RENDERED_KINDS = new Set(['dimension_members', 'user_permissions']);\nconst SHARE_OWNER_KINDS = new Set([\n 'folder',\n 'variable',\n 'dimension_table',\n 'sheet',\n 'dashboard',\n 'file',\n 'remote_job',\n]);\nconst NULL_LOCATION_CODES = new Set<NullLocationCode>(['orphan', 'pending-item-node', 'item-node-path-invalid']);\n\nfunction resourceId(value: unknown): string | undefined {\n return typeof value === 'string' && RESOURCE_ID.test(value) && BigInt(value) <= MAX_RESOURCE_ID ? value : undefined;\n}\n\nfunction resourceFromKey(documentKey: string): StableResourceSource {\n const separator = documentKey.indexOf('/');\n const kind = documentKey.slice(0, separator);\n const id = resourceId(documentKey.slice(separator + 1));\n if (!kind || separator < 1 || !id) throw new Error(`Invalid Head document key: ${documentKey}`);\n return { type: 'resource', resource: { kind, id } };\n}\n\nfunction validateDiagnostic(diagnostic: HeadDiagnostic): void {\n if (\n !diagnostic ||\n typeof diagnostic.kind !== 'string' ||\n diagnostic.kind.length === 0 ||\n !resourceId(diagnostic.id) ||\n typeof diagnostic.code !== 'string' ||\n diagnostic.code.length === 0 ||\n typeof diagnostic.message !== 'string'\n )\n throw new Error('Head has an invalid diagnostic');\n}\n\nfunction validateRenderedIdentity(document: Document, source: StableResourceSource): void {\n if (Object.prototype.hasOwnProperty.call(document, 'key'))\n throw new Error(`Head document has a local key: ${source.resource.kind}/${source.resource.id}`);\n if (ID_FREE_RENDERED_KINDS.has(document.kind)) {\n if (Object.prototype.hasOwnProperty.call(document, 'id'))\n throw new Error(\n `Head document has an unexpected rendered id: ${source.resource.kind}/${source.resource.id}`,\n );\n return;\n }\n if (resourceId(document.id) !== source.resource.id)\n throw new Error(`Head document identity does not match its key: ${source.resource.kind}/${source.resource.id}`);\n}\n\nfunction exactDangling(value: Json): string | undefined {\n const marker = object(value);\n if (!marker || Object.keys(marker).length !== 1) return undefined;\n return resourceId(marker.dangling);\n}\n\nfunction validPath(value: Json): boolean {\n return Array.isArray(value) && value.every((part) => typeof part === 'string');\n}\n\nfunction nullLocationCode(\n diagnostics: readonly HeadDiagnostic[],\n kind: string,\n id: string,\n): NullLocationCode | undefined {\n const codes = [\n ...new Set(\n diagnostics\n .filter((diagnostic) => diagnostic.kind === kind && diagnostic.id === id)\n .map((diagnostic) => diagnostic.code)\n .filter((code): code is NullLocationCode => NULL_LOCATION_CODES.has(code as NullLocationCode)),\n ),\n ];\n if (codes.length > 1) throw new Error(`Head has conflicting placement diagnostics for ${kind}/${id}`);\n return codes[0];\n}\n\nfunction groupedCause(\n document: Document,\n source: StableResourceSource,\n diagnostics: readonly HeadDiagnostic[],\n): AuthoritativeDamageCause | undefined {\n const value = document as JsonObject;\n const folder = value.folder;\n if (folder === null) {\n const code = nullLocationCode(diagnostics, source.resource.kind, source.resource.id);\n return code ? { type: 'null-location', code } : undefined;\n }\n if (validPath(folder)) return undefined;\n const folderId = exactDangling(folder);\n if (folderId) return { type: 'dangling-folder', folderId };\n throw new Error(`Head has an invalid folder location for ${source.resource.kind}/${source.resource.id}`);\n}\n\nfunction folderCause(document: Document, source: StableResourceSource): AuthoritativeDamageCause | undefined {\n const value = document as JsonObject;\n if (validPath(value.path)) return undefined;\n if (value.path !== null)\n throw new Error(`Head has an invalid folder path for ${source.resource.kind}/${source.resource.id}`);\n if (typeof value.name !== 'string')\n throw new Error(`Head has an invalid damaged folder name for ${source.resource.kind}/${source.resource.id}`);\n const parentId = exactDangling(value.parent);\n if (!parentId)\n throw new Error(`Head has an invalid damaged folder parent for ${source.resource.kind}/${source.resource.id}`);\n return { type: 'dangling-folder-parent', parentId };\n}\n\nfunction shareOwner(value: Json): GroupOwnerSelector {\n const owner = object(value);\n if (\n !owner ||\n typeof owner.kind !== 'string' ||\n !SHARE_OWNER_KINDS.has(owner.kind) ||\n Object.keys(owner).length !== 2\n )\n throw new Error('Head has an invalid share owner');\n const id = resourceId(owner.id);\n const dangling = resourceId(owner.dangling);\n if ((id === undefined) === (dangling === undefined)) throw new Error('Head has an invalid share owner');\n return id ? { kind: owner.kind, id } : { kind: owner.kind, dangling: dangling! };\n}\n\nfunction shareCause(\n document: Document,\n source: StableResourceSource,\n diagnostics: readonly HeadDiagnostic[],\n): AuthoritativeDamageCause | undefined {\n const owner = shareOwner(document.owner);\n if ('dangling' in owner) return { type: 'damaged-share-owner', owner };\n const damaged = diagnostics.some(\n (diagnostic) =>\n diagnostic.kind === source.resource.kind &&\n diagnostic.id === source.resource.id &&\n diagnostic.code === 'share-owner-damaged',\n );\n return damaged ? { type: 'damaged-share-owner', owner, code: 'share-owner-damaged' } : undefined;\n}\n\nfunction causeFor(\n document: Document,\n source: StableResourceSource,\n diagnostics: readonly HeadDiagnostic[],\n): AuthoritativeDamageCause | undefined {\n if (document.kind === 'folder') return folderCause(document, source);\n if (document.kind === 'share') return shareCause(document, source, diagnostics);\n if (document.kind === 'file' || GROUPED_FOLDER_KINDS.has(document.kind))\n return groupedCause(document, source, diagnostics);\n return undefined;\n}\n\nfunction locationHash(document: Document): string {\n const value = document as JsonObject;\n if (document.kind === 'file')\n return canonicalFragmentHash({ name: value.name ?? null, folder: value.folder ?? null });\n if (document.kind === 'share') return canonicalFragmentHash({ owner: value.owner ?? null });\n return canonicalFragmentHash({\n name: value.name ?? null,\n folder: value.folder ?? null,\n path: value.path ?? null,\n parent: value.parent ?? null,\n });\n}\n\n/**\n * Extract placement damage from one server Head and the document map that `headDocuments` validated.\n * The caller owns that validation; this function never repeats it.\n */\nexport function extractAuthoritativeDamageEvidence(\n head: Head,\n documents: ReadonlyMap<string, Document>,\n): ReadonlyMap<string, AuthoritativeDamageEvidence> {\n if (!Array.isArray(head.diagnostics)) throw new Error('Head diagnostics are missing');\n head.diagnostics.forEach(validateDiagnostic);\n for (const hash of Object.values(head.manifest))\n if (typeof hash !== 'string' || !SHA256.test(hash)) throw new Error('Head manifest has an invalid hash');\n const evidence = new Map<string, AuthoritativeDamageEvidence>();\n for (const [documentKey, document] of documents) {\n const source = resourceFromKey(documentKey);\n validateRenderedIdentity(document, source);\n const cause = causeFor(document, source, head.diagnostics);\n if (!cause) continue;\n evidence.set(documentKey, {\n documentKey,\n source,\n canonicalHash: head.manifest[documentKey],\n serverDocumentHash: canonicalFragmentHash({ documentKey, document }),\n locationHash: locationHash(document),\n cause,\n });\n }\n return evidence;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaA,wBAmBO;AACP,yBAYO;AAOP,8BAQO;AAoHP,MAAM,aAA+C;AAAA,EACjD,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,SAAS;AAAA,EACT,sBAAsB;AAC1B;AACA,SAAS,mBAAmB,MAA8B,OAAwC;AAC9F,MAAI,KAAK,SAAS,MAAM,KAAM,QAAO;AACrC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