@ybotok/loam 0.0.0 → 0.1.0-beta.1

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 (106) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/COMPARISON.md +63 -0
  3. package/LICENSE +21 -0
  4. package/MIGRATING-from-OpenSpec.md +202 -0
  5. package/README.md +241 -9
  6. package/SCHEMA.md +425 -0
  7. package/SECURITY.md +9 -0
  8. package/dist/cli.js +138 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/commands/adopt.js +226 -0
  11. package/dist/commands/adopt.js.map +1 -0
  12. package/dist/commands/archive.js +1297 -0
  13. package/dist/commands/archive.js.map +1 -0
  14. package/dist/commands/delta.js +361 -0
  15. package/dist/commands/delta.js.map +1 -0
  16. package/dist/commands/dependencies.js +78 -0
  17. package/dist/commands/dependencies.js.map +1 -0
  18. package/dist/commands/doctor.js +85 -0
  19. package/dist/commands/doctor.js.map +1 -0
  20. package/dist/commands/gherkin.js +270 -0
  21. package/dist/commands/gherkin.js.map +1 -0
  22. package/dist/commands/init.js +250 -0
  23. package/dist/commands/init.js.map +1 -0
  24. package/dist/commands/list.js +361 -0
  25. package/dist/commands/list.js.map +1 -0
  26. package/dist/commands/migrate-openspec.js +933 -0
  27. package/dist/commands/migrate-openspec.js.map +1 -0
  28. package/dist/commands/new.js +412 -0
  29. package/dist/commands/new.js.map +1 -0
  30. package/dist/commands/rebase.js +358 -0
  31. package/dist/commands/rebase.js.map +1 -0
  32. package/dist/commands/show.js +325 -0
  33. package/dist/commands/show.js.map +1 -0
  34. package/dist/commands/status.js +270 -0
  35. package/dist/commands/status.js.map +1 -0
  36. package/dist/commands/unarchive.js +310 -0
  37. package/dist/commands/unarchive.js.map +1 -0
  38. package/dist/commands/validate.js +1609 -0
  39. package/dist/commands/validate.js.map +1 -0
  40. package/dist/commands/verify.js +759 -0
  41. package/dist/commands/verify.js.map +1 -0
  42. package/dist/commands/vouch.js +325 -0
  43. package/dist/commands/vouch.js.map +1 -0
  44. package/dist/core/agent.js +1823 -0
  45. package/dist/core/agent.js.map +1 -0
  46. package/dist/core/agents-stamp.js +68 -0
  47. package/dist/core/agents-stamp.js.map +1 -0
  48. package/dist/core/arch.js +104 -0
  49. package/dist/core/arch.js.map +1 -0
  50. package/dist/core/brief.js +733 -0
  51. package/dist/core/brief.js.map +1 -0
  52. package/dist/core/coherence.js +553 -0
  53. package/dist/core/coherence.js.map +1 -0
  54. package/dist/core/config.js +172 -0
  55. package/dist/core/config.js.map +1 -0
  56. package/dist/core/delta.js +457 -0
  57. package/dist/core/delta.js.map +1 -0
  58. package/dist/core/dependencies.js +352 -0
  59. package/dist/core/dependencies.js.map +1 -0
  60. package/dist/core/docs.js +143 -0
  61. package/dist/core/docs.js.map +1 -0
  62. package/dist/core/doctor.js +544 -0
  63. package/dist/core/doctor.js.map +1 -0
  64. package/dist/core/fleet-context.js +272 -0
  65. package/dist/core/fleet-context.js.map +1 -0
  66. package/dist/core/frontmatter.js +203 -0
  67. package/dist/core/frontmatter.js.map +1 -0
  68. package/dist/core/gherkin.js +521 -0
  69. package/dist/core/gherkin.js.map +1 -0
  70. package/dist/core/health.js +71 -0
  71. package/dist/core/health.js.map +1 -0
  72. package/dist/core/ids.js +93 -0
  73. package/dist/core/ids.js.map +1 -0
  74. package/dist/core/issue.js +9 -0
  75. package/dist/core/issue.js.map +1 -0
  76. package/dist/core/json.js +67 -0
  77. package/dist/core/json.js.map +1 -0
  78. package/dist/core/likec4.js +474 -0
  79. package/dist/core/likec4.js.map +1 -0
  80. package/dist/core/openapi-merge.js +519 -0
  81. package/dist/core/openapi-merge.js.map +1 -0
  82. package/dist/core/openapi.js +243 -0
  83. package/dist/core/openapi.js.map +1 -0
  84. package/dist/core/openspec-inventory.js +1403 -0
  85. package/dist/core/openspec-inventory.js.map +1 -0
  86. package/dist/core/path-safety.js +109 -0
  87. package/dist/core/path-safety.js.map +1 -0
  88. package/dist/core/provenance.js +695 -0
  89. package/dist/core/provenance.js.map +1 -0
  90. package/dist/core/repo.js +362 -0
  91. package/dist/core/repo.js.map +1 -0
  92. package/dist/core/report.js +38 -0
  93. package/dist/core/report.js.map +1 -0
  94. package/dist/core/results.js +201 -0
  95. package/dist/core/results.js.map +1 -0
  96. package/dist/core/spec.js +481 -0
  97. package/dist/core/spec.js.map +1 -0
  98. package/dist/core/staging.js +783 -0
  99. package/dist/core/staging.js.map +1 -0
  100. package/dist/core/status.js +1015 -0
  101. package/dist/core/status.js.map +1 -0
  102. package/dist/core/verify.js +793 -0
  103. package/dist/core/verify.js.map +1 -0
  104. package/dist/core/version.js +8 -0
  105. package/dist/core/version.js.map +1 -0
  106. package/package.json +63 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openspec-inventory.js","sourceRoot":"","sources":["../../src/core/openspec-inventory.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxF,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,wFAAwF;AACxF,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC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Ac,EAAE,KAAK;SACtB;QACD,MAAM,EAAE,EAAE,GAAG,YAAY,EAAE,YAAY,EAAE;QACzC,OAAO,EAAE;YACP,MAAM;YACN,QAAQ;YACR,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE;SAC7D;QACD,OAAO;QACP,WAAW,EAAE,QAAQ;QACrB,kBAAkB;QAClB,gBAAgB;QAChB,YAAY;QACZ,eAAe;QACf,kBAAkB;QAClB,aAAa;QACb,SAAS;QACT,iBAAiB;QACjB,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["/** Read-only OpenSpec workspace inventory shared by audit and migration planning. */\nimport { createHash } from \"node:crypto\";\nimport { isUtf8 } from \"node:buffer\";\nimport { existsSync } from \"node:fs\";\nimport { lstat, readFile, readdir, realpath, stat } from \"node:fs/promises\";\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport { compareIds } from \"./repo.js\";\nimport {\n isRequirementsHeading,\n parseRequirements,\n REQUIREMENT_ID_RE,\n requirementIdDeclarations,\n requirementIdProblems,\n sectionHeadings,\n} from \"./spec.js\";\n\n/** Released behavior and the newer upstream snapshot used as a compatibility canary. */\nexport const OPENSPEC_BASELINES = Object.freeze({\n release: Object.freeze({\n version: \"1.7.0\",\n ref: \"v1.7.0\",\n commit: \"4e16790d90d8f54d4773ad9a5e71a57cd9f1e86b\",\n }),\n mainCanary: Object.freeze({\n ref: \"main\",\n commit: \"45cca5db6137ed209117cc70510eb3e057fb981b\",\n }),\n});\n\nexport interface OpenSpecCounts {\n specFiles: number;\n requirements: number;\n scenarios: number;\n}\n\nexport interface OpenSpecCapability extends OpenSpecCounts {\n /** Nested capability ids retain their complete relative directory, e.g. payments/refunds. */\n id: string;\n files: string[];\n}\n\nexport interface OpenSpecChangeMetadata {\n path: string | null;\n schema: string | null;\n skipSpecs: boolean;\n created: string | null;\n fields: string[];\n}\n\nexport interface OpenSpecChangeSpec extends OpenSpecCounts {\n capability: string;\n path: string;\n requirementNames: string[];\n}\n\nexport interface OpenSpecChange extends OpenSpecCounts {\n id: string;\n files: string[];\n specs: OpenSpecChangeSpec[];\n artifacts: string[];\n metadata: OpenSpecChangeMetadata;\n}\n\nexport type OpenSpecIssueScope = \"workspace\" | \"living\" | \"active\" | \"archive\";\n\nexport interface OpenSpecRenamedUsage {\n /** Stable key used by the mapping file. */\n key: string;\n path: string;\n line: number;\n scope: \"active\" | \"archive\";\n changeId: string;\n capability: string;\n from: string | null;\n to: string | null;\n existingRequirementId: string | null;\n requirementId: string | null;\n status: \"needsIdentity\" | \"mapped\";\n}\n\nexport interface OpenSpecUnsupportedShape {\n code: string;\n path: string;\n message: string;\n scope: OpenSpecIssueScope;\n}\n\nexport interface CapabilityMappingDecision {\n capability: string;\n /** Backward-compatible convenience for consumers that only understand one owner. */\n service: string | null;\n /** One capability may need to be split across multiple loam services. */\n services: string[];\n /** Required only when a capability is split across more than one service. */\n requirementServices: Record<string, string[]>;\n suggestedService: string;\n hasLivingSpec: boolean;\n activeChanges: string[];\n status: \"needsMapping\" | \"mapped\";\n}\n\nexport interface OpenSpecCapabilityMapping {\n services: string[];\n requirementServices: Record<string, string[]>;\n}\n\nexport interface OpenSpecChangeMapping {\n feature: string | null;\n title: string;\n}\n\nexport interface OpenSpecChangeDecision {\n change: string;\n feature: string | null;\n title: string;\n suggestedFeature: string;\n suggestedTitle: string;\n status: \"needsFeature\" | \"mapped\";\n}\n\nexport interface OpenSpecMapping {\n source: { root: string; inventoryDigest: string } | null;\n capabilities: Record<string, OpenSpecCapabilityMapping>;\n changes: Record<string, OpenSpecChangeMapping>;\n renames: Record<string, string>;\n artifacts: Record<string, OpenSpecArtifactDisposition>;\n}\n\nexport interface OpenSpecMappingIssue {\n code:\n | \"mapping.source-missing\"\n | \"mapping.source-root-mismatch\"\n | \"mapping.source-digest-mismatch\"\n | \"mapping.unknown-capability\"\n | \"mapping.unknown-requirement\"\n | \"mapping.requirement-allocation-missing\"\n | \"mapping.requirement-service-unknown\"\n | \"mapping.service-allocation-empty\"\n | \"mapping.unknown-change\"\n | \"mapping.change-title-missing\"\n | \"mapping.feature-id-invalid\"\n | \"mapping.feature-id-duplicate\"\n | \"mapping.unknown-rename\"\n | \"mapping.invalid-requirement-id\"\n | \"mapping.rename-source-missing\"\n | \"mapping.rename-source-ambiguous\"\n | \"mapping.rename-source-id-invalid\"\n | \"mapping.rename-target-conflict\"\n | \"mapping.rename-existing-id-conflict\"\n | \"mapping.rename-id-conflict\"\n | \"mapping.rename-double-source\"\n | \"mapping.rename-double-target\"\n | \"mapping.rename-chain\"\n | \"mapping.unknown-artifact\"\n | \"mapping.invalid-artifact-disposition\";\n key: string;\n message: string;\n}\n\nexport type OpenSpecArtifactScope = \"workspace\" | \"living\" | \"active\" | \"archive\";\nexport type OpenSpecArtifactKind =\n | \"config\"\n | \"store-metadata\"\n | \"project-context\"\n | \"agent-instructions\"\n | \"living-spec\"\n | \"living-design\"\n | \"change-metadata\"\n | \"proposal\"\n | \"tasks\"\n | \"change-design\"\n | \"delta-spec\"\n | \"custom-schema\"\n | \"schema-template\"\n | \"other\";\nexport type OpenSpecArtifactDisposition =\n | \"translate-project-context\"\n | \"record-external-planning-root\"\n | \"remove-after-cutover\"\n | \"map-requirements\"\n | \"review-as-service-adr\"\n | \"translate-change-metadata\"\n | \"convert-to-intent\"\n | \"preserve-as-legacy-checklist\"\n | \"review-as-feature-adr\"\n | \"map-delta\"\n | \"review-custom-workflow\"\n | \"retain-read-only\"\n | \"manual-review\";\n\nexport interface OpenSpecArtifact {\n /** Workspace-relative, so store metadata outside openspec/ remains representable. */\n path: string;\n scope: OpenSpecArtifactScope;\n kind: OpenSpecArtifactKind;\n disposition: OpenSpecArtifactDisposition;\n changeId?: string;\n capability?: string;\n}\n\nexport interface OpenSpecArtifactDecision {\n path: string;\n kind: \"proposal\" | \"tasks\" | \"change-design\";\n suggestedDisposition: OpenSpecArtifactDisposition;\n disposition: OpenSpecArtifactDisposition | null;\n status: \"needsDisposition\" | \"mapped\";\n}\n\nexport interface OpenSpecConfigSummary {\n path: string;\n schema: string | null;\n store: string | null;\n hasContext: boolean;\n ruleArtifacts: string[];\n references: string[];\n}\n\nexport interface OpenSpecInventory {\n baselines: typeof OPENSPEC_BASELINES;\n inputRoot: string;\n root: string;\n /** SHA-256 over every inventoried OpenSpec source path and byte sequence. */\n inventoryDigest: string;\n workspace: {\n kind: \"project\" | \"store\" | \"openspec-root\";\n config: OpenSpecConfigSummary | null;\n storeMetadataPath: string | null;\n };\n ready: boolean;\n mechanicallyCompatible: boolean;\n readiness: {\n living: { compatible: boolean; issueCount: number };\n active: { compatible: boolean; issueCount: number };\n sourceCurrent: boolean;\n mappingsResolved: boolean;\n changesResolved: boolean;\n renamesResolved: boolean;\n dispositionsResolved: boolean;\n migrationReady: boolean;\n };\n living: OpenSpecCounts & { capabilities: OpenSpecCapability[] };\n changes: {\n active: OpenSpecChange[];\n archived: OpenSpecChange[];\n counts: { active: number; archived: number };\n };\n renamed: OpenSpecRenamedUsage[];\n /** Living/active blockers only. Frozen archive history never blocks migration readiness. */\n unsupported: OpenSpecUnsupportedShape[];\n /** Historical anomalies are retained for review, but are not migration blockers. */\n archiveDiagnostics: OpenSpecUnsupportedShape[];\n mappingDecisions: CapabilityMappingDecision[];\n needsMapping: CapabilityMappingDecision[];\n changeDecisions: OpenSpecChangeDecision[];\n needsChangeMapping: OpenSpecChangeDecision[];\n mappingIssues: OpenSpecMappingIssue[];\n artifacts: OpenSpecArtifact[];\n artifactDecisions: OpenSpecArtifactDecision[];\n needsDisposition: OpenSpecArtifactDecision[];\n}\n\nexport interface OpenSpecMappingSkeleton {\n version: 1;\n source: { root: string; inventoryDigest: string };\n capabilities: Record<string, {\n services: string[];\n suggestedServices: string[];\n requirementServices: Record<string, string[]>;\n }>;\n changes: Record<string, {\n feature: null;\n suggestedFeature: string;\n title: string;\n }>;\n renames: Record<string, {\n from: string | null;\n to: string | null;\n existingRequirementId: string | null;\n requirementId: string | null;\n }>;\n artifacts: Record<string, {\n kind: \"proposal\" | \"tasks\" | \"change-design\";\n disposition: null;\n suggestedDisposition: OpenSpecArtifactDisposition;\n }>;\n}\n\nexport class OpenSpecRootError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"OpenSpecRootError\";\n }\n}\n\nasync function isDirectory(path: string): Promise<boolean> {\n try {\n return (await stat(path)).isDirectory();\n } catch {\n return false;\n }\n}\n\nasync function looksLikeOpenSpec(path: string): Promise<boolean> {\n return existsSync(join(path, \"config.yaml\"))\n || existsSync(join(path, \"project.md\"))\n || existsSync(join(path, \".openspec.yaml\"))\n || await isDirectory(join(path, \"specs\"))\n || await isDirectory(join(path, \"changes\"));\n}\n\nasync function locateOpenSpecRoot(\n input: string,\n): Promise<{ inputRoot: string; root: string; kind: \"project\" | \"store\" | \"openspec-root\" }> {\n const requestedRoot = resolve(input);\n if (!await isDirectory(requestedRoot)) {\n throw new OpenSpecRootError(`OpenSpec root is missing or is not a directory: ${requestedRoot}`);\n }\n const inputRoot = await realpath(requestedRoot);\n const nested = join(inputRoot, \"openspec\");\n const storeMarker = join(inputRoot, \".openspec-store\", \"store.yaml\");\n const hasNestedShape = await looksLikeOpenSpec(nested);\n const hasDirectShape = await looksLikeOpenSpec(inputRoot);\n if (hasNestedShape && hasDirectShape) {\n throw new OpenSpecRootError(\n `Ambiguous OpenSpec root ${inputRoot}: both the directory itself and ${nested} contain OpenSpec planning shapes. Pass the intended root explicitly.`,\n );\n }\n if (hasNestedShape) {\n await assertPlanningRootNotLinked(nested);\n return { inputRoot, root: nested, kind: existsSync(storeMarker) ? \"store\" : \"project\" };\n }\n // The shape decides the root, the Store marker only decides the kind. Deciding\n // \"store\" first sent `root` to <store>/openspec for a checkout that keeps its\n // planning shape at the checkout root: a directory that does not exist reads\n // as an empty, fully compatible workspace, and apply then stages nothing.\n if (hasDirectShape) {\n const parentStoreMarker = basename(inputRoot) === \"openspec\"\n ? join(dirname(inputRoot), \".openspec-store\", \"store.yaml\")\n : \"\";\n const store = existsSync(storeMarker) || (parentStoreMarker !== \"\" && existsSync(parentStoreMarker));\n return { inputRoot, root: inputRoot, kind: store ? \"store\" : \"openspec-root\" };\n }\n // OpenSpec stores may omit empty planning directories. Keep their canonical\n // future root at <store>/openspec so paths do not change after the first spec\n // — but only when that directory is really there. Auditing a root that does\n // not exist is how a Store checkout came back `ready` over invisible content.\n if (existsSync(storeMarker)) {\n await assertPlanningRootNotLinked(nested);\n if (!await isDirectory(nested)) {\n throw new OpenSpecRootError(\n `Store checkout ${inputRoot} has no OpenSpec planning content: neither ${nested} nor config.yaml, project.md, specs/ or changes/ at the checkout root.`,\n );\n }\n return { inputRoot, root: nested, kind: \"store\" };\n }\n throw new OpenSpecRootError(\n `No OpenSpec workspace found at ${inputRoot} (expected openspec/config.yaml, specs/, changes/, project.md, or .openspec-store/store.yaml).`,\n );\n}\n\nasync function assertPlanningRootNotLinked(path: string): Promise<void> {\n if (await isSymbolicLink(path)) {\n throw new OpenSpecRootError(\n `OpenSpec planning root must not be a symbolic link: ${path}. Pass the canonical planning directory explicitly.`,\n );\n }\n}\n\nfunction portable(root: string, path: string): string {\n return relative(root, path).split(sep).join(\"/\");\n}\n\n/** Stable inventory namespace: planning-root relative, with one explicit external prefix. */\nfunction sourceInventoryPath(root: string, absolute: string): string {\n const rel = relative(root, absolute);\n if (rel === \"\" || (!rel.startsWith(`..${sep}`) && rel !== \"..\" && !isAbsolute(rel))) {\n return rel.split(sep).join(\"/\");\n }\n return `@workspace/${portable(dirname(root), absolute)}`;\n}\n\nasync function subdirs(path: string): Promise<string[]> {\n if (!await isDirectory(path)) return [];\n return (await readdir(path, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory() && !entry.name.startsWith(\".\"))\n .map((entry) => entry.name)\n .sort(compareIds);\n}\n\n/**\n * Exactly what `subdirs` drops. walkFiles does not drop it, so a change behind a\n * dot-directory was never enumerated as a change while its files were still\n * classified, counted and given a disposition slot — a decision recorded as\n * selected for an artifact nothing migrates.\n */\nasync function hiddenSubdirs(path: string): Promise<string[]> {\n if (!await isDirectory(path)) return [];\n return (await readdir(path, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory() && entry.name.startsWith(\".\"))\n .map((entry) => entry.name)\n .sort(compareIds);\n}\n\nasync function walkFiles(path: string): Promise<string[]> {\n if (!await isDirectory(path)) return [];\n const files: string[] = [];\n const walk = async (dir: string): Promise<void> => {\n const entries = (await readdir(dir, { withFileTypes: true }))\n .filter((entry) => entry.name !== \".git\")\n .sort((a, b) => compareIds(a.name, b.name));\n for (const entry of entries) {\n const absolute = join(dir, entry.name);\n if (entry.isDirectory()) await walk(absolute);\n else if (entry.isFile()) files.push(absolute);\n }\n };\n await walk(path);\n return files;\n}\n\n/** Inventory symbolic links without following them into unbound source trees. */\nasync function walkSymlinks(path: string): Promise<string[]> {\n if (!await isDirectory(path)) return [];\n const links: string[] = [];\n const walk = async (dir: string): Promise<void> => {\n const entries = (await readdir(dir, { withFileTypes: true }))\n .filter((entry) => entry.name !== \".git\")\n .sort((a, b) => compareIds(a.name, b.name));\n for (const entry of entries) {\n const absolute = join(dir, entry.name);\n if (entry.isSymbolicLink()) links.push(absolute);\n else if (entry.isDirectory()) await walk(absolute);\n }\n };\n await walk(path);\n return links;\n}\n\nasync function isSymbolicLink(path: string): Promise<boolean> {\n try {\n return (await lstat(path)).isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? value as Record<string, unknown>\n : null;\n}\n\nfunction dictionary<T>(): Record<string, T> {\n return Object.create(null) as Record<string, T>;\n}\n\nfunction ownValue<T>(record: Record<string, T>, key: string): T | undefined {\n return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : undefined;\n}\n\nasync function yamlRecord(path: string): Promise<Record<string, unknown>> {\n const parsed: unknown = parseYaml(await readFile(path, \"utf8\"));\n const record = asRecord(parsed);\n if (record === null) throw new Error(\"expected a YAML mapping\");\n return record;\n}\n\nfunction countsFor(requirements: ReturnType<typeof parseRequirements>): Omit<OpenSpecCounts, \"specFiles\"> {\n return {\n requirements: requirements.length,\n scenarios: requirements.reduce((sum, requirement) => sum + requirement.scenarios.length, 0),\n };\n}\n\nfunction addCounts(target: OpenSpecCounts, source: OpenSpecCounts): void {\n target.specFiles += source.specFiles;\n target.requirements += source.requirements;\n target.scenarios += source.scenarios;\n}\n\nfunction cleanRenameName(value: string): string {\n return value\n .trim()\n .replace(/^`|`$/g, \"\")\n .replace(/^###\\s+Requirement:\\s*/i, \"\")\n .trim();\n}\n\nfunction changeSpecCoordinates(\n path: string,\n scope: \"active\" | \"archive\",\n): { changeId: string; capability: string } {\n const prefix = scope === \"active\" ? /^changes\\/([^/]+)\\/specs\\/(.+)\\/spec\\.md$/ : /^changes\\/archive\\/([^/]+)\\/specs\\/(.+)\\/spec\\.md$/;\n const match = prefix.exec(path);\n return { changeId: match?.[1] ?? \"\", capability: match?.[2] ?? \"\" };\n}\n\n/**\n * Which lines are fenced content, marker included \\u2014 the same rule\n * `parseRequirements` and `sectionHeadings` apply, which spec.ts keeps private.\n * Without it a FROM/TO line inside a fenced example of the rename syntax became\n * a phantom pair, and the only cure was editing the OpenSpec source migration\n * promises never to touch.\n */\nfunction fencedLines(lines: string[]): boolean[] {\n let fence: string | null = null;\n return lines.map((line) => {\n const marker = /^\\s*(```|~~~)/.exec(line);\n if (marker === null) return fence !== null;\n if (fence === null) fence = marker[1]!;\n else if (fence === marker[1]!) fence = null;\n return true;\n });\n}\n\nfunction renameUsages(\n path: string,\n raw: string,\n scope: \"active\" | \"archive\",\n mapped: Record<string, string>,\n): OpenSpecRenamedUsage[] {\n const lines = raw.replace(/^\\uFEFF/, \"\").split(/\\r?\\n/);\n const fenced = fencedLines(lines);\n const headings = sectionHeadings(raw);\n const coordinates = changeSpecCoordinates(path, scope);\n const output: OpenSpecRenamedUsage[] = [];\n for (const [headingIndex, heading] of headings.entries()) {\n if (!/^##\\s+RENAMED\\s+Requirements?\\s*:?\\s*$/i.test(heading.text)) continue;\n const end = headings[headingIndex + 1]?.line ?? lines.length + 1;\n const pairs: Array<{ from: string | null; to: string | null }> = [];\n let pendingFrom: string | null = null;\n for (let line = heading.line; line < end - 1; line += 1) {\n if (fenced[line] === true) continue;\n const text = lines[line] ?? \"\";\n const from = /^\\s*-\\s*FROM:\\s*(.*?)\\s*$/i.exec(text);\n if (from !== null) {\n if (pendingFrom !== null) pairs.push({ from: pendingFrom, to: null });\n pendingFrom = cleanRenameName(from[1] ?? \"\");\n continue;\n }\n const to = /^\\s*-\\s*TO:\\s*(.*?)\\s*$/i.exec(text);\n if (to !== null) {\n pairs.push({ from: pendingFrom, to: cleanRenameName(to[1] ?? \"\") });\n pendingFrom = null;\n }\n }\n if (pendingFrom !== null) pairs.push({ from: pendingFrom, to: null });\n if (pairs.length === 0) pairs.push({ from: null, to: null });\n pairs.forEach((pair, pairIndex) => {\n const key = `${path}:${heading.line}:${pairIndex + 1}`;\n const requirementId = ownValue(mapped, key) ?? null;\n output.push({\n key,\n path,\n line: heading.line,\n scope,\n changeId: coordinates.changeId,\n capability: coordinates.capability,\n from: pair.from,\n to: pair.to,\n existingRequirementId: null,\n requirementId,\n status: requirementId === null ? \"needsIdentity\" : \"mapped\",\n });\n });\n }\n return output;\n}\n\nfunction issue(\n target: OpenSpecUnsupportedShape[],\n scope: OpenSpecIssueScope,\n code: string,\n path: string,\n message: string,\n): void {\n target.push({ code, path, message, scope });\n}\n\nfunction inspectLivingShape(\n path: string,\n raw: string,\n unsupported: OpenSpecUnsupportedShape[],\n): void {\n const requirements = parseRequirements(raw);\n if (requirements.length === 0) {\n issue(unsupported, \"living\", \"openspec.living-empty\", path, \"Living spec has no parseable Requirement headings.\");\n return;\n }\n const outside = requirements.filter(\n (requirement) => requirement.section === undefined || !isRequirementsHeading(requirement.section),\n );\n if (outside.length > 0) {\n issue(\n unsupported,\n \"living\",\n \"openspec.living-requirements-outside-section\",\n path,\n `${outside.length} requirement(s) are outside the canonical ## Requirements section.`,\n );\n }\n if (requirements.some((requirement) => requirement.kind !== \"BASE\")) {\n issue(unsupported, \"living\", \"openspec.living-delta-section\", path, \"Living spec contains delta-kind requirements.\");\n }\n}\n\nfunction inspectChangeShape(\n path: string,\n raw: string,\n scope: \"active\" | \"archive\",\n renames: OpenSpecRenamedUsage[],\n unsupported: OpenSpecUnsupportedShape[],\n): void {\n const requirements = parseRequirements(raw);\n const fileRenames = renames.filter((rename) => rename.path === path);\n for (const rename of fileRenames) {\n if (rename.from === null || rename.from === \"\" || rename.to === null || rename.to === \"\") {\n issue(\n unsupported,\n scope,\n \"openspec.renamed-malformed\",\n path,\n `RENAMED Requirements at line ${rename.line} must contain a FROM/TO pair.`,\n );\n }\n }\n if (requirements.length === 0) {\n // A well-formed rename-only delta is meaningful even though the requirement\n // parser correctly returns no requirement blocks for it.\n if (fileRenames.length === 0) {\n issue(unsupported, scope, \"openspec.change-empty\", path, \"Change spec has no parseable Requirement headings.\");\n }\n return;\n }\n // `## Requirements` is the heading OpenSpec's own living-spec template\n // mandates, so this is the shape a team produces by copying a living spec into\n // a change directory. It parses, it is counted, and nothing routes it: only\n // delta-kind requirements reach the staged feature. Blocking is what keeps the\n // per-change counters and what actually lands the same number.\n const quoted = requirements.filter(\n (requirement) => requirement.kind === \"BASE\"\n && requirement.section !== undefined\n && isRequirementsHeading(requirement.section),\n );\n if (quoted.length > 0) {\n unsupported.push({\n code: \"openspec.change-quoted-requirements\",\n path,\n message: `${quoted.length} requirement(s) sit under ## Requirements in a change delta, which stages nothing; re-home them under ADDED, MODIFIED, or REMOVED.`,\n scope,\n });\n }\n const stranded = requirements.filter(\n (requirement) => requirement.kind === \"BASE\"\n && (requirement.section === undefined || !isRequirementsHeading(requirement.section)),\n );\n if (stranded.length === requirements.length) {\n issue(\n unsupported,\n scope,\n \"openspec.change-without-delta-sections\",\n path,\n \"Change requirements are not under ADDED, MODIFIED, REMOVED, or the explicitly non-merging ## Requirements section.\",\n );\n } else if (stranded.length > 0) {\n issue(\n unsupported,\n scope,\n \"openspec.change-requirements-outside-delta-sections\",\n path,\n `${stranded.length} requirement(s) would be stranded outside delta sections.`,\n );\n }\n}\n\nasync function inspectSpecFile(\n root: string,\n absolute: string,\n kind: \"living\" | \"change\",\n scope: \"active\" | \"archive\" | null,\n mapping: OpenSpecMapping,\n renamed: OpenSpecRenamedUsage[],\n unsupported: OpenSpecUnsupportedShape[],\n): Promise<{ path: string; counts: OpenSpecCounts }> {\n const path = portable(root, absolute);\n const raw = await readFile(absolute, \"utf8\");\n const requirements = parseRequirements(raw);\n const counts = { specFiles: 1, ...countsFor(requirements) };\n const issueScope = kind === \"living\" ? \"living\" : scope ?? \"active\";\n for (const problem of requirementIdProblems(requirements)) {\n if (problem.kind === \"invalid\") {\n issue(\n unsupported,\n issueScope,\n \"openspec.requirement-id-invalid\",\n path,\n `Requirement '${problem.requirement}' has invalid Requirement-ID '${problem.value}'; use [A-Za-z][A-Za-z0-9._-]{0,127}.`,\n );\n } else if (problem.kind === \"repeated\") {\n issue(\n unsupported,\n issueScope,\n \"openspec.requirement-id-repeated\",\n path,\n `Requirement '${problem.requirement}' declares Requirement-ID ${problem.values.length} times; keep exactly one identity line.`,\n );\n } else {\n issue(\n unsupported,\n issueScope,\n \"openspec.requirement-id-duplicate\",\n path,\n `Requirement-ID '${problem.id}' is shared by ${problem.requirements.map((name) => `'${name}'`).join(\", \")}.`,\n );\n }\n }\n if (kind === \"living\") {\n inspectLivingShape(path, raw, unsupported);\n } else {\n const changeScope = scope ?? \"active\";\n const usages = renameUsages(path, raw, changeScope, mapping.renames);\n renamed.push(...usages);\n inspectChangeShape(path, raw, changeScope, usages, unsupported);\n }\n return { path, counts };\n}\n\nasync function inspectConfig(\n root: string,\n unsupported: OpenSpecUnsupportedShape[],\n): Promise<OpenSpecConfigSummary | null> {\n const path = join(root, \"config.yaml\");\n if (!existsSync(path)) return null;\n if (await isSymbolicLink(path)) return null;\n try {\n const config = await yamlRecord(path);\n const rules = asRecord(config.rules);\n return {\n path: \"config.yaml\",\n schema: typeof config.schema === \"string\" ? config.schema : null,\n store: typeof config.store === \"string\" ? config.store : null,\n hasContext: typeof config.context === \"string\" && config.context.trim() !== \"\",\n ruleArtifacts: rules === null ? [] : Object.keys(rules).sort(compareIds),\n references: Array.isArray(config.references)\n ? config.references.filter((item): item is string => typeof item === \"string\").sort(compareIds)\n : [],\n };\n } catch (error) {\n issue(\n unsupported,\n \"workspace\",\n \"openspec.config-invalid\",\n \"config.yaml\",\n `OpenSpec config.yaml is invalid: ${error instanceof Error ? error.message : String(error)}`,\n );\n return {\n path: \"config.yaml\",\n schema: null,\n store: null,\n hasContext: false,\n ruleArtifacts: [],\n references: [],\n };\n }\n}\n\n/**\n * A calendar date, optionally with a time. OpenSpec's template writes the plain\n * date, but a timestamp is still a date — and rejecting it blocked every change\n * and every capability in the workspace over one field nobody reads, fixable\n * only by editing the source migration promises not to touch.\n */\nconst CHANGE_CREATED_RE = /^\\d{4}-\\d{2}-\\d{2}(?:[T ]\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d+)?)?(?:Z|[+-]\\d{2}:?\\d{2})?)?$/;\n\nasync function inspectChangeMetadata(\n root: string,\n dir: string,\n scope: \"active\" | \"archive\",\n fallbackSchema: string | null,\n unsupported: OpenSpecUnsupportedShape[],\n): Promise<OpenSpecChangeMetadata> {\n const absolute = join(dir, \".openspec.yaml\");\n if (!existsSync(absolute)) {\n return { path: null, schema: fallbackSchema, skipSpecs: false, created: null, fields: [] };\n }\n const path = portable(root, absolute);\n if (await isSymbolicLink(absolute)) {\n return { path, schema: fallbackSchema, skipSpecs: false, created: null, fields: [] };\n }\n try {\n const metadata = await yamlRecord(absolute);\n let valid = true;\n const invalid = (message: string): void => {\n valid = false;\n issue(unsupported, scope, \"openspec.change-metadata-invalid\", path, message);\n };\n const schema = typeof metadata.schema === \"string\" && metadata.schema.trim() !== \"\"\n ? metadata.schema.trim()\n : null;\n if (schema === null) {\n invalid(\n \"Present .openspec.yaml metadata requires a non-empty string schema; fallback applies only when the file is absent.\",\n );\n }\n if (\"skip_specs\" in metadata && typeof metadata.skip_specs !== \"boolean\") {\n invalid(\"skip_specs must be a boolean when present.\");\n }\n if (\"created\" in metadata\n && (typeof metadata.created !== \"string\" || !CHANGE_CREATED_RE.test(metadata.created))) {\n invalid(\"created must be a string date in YYYY-MM-DD or ISO-8601 date-time form when present.\");\n }\n if (\"goal\" in metadata && (typeof metadata.goal !== \"string\" || metadata.goal.length === 0)) {\n invalid(\"goal must be a non-empty string when present.\");\n }\n if (\"affected_areas\" in metadata\n && (!Array.isArray(metadata.affected_areas)\n || metadata.affected_areas.some((value) => typeof value !== \"string\" || value.length === 0))) {\n invalid(\"affected_areas must be an array of non-empty strings when present.\");\n }\n if (\"initiative\" in metadata) {\n const initiative = asRecord(metadata.initiative);\n const keys = initiative === null ? [] : Object.keys(initiative).sort(compareIds);\n const kebabId = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;\n if (initiative === null\n || keys.length !== 2\n || keys[0] !== \"id\"\n || keys[1] !== \"store\"\n || typeof initiative.id !== \"string\"\n || !kebabId.test(initiative.id)\n || typeof initiative.store !== \"string\"\n || !kebabId.test(initiative.store)) {\n invalid(\"initiative must be exactly { store, id }, with both values portable kebab-case identifiers.\");\n }\n }\n return {\n path,\n schema,\n skipSpecs: valid && schema !== null && metadata.skip_specs === true,\n created: typeof metadata.created === \"string\" && CHANGE_CREATED_RE.test(metadata.created)\n ? metadata.created\n : null,\n fields: Object.keys(metadata).sort(compareIds),\n };\n } catch (error) {\n issue(\n unsupported,\n scope,\n \"openspec.change-metadata-invalid\",\n path,\n `Change metadata is invalid: ${error instanceof Error ? error.message : String(error)}`,\n );\n return { path, schema: fallbackSchema, skipSpecs: false, created: null, fields: [] };\n }\n}\n\nfunction isContainedPath(parent: string, candidate: string): boolean {\n const rel = relative(parent, candidate);\n return rel === \"\" || (!rel.startsWith(`..${sep}`) && rel !== \"..\" && !isAbsolute(rel));\n}\n\n/**\n * Resolve only a schema that OpenSpec could enumerate as one direct, portable\n * member of this workspace's schemas/ directory. Constructing a path from the\n * metadata value first would let `../` (or a platform-specific separator) read\n * bytes outside the inventoried tree and then authorize `skip_specs` with them.\n */\nasync function registeredProjectSchemaPath(\n root: string,\n schema: string,\n): Promise<{ registered: boolean; path: string | null }> {\n const windowsStem = schema.split(\".\")[0]!.toUpperCase();\n const windowsReserved = /^(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/.test(windowsStem);\n if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(schema)\n || schema === \".\"\n || schema === \"..\"\n || schema.endsWith(\".\")\n || windowsReserved) {\n return { registered: false, path: null };\n }\n\n const schemasRoot = join(root, \"schemas\");\n try {\n const schemasStat = await lstat(schemasRoot);\n if (!schemasStat.isDirectory() || schemasStat.isSymbolicLink()) return { registered: false, path: null };\n const entries = await readdir(schemasRoot, { withFileTypes: true });\n const registered = entries.find((entry) => entry.name === schema);\n if (registered === undefined) return { registered: false, path: null };\n if (!registered.isDirectory() || registered.isSymbolicLink()) return { registered: true, path: null };\n\n const schemaDir = join(schemasRoot, registered.name);\n const schemaFile = join(schemaDir, \"schema.yaml\");\n const [schemaDirStat, schemaFileStat] = await Promise.all([lstat(schemaDir), lstat(schemaFile)]);\n if (!schemaDirStat.isDirectory() || schemaDirStat.isSymbolicLink()\n || !schemaFileStat.isFile() || schemaFileStat.isSymbolicLink()) {\n return { registered: true, path: null };\n }\n\n const [canonicalRoot, canonicalSchemasRoot, canonicalSchemaDir, canonicalSchemaFile] = await Promise.all([\n realpath(root),\n realpath(schemasRoot),\n realpath(schemaDir),\n realpath(schemaFile),\n ]);\n if (!isContainedPath(canonicalRoot, canonicalSchemasRoot)\n || !isContainedPath(canonicalSchemasRoot, canonicalSchemaDir)\n || !isContainedPath(canonicalSchemaDir, canonicalSchemaFile)) {\n return { registered: true, path: null };\n }\n return { registered: true, path: schemaFile };\n } catch {\n return { registered: false, path: null };\n }\n}\n\nfunction validArtifactSchema(document: Record<string, unknown>): boolean {\n if (typeof document.name !== \"string\" || document.name.length === 0\n || typeof document.version !== \"number\"\n || !Number.isInteger(document.version)\n || document.version <= 0\n || (\"description\" in document && typeof document.description !== \"string\")\n || !Array.isArray(document.artifacts)\n || document.artifacts.length === 0) {\n return false;\n }\n\n const artifacts: Array<{ id: string; requires: string[] }> = [];\n for (const value of document.artifacts) {\n const artifact = asRecord(value);\n if (artifact === null\n || typeof artifact.id !== \"string\"\n || artifact.id.length === 0\n || typeof artifact.generates !== \"string\"\n || artifact.generates.length === 0\n || typeof artifact.description !== \"string\"\n || typeof artifact.template !== \"string\"\n || artifact.template.length === 0\n || (\"instruction\" in artifact && typeof artifact.instruction !== \"string\")\n || (\"requires\" in artifact\n && (!Array.isArray(artifact.requires)\n || artifact.requires.some((dependency) => typeof dependency !== \"string\")))) {\n return false;\n }\n artifacts.push({\n id: artifact.id,\n requires: Array.isArray(artifact.requires) ? artifact.requires as string[] : [],\n });\n }\n\n if (\"apply\" in document) {\n const apply = asRecord(document.apply);\n if (apply === null\n || !Array.isArray(apply.requires)\n || apply.requires.length === 0\n || apply.requires.some((dependency) => typeof dependency !== \"string\")\n || (\"tracks\" in apply && apply.tracks !== null && typeof apply.tracks !== \"string\")\n || (\"instruction\" in apply && typeof apply.instruction !== \"string\")) {\n return false;\n }\n }\n\n const ids = new Set<string>();\n for (const artifact of artifacts) {\n if (ids.has(artifact.id)) return false;\n ids.add(artifact.id);\n }\n if (artifacts.some((artifact) => artifact.requires.some((dependency) => !ids.has(dependency)))) return false;\n\n const byId = new Map(artifacts.map((artifact) => [artifact.id, artifact]));\n const complete = new Set<string>();\n const visiting = new Set<string>();\n const visit = (id: string): boolean => {\n if (complete.has(id)) return true;\n if (visiting.has(id)) return false;\n visiting.add(id);\n for (const dependency of byId.get(id)?.requires ?? []) {\n if (!visit(dependency)) return false;\n }\n visiting.delete(id);\n complete.add(id);\n return true;\n };\n return artifacts.every((artifact) => visit(artifact.id));\n}\n\nasync function schemaSpecPolicy(\n root: string,\n schema: string | null,\n): Promise<{ resolved: boolean }> {\n if (schema === null) return { resolved: false };\n const projectSchema = await registeredProjectSchemaPath(root, schema);\n // A project-local entry shadows the known built-in, but migration refuses\n // unsafe/symlinked entries instead of following them outside the inventory.\n if (!projectSchema.registered) return { resolved: schema === \"spec-driven\" };\n if (projectSchema.path === null) return { resolved: false };\n try {\n const document = await yamlRecord(projectSchema.path);\n return { resolved: validArtifactSchema(document) };\n } catch {\n return { resolved: false };\n }\n}\n\nasync function inventoryChanges(\n root: string,\n base: string,\n ids: string[],\n scope: \"active\" | \"archive\",\n fallbackSchema: string | null,\n mapping: OpenSpecMapping,\n renamed: OpenSpecRenamedUsage[],\n unsupported: OpenSpecUnsupportedShape[],\n): Promise<OpenSpecChange[]> {\n const changes: OpenSpecChange[] = [];\n for (const id of ids) {\n const dir = join(base, id);\n const allArtifacts = await walkFiles(dir);\n const specRoot = join(dir, \"specs\");\n const allSpecs = await walkFiles(specRoot);\n const specFiles = allSpecs.filter((path) => basename(path) === \"spec.md\");\n const metadata = await inspectChangeMetadata(root, dir, scope, fallbackSchema, unsupported);\n const counts: OpenSpecCounts = { specFiles: 0, requirements: 0, scenarios: 0 };\n const files: string[] = [];\n const specs: OpenSpecChangeSpec[] = [];\n for (const specFile of specFiles) {\n const inspected = await inspectSpecFile(root, specFile, \"change\", scope, mapping, renamed, unsupported);\n files.push(inspected.path);\n const parsed = parseRequirements(await readFile(specFile, \"utf8\"));\n specs.push({\n capability: portable(specRoot, dirname(specFile)),\n path: inspected.path,\n requirementNames: [...new Set(parsed.filter((item) => item.kind !== \"BASE\").map((item) => item.name))].sort(compareIds),\n ...inspected.counts,\n });\n addCounts(counts, inspected.counts);\n }\n const schemaPolicy = await schemaSpecPolicy(root, metadata.schema);\n if (!schemaPolicy.resolved) {\n issue(\n unsupported,\n scope,\n \"openspec.change-schema-unresolved\",\n metadata.path ?? portable(root, dir),\n `Change schema '${metadata.schema ?? \"<missing>\"}' cannot be resolved to a readable built-in or project schema.`,\n );\n }\n if (metadata.skipSpecs && allSpecs.length > 0) {\n issue(\n unsupported,\n scope,\n \"openspec.skip-specs-with-specs\",\n portable(root, specRoot),\n \"skip_specs: true conflicts with authored content under specs/; remove the marker or review and remove the spec tree.\",\n );\n }\n const permitsNoSpecs = schemaPolicy.resolved && metadata.skipSpecs;\n if (specFiles.length === 0 && schemaPolicy.resolved && !permitsNoSpecs) {\n issue(\n unsupported,\n scope,\n \"openspec.change-no-specs\",\n portable(root, dir),\n \"Change has no specs/<capability>/spec.md files and does not opt out with a valid, schema-resolved skip_specs: true marker.\",\n );\n }\n for (const file of allSpecs.filter((path) => path.endsWith(\".md\") && basename(path) !== \"spec.md\")) {\n issue(\n unsupported,\n scope,\n \"openspec.nonstandard-change-spec\",\n portable(root, file),\n \"Markdown under a change specs/ tree is not named spec.md.\",\n );\n }\n changes.push({\n id,\n files,\n specs: specs.sort((a, b) => compareIds(a.capability, b.capability)),\n artifacts: allArtifacts.map((path) => portable(root, path)),\n metadata,\n ...counts,\n });\n }\n return changes;\n}\n\nfunction artifactScope(path: string): OpenSpecArtifactScope {\n if (path.startsWith(\"changes/archive/\")) return \"archive\";\n if (/^changes\\/[^/]+\\//.test(path)) return \"active\";\n if (path.startsWith(\"specs/\")) return \"living\";\n return \"workspace\";\n}\n\nfunction artifactFor(root: string, absolute: string): OpenSpecArtifact {\n const rootPath = portable(root, absolute);\n const path = sourceInventoryPath(root, absolute);\n const scope = artifactScope(rootPath);\n const pieces = rootPath.split(\"/\");\n const archived = scope === \"archive\";\n const changeId = scope === \"active\" ? pieces[1] : scope === \"archive\" ? pieces[2] : undefined;\n const deltaSpecIndex = pieces.indexOf(\"specs\");\n const capability = basename(absolute) === \"spec.md\" && deltaSpecIndex >= 0\n ? pieces.slice(deltaSpecIndex + 1, -1).join(\"/\")\n : undefined;\n let kind: OpenSpecArtifactKind = \"other\";\n let disposition: OpenSpecArtifactDisposition = \"manual-review\";\n\n // A Store checkout that keeps its planning shape at the checkout root holds\n // its own metadata inside the planning root, not beside it.\n if (path === \"@workspace/.openspec-store/store.yaml\" || rootPath === \".openspec-store/store.yaml\") {\n [kind, disposition] = [\"store-metadata\", \"record-external-planning-root\"];\n } else if (rootPath === \"config.yaml\") [kind, disposition] = [\"config\", \"translate-project-context\"];\n else if (rootPath === \"project.md\") [kind, disposition] = [\"project-context\", \"translate-project-context\"];\n else if (rootPath === \"AGENTS.md\") [kind, disposition] = [\"agent-instructions\", \"remove-after-cutover\"];\n else if (/^specs\\/.+\\/spec\\.md$/.test(rootPath)) [kind, disposition] = [\"living-spec\", \"map-requirements\"];\n else if (/^specs\\/.+\\/design\\.md$/.test(rootPath)) [kind, disposition] = [\"living-design\", \"review-as-service-adr\"];\n else if (/^changes\\/(?:archive\\/[^/]+|[^/]+)\\/\\.openspec\\.yaml$/.test(rootPath)) {\n [kind, disposition] = [\"change-metadata\", \"translate-change-metadata\"];\n } else if (basename(absolute) === \"proposal.md\" && (scope === \"active\" || scope === \"archive\")) {\n [kind, disposition] = [\"proposal\", \"convert-to-intent\"];\n } else if (basename(absolute) === \"tasks.md\" && (scope === \"active\" || scope === \"archive\")) {\n [kind, disposition] = [\"tasks\", \"preserve-as-legacy-checklist\"];\n } else if (basename(absolute) === \"design.md\" && (scope === \"active\" || scope === \"archive\")) {\n [kind, disposition] = [\"change-design\", \"review-as-feature-adr\"];\n } else if (basename(absolute) === \"spec.md\" && (scope === \"active\" || scope === \"archive\")) {\n [kind, disposition] = [\"delta-spec\", \"map-delta\"];\n } else if (/^schemas\\/[^/]+\\/schema\\.yaml$/.test(rootPath)) {\n [kind, disposition] = [\"custom-schema\", \"review-custom-workflow\"];\n } else if (/^schemas\\/[^/]+\\/templates\\//.test(rootPath)) {\n [kind, disposition] = [\"schema-template\", \"review-custom-workflow\"];\n }\n\n if (archived) disposition = \"retain-read-only\";\n return { path, scope, kind, disposition, ...(changeId ? { changeId } : {}), ...(capability ? { capability } : {}) };\n}\n\nfunction sortIssues(issues: OpenSpecUnsupportedShape[]): void {\n issues.sort((a, b) => compareIds(a.path, b.path) || compareIds(a.code, b.code));\n}\n\nconst LOAM_FEATURE_ID_RE = /^[A-Za-z][A-Za-z0-9]*-\\d+$/;\n\nfunction titleFromChangeId(id: string): string {\n const words = id.split(/[-_]+/).filter(Boolean);\n const text = words.join(\" \");\n return text === \"\" ? id : text[0]!.toUpperCase() + text.slice(1);\n}\n\nfunction emptyMapping(mapping?: OpenSpecMapping): OpenSpecMapping {\n if (mapping === undefined) {\n return {\n source: null,\n capabilities: dictionary(),\n changes: dictionary(),\n renames: dictionary(),\n artifacts: dictionary(),\n };\n }\n // Keep the core inventory tolerant of programmatic v0 callers while the CLI\n // parser enforces the complete v1 document, including explicit `changes`.\n return {\n source: mapping.source ?? null,\n capabilities: mapping.capabilities ?? dictionary(),\n changes: mapping.changes ?? dictionary(),\n renames: mapping.renames ?? dictionary(),\n artifacts: mapping.artifacts ?? dictionary(),\n };\n}\n\nexport function createOpenSpecMappingSkeleton(inventory: OpenSpecInventory): OpenSpecMappingSkeleton {\n return {\n version: 1,\n source: { root: inventory.root, inventoryDigest: inventory.inventoryDigest },\n capabilities: Object.fromEntries(inventory.mappingDecisions.map((decision) => [\n decision.capability,\n {\n services: decision.services,\n suggestedServices: [decision.suggestedService],\n requirementServices: decision.requirementServices,\n },\n ])),\n changes: Object.fromEntries(inventory.changeDecisions.map((decision) => [\n decision.change,\n {\n feature: null,\n suggestedFeature: decision.suggestedFeature,\n title: decision.title,\n },\n ])),\n renames: Object.fromEntries(\n inventory.renamed\n .filter((rename) => rename.scope === \"active\")\n .map((rename) => [rename.key, {\n from: rename.from,\n to: rename.to,\n existingRequirementId: rename.existingRequirementId,\n requirementId: rename.status === \"mapped\" ? rename.existingRequirementId : null,\n }]),\n ),\n artifacts: Object.fromEntries(inventory.artifactDecisions.map((decision) => [\n decision.path,\n {\n kind: decision.kind,\n disposition: null,\n suggestedDisposition: decision.suggestedDisposition,\n },\n ])),\n };\n}\n\nasync function digestInventory(root: string, files: string[]): Promise<string> {\n const hash = createHash(\"sha256\");\n // v3 narrowed the covered set to living + active. The version string is what\n // stops a v2 mapping from being accepted against a v3 reading of the same tree.\n hash.update(\"loam-openspec-inventory-v3\\0\");\n for (const absolute of [...new Set(files)].sort((a, b) => compareIds(sourceInventoryPath(root, a), sourceInventoryPath(root, b)))) {\n const path = sourceInventoryPath(root, absolute);\n const bytes = await readFile(absolute);\n hash.update(`${path.length}:${path}:${bytes.length}:`);\n hash.update(bytes);\n hash.update(\"\\0\");\n }\n return `sha256:${hash.digest(\"hex\")}`;\n}\n\nexport async function inventoryOpenSpec(\n input: string,\n options: { mapping?: OpenSpecMapping } = {},\n): Promise<OpenSpecInventory> {\n const located = await locateOpenSpecRoot(input);\n const { inputRoot, root } = located;\n const mapping = emptyMapping(options.mapping);\n const renamed: OpenSpecRenamedUsage[] = [];\n const blockers: OpenSpecUnsupportedShape[] = [];\n const archiveDiagnostics: OpenSpecUnsupportedShape[] = [];\n for (const absolute of await walkSymlinks(root)) {\n const path = portable(root, absolute);\n const scope = artifactScope(path);\n issue(\n scope === \"archive\" ? archiveDiagnostics : blockers,\n scope,\n \"openspec.symlink-unsupported\",\n path,\n \"Symbolic links are not followed by migration inventory; replace this link with an in-tree regular file or directory.\",\n );\n }\n const config = await inspectConfig(root, blockers);\n const specsRoot = join(root, \"specs\");\n const changesRoot = join(root, \"changes\");\n const inputStoreMetadata = join(inputRoot, \".openspec-store\", \"store.yaml\");\n const parentStoreMetadata = basename(root) === \"openspec\"\n ? join(dirname(root), \".openspec-store\", \"store.yaml\")\n : inputStoreMetadata;\n const storeMetadata = existsSync(inputStoreMetadata) ? inputStoreMetadata : parentStoreMetadata;\n const storeMetadataExists = existsSync(storeMetadata);\n const storeMetadataSymlink = storeMetadataExists && await isSymbolicLink(storeMetadata);\n if (storeMetadataSymlink) {\n issue(\n blockers,\n \"workspace\",\n \"openspec.symlink-unsupported\",\n sourceInventoryPath(root, storeMetadata),\n \"Symbolic Store metadata is not followed; replace it with an in-tree regular file.\",\n );\n }\n const hasModernEmptyShape = config !== null || (storeMetadataExists && !storeMetadataSymlink);\n if (!await isDirectory(specsRoot) && !hasModernEmptyShape) {\n issue(blockers, \"living\", \"openspec.specs-missing\", \"specs\", \"Living specs/ directory is missing.\");\n }\n if (config !== null && config.store !== null && !await isDirectory(specsRoot) && !await isDirectory(changesRoot)) {\n issue(\n blockers,\n \"workspace\",\n \"openspec.external-store-pointer\",\n \"config.yaml\",\n `Planning is externalized to Store '${config.store}'; audit that registered Store checkout directly.`,\n );\n }\n\n const capabilities: OpenSpecCapability[] = [];\n const livingRequirements = new Map<string, ReturnType<typeof parseRequirements>>();\n const livingCounts: OpenSpecCounts = { specFiles: 0, requirements: 0, scenarios: 0 };\n const livingTree = await walkFiles(specsRoot);\n const livingFiles = livingTree.filter((path) => basename(path) === \"spec.md\");\n // The living twin of openspec.nonstandard-change-spec. Selecting living specs\n // by exact basename is right, but without the mirror a mis-cased or renamed\n // file simply disappears: specs/payments/Spec.md audited as a clean, empty\n // corpus while the identical shape under a change was reported.\n for (const file of livingTree.filter((path) =>\n /\\.md$/i.test(path) && basename(path) !== \"spec.md\" && basename(path) !== \"design.md\")) {\n blockers.push({\n code: \"openspec.nonstandard-living-spec\",\n path: portable(root, file),\n message: \"Markdown under specs/ is named neither spec.md nor design.md, so no capability reads it.\",\n scope: \"living\",\n });\n }\n for (const specFile of livingFiles) {\n const id = portable(specsRoot, dirname(specFile));\n const inspected = await inspectSpecFile(root, specFile, \"living\", null, mapping, renamed, blockers);\n livingRequirements.set(id, parseRequirements(await readFile(specFile, \"utf8\")));\n const capability = { id, files: [inspected.path], ...inspected.counts };\n capabilities.push(capability);\n addCounts(livingCounts, inspected.counts);\n }\n capabilities.sort((a, b) => compareIds(a.id, b.id));\n\n const activeIds = (await subdirs(changesRoot)).filter((id) => id !== \"archive\");\n const archiveRoot = join(changesRoot, \"archive\");\n const archivedIds = await subdirs(archiveRoot);\n for (const id of await hiddenSubdirs(changesRoot)) {\n blockers.push({\n code: \"openspec.hidden-change-directory\",\n path: portable(root, join(changesRoot, id)),\n message: \"A dot-prefixed change directory is not enumerated as a change, so nothing under it is migrated; rename it or move it out of changes/.\",\n scope: \"active\",\n });\n }\n for (const id of await hiddenSubdirs(archiveRoot)) {\n archiveDiagnostics.push({\n code: \"openspec.hidden-change-directory\",\n path: portable(root, join(archiveRoot, id)),\n message: \"A dot-prefixed archive directory is not enumerated as a change; frozen history is retained read-only where it is.\",\n scope: \"archive\",\n });\n }\n const fallbackSchema = config?.schema ?? \"spec-driven\";\n const active = await inventoryChanges(\n root,\n changesRoot,\n activeIds,\n \"active\",\n fallbackSchema,\n mapping,\n renamed,\n blockers,\n );\n const archived = await inventoryChanges(\n root,\n archiveRoot,\n archivedIds,\n \"archive\",\n fallbackSchema,\n mapping,\n renamed,\n archiveDiagnostics,\n );\n\n // Last-resort backstop under the whole \"audited past the corpus\" family, and\n // the one check that does not depend on root selection being right: an\n // inventory that read no living spec AND no active change describes nothing,\n // so no verdict over it can be `ready`. That is exactly the shape the Store\n // misdetection produced — ready, mechanically compatible, zero capabilities,\n // zero unsupported shapes — where the failure verdict was more confident than\n // any success verdict. A greenfield workspace whose only requirements live\n // under changes/ has an active change and is not caught here.\n if (livingCounts.specFiles === 0 && active.length === 0) {\n blockers.push({\n code: \"openspec.workspace-empty\",\n path: \".\",\n message: `Planning root ${root} holds no living spec and no active change; there is nothing to migrate, so confirm this is the directory that really holds the corpus.`,\n scope: \"workspace\",\n });\n }\n\n const artifactFiles = await walkFiles(root);\n if (storeMetadataExists && !storeMetadataSymlink && !artifactFiles.includes(storeMetadata)) {\n artifactFiles.push(storeMetadata);\n }\n for (const absolute of artifactFiles) {\n const bytes = await readFile(absolute);\n if (isUtf8(bytes)) continue;\n const rootPath = portable(root, absolute);\n const artifactPath = sourceInventoryPath(root, absolute);\n const scope = absolute === storeMetadata ? \"workspace\" : artifactScope(rootPath);\n issue(\n scope === \"archive\" ? archiveDiagnostics : blockers,\n scope,\n \"openspec.non-utf8-artifact\",\n artifactPath,\n \"Migration can preserve only valid UTF-8 authored artifacts; convert this file to UTF-8 before apply.\",\n );\n }\n // The digest binds a mapping to the truth it was reviewed against, and frozen\n // archive history is neither migrated nor allowed to block readiness. Covering\n // it meant a colleague's typo fix under changes/archive/ killed a completed\n // mapping, with no --force and no indication of which file moved.\n const inventoryDigest = await digestInventory(\n root,\n artifactFiles.filter((absolute) => artifactScope(portable(root, absolute)) !== \"archive\"),\n );\n const artifacts = artifactFiles\n .map((path) => artifactFor(root, path))\n .sort((a, b) => compareIds(a.path, b.path));\n\n // Capability ownership must cover the active horizon too: a brand-new\n // capability may exist only under changes/<id>/specs until archive.\n //\n // `routedNames` is the subset a split capability must actually allocate. A\n // renamed requirement is routed by its FROM — that is what keeps the delta in\n // the same services as the living text it rewrites — so demanding an\n // allocation for its TO as well asked a reviewer for a decision apply ignores.\n const requirementNamesByCapability = new Map<string, Set<string>>();\n const routedNamesByCapability = new Map<string, Set<string>>();\n const activeChangesByCapability = new Map<string, Set<string>>();\n const activeRenamePairs = renamed.filter((rename) =>\n rename.scope === \"active\"\n && rename.from !== null && rename.from !== \"\"\n && rename.to !== null && rename.to !== \"\");\n for (const [capability, requirements] of livingRequirements) {\n requirementNamesByCapability.set(capability, new Set(requirements.map((item) => item.name)));\n routedNamesByCapability.set(capability, new Set(requirements.map((item) => item.name)));\n }\n for (const change of active) {\n for (const spec of change.specs) {\n const names = requirementNamesByCapability.get(spec.capability) ?? new Set<string>();\n const routed = routedNamesByCapability.get(spec.capability) ?? new Set<string>();\n for (const name of spec.requirementNames) {\n names.add(name);\n const pairs = activeRenamePairs.filter((rename) =>\n rename.changeId === change.id\n && rename.capability === spec.capability\n && (name === rename.from || name === rename.to));\n routed.add(pairs.length === 1 ? pairs[0]!.from! : name);\n }\n requirementNamesByCapability.set(spec.capability, names);\n routedNamesByCapability.set(spec.capability, routed);\n const changes = activeChangesByCapability.get(spec.capability) ?? new Set<string>();\n changes.add(change.id);\n activeChangesByCapability.set(spec.capability, changes);\n }\n }\n const allCapabilityIds = [...requirementNamesByCapability.keys()].sort(compareIds);\n\n const mappingIssues: OpenSpecMappingIssue[] = [];\n if (options.mapping !== undefined) {\n if (mapping.source === null) {\n mappingIssues.push({\n code: \"mapping.source-missing\",\n key: \"source\",\n message: \"Mapping is not bound to an audited source root and inventory digest.\",\n });\n } else {\n if (resolve(mapping.source.root) !== root) {\n mappingIssues.push({\n code: \"mapping.source-root-mismatch\",\n key: \"source.root\",\n message: `Mapping was created for ${mapping.source.root}, not ${root}.`,\n });\n }\n if (mapping.source.inventoryDigest !== inventoryDigest) {\n mappingIssues.push({\n code: \"mapping.source-digest-mismatch\",\n key: \"source.inventoryDigest\",\n message: `OpenSpec source changed after audit (${mapping.source.inventoryDigest} != ${inventoryDigest}).`,\n });\n }\n }\n }\n const capabilityIds = new Set(allCapabilityIds);\n for (const capability of Object.keys(mapping.capabilities)) {\n if (!capabilityIds.has(capability)) {\n mappingIssues.push({\n code: \"mapping.unknown-capability\",\n key: capability,\n message: `Mapping names unknown capability '${capability}'.`,\n });\n }\n }\n const mappingDecisions: CapabilityMappingDecision[] = allCapabilityIds.map((capability) => {\n const capabilityMapping = ownValue(mapping.capabilities, capability)\n ?? { services: [], requirementServices: dictionary<string[]>() };\n const services = [...new Set(capabilityMapping.services)]\n .filter((service) => service.trim() !== \"\")\n .sort(compareIds);\n const requirementNames = [...(requirementNamesByCapability.get(capability) ?? [])].sort(compareIds);\n const requirementNameSet = new Set(requirementNames);\n const routedNames = [...(routedNamesByCapability.get(capability) ?? [])].sort(compareIds);\n const requirementServices = dictionary<string[]>();\n for (const [requirement, allocated] of Object.entries(capabilityMapping.requirementServices)) {\n if (!requirementNameSet.has(requirement)) {\n mappingIssues.push({\n code: \"mapping.unknown-requirement\",\n key: `${capability}:${requirement}`,\n message: `Capability '${capability}' mapping names unknown requirement '${requirement}'.`,\n });\n continue;\n }\n const selected = [...new Set(allocated)].filter(Boolean).sort(compareIds);\n requirementServices[requirement] = selected;\n for (const service of selected) {\n if (!services.includes(service)) {\n mappingIssues.push({\n code: \"mapping.requirement-service-unknown\",\n key: `${capability}:${requirement}`,\n message: `Requirement '${requirement}' is allocated to '${service}', which is not in capability '${capability}' services.`,\n });\n }\n }\n }\n // Only routed names get an empty slot in the skeleton: an unroutable name\n // offered for allocation is a decision that changes nothing.\n for (const requirement of routedNames) {\n if (ownValue(requirementServices, requirement) === undefined) requirementServices[requirement] = [];\n }\n if (services.length > 1) {\n for (const requirement of routedNames) {\n if ((ownValue(requirementServices, requirement) ?? []).length === 0) {\n mappingIssues.push({\n code: \"mapping.requirement-allocation-missing\",\n key: `${capability}:${requirement}`,\n message: `Split capability '${capability}' must allocate requirement '${requirement}' to at least one selected service.`,\n });\n }\n }\n for (const service of services) {\n if (!Object.values(requirementServices).some((selected) => selected.includes(service))) {\n mappingIssues.push({\n code: \"mapping.service-allocation-empty\",\n key: `${capability}:${service}`,\n message: `Split capability '${capability}' selects service '${service}' but allocates no requirement to it.`,\n });\n }\n }\n }\n return {\n capability,\n service: services.length === 1 ? services[0]! : null,\n services,\n requirementServices,\n suggestedService: capability.split(\"/\").at(-1) ?? capability,\n hasLivingSpec: livingRequirements.has(capability),\n activeChanges: [...(activeChangesByCapability.get(capability) ?? [])].sort(compareIds),\n status: services.length === 0 ? \"needsMapping\" : \"mapped\",\n };\n });\n const decisionsByCapability = new Map(mappingDecisions.map((decision) => [decision.capability, decision]));\n const servicesForRequirement = (capability: string, requirement: string): string[] => {\n const decision = decisionsByCapability.get(capability);\n if (decision === undefined) return [];\n return decision.services.length === 1\n ? decision.services\n : ownValue(decision.requirementServices, requirement) ?? [];\n };\n const livingByService = new Map<string, Array<{ capability: string; requirement: ReturnType<typeof parseRequirements>[number] }>>();\n for (const [capability, requirements] of livingRequirements) {\n for (const requirement of requirements) {\n for (const service of servicesForRequirement(capability, requirement.name)) {\n const routed = livingByService.get(service) ?? [];\n routed.push({ capability, requirement });\n livingByService.set(service, routed);\n }\n }\n }\n\n const activeChangeIds = new Set(active.map((change) => change.id));\n for (const change of Object.keys(mapping.changes)) {\n if (!activeChangeIds.has(change)) {\n mappingIssues.push({\n code: \"mapping.unknown-change\",\n key: change,\n message: `Mapping names unknown active change '${change}'.`,\n });\n }\n }\n const changeDecisions: OpenSpecChangeDecision[] = active.map((change, index) => {\n const suggestedTitle = titleFromChangeId(change.id);\n const selected = ownValue(mapping.changes, change.id);\n const feature = selected?.feature ?? null;\n const title = selected?.title?.trim() ?? suggestedTitle;\n if (selected !== undefined && title === \"\") {\n mappingIssues.push({\n code: \"mapping.change-title-missing\",\n key: change.id,\n message: `Active change '${change.id}' needs a non-empty title.`,\n });\n }\n if (feature !== null && !LOAM_FEATURE_ID_RE.test(feature)) {\n mappingIssues.push({\n code: \"mapping.feature-id-invalid\",\n key: change.id,\n message: `Active change '${change.id}' maps to invalid loam feature id '${feature}'. Expected <word>-<number>.`,\n });\n }\n return {\n change: change.id,\n feature,\n title,\n suggestedFeature: `FEAT-${index + 1}`,\n suggestedTitle,\n status: feature === null || title === \"\" ? \"needsFeature\" : \"mapped\",\n };\n });\n const featureOwners = new Map<string, string[]>();\n for (const decision of changeDecisions) {\n if (decision.feature === null || !LOAM_FEATURE_ID_RE.test(decision.feature)) continue;\n const key = decision.feature.toLowerCase();\n const owners = featureOwners.get(key) ?? [];\n owners.push(decision.change);\n featureOwners.set(key, owners);\n }\n for (const [feature, owners] of featureOwners) {\n if (owners.length > 1) {\n mappingIssues.push({\n code: \"mapping.feature-id-duplicate\",\n key: feature,\n message: `Loam feature id '${feature}' is assigned to multiple OpenSpec changes: ${owners.join(\", \")}.`,\n });\n }\n }\n\n const activeRenames = renamed.filter((rename) => rename.scope === \"active\");\n const renameKeys = new Set(activeRenames.map((rename) => rename.key));\n for (const [key, requirementId] of Object.entries(mapping.renames)) {\n if (!renameKeys.has(key)) {\n mappingIssues.push({\n code: \"mapping.unknown-rename\",\n key,\n message: `Mapping names unknown RENAMED pair '${key}'.`,\n });\n } else if (!REQUIREMENT_ID_RE.test(requirementId)) {\n mappingIssues.push({\n code: \"mapping.invalid-requirement-id\",\n key,\n message: `RENAMED pair '${key}' has invalid Requirement-ID '${requirementId}'.`,\n });\n }\n }\n\n // Resolve every rename against the living source of truth. A mapped id is\n // only needed when the source requirement does not already carry one.\n for (const rename of activeRenames) {\n if (rename.from === null || rename.from === \"\" || rename.to === null || rename.to === \"\") continue;\n const living = livingRequirements.get(rename.capability) ?? [];\n const matches = living.filter((requirement) => requirement.name === rename.from);\n if (matches.length === 0) {\n mappingIssues.push({\n code: \"mapping.rename-source-missing\",\n key: rename.key,\n message: `RENAMED source '${rename.from}' does not exist in living capability '${rename.capability}'.`,\n });\n rename.requirementId = null;\n rename.status = \"needsIdentity\";\n continue;\n }\n if (matches.length > 1) {\n mappingIssues.push({\n code: \"mapping.rename-source-ambiguous\",\n key: rename.key,\n message: `RENAMED source '${rename.from}' matches ${matches.length} living requirements in '${rename.capability}'.`,\n });\n rename.requirementId = null;\n rename.status = \"needsIdentity\";\n continue;\n }\n const source = matches[0]!;\n const declarations = requirementIdDeclarations(source);\n if (declarations.length > 0\n && (declarations.length !== 1 || !REQUIREMENT_ID_RE.test(declarations[0]!))) {\n rename.existingRequirementId = source.id ?? null;\n rename.requirementId = null;\n rename.status = \"needsIdentity\";\n mappingIssues.push({\n code: \"mapping.rename-source-id-invalid\",\n key: rename.key,\n message: `RENAMED source '${rename.from}' has ${declarations.length === 1 ? \"an invalid\" : \"repeated\"} Requirement-ID declaration; repair the living source before migration.`,\n });\n continue;\n }\n rename.existingRequirementId = source.id ?? null;\n const requestedId = ownValue(mapping.renames, rename.key) ?? null;\n if (source.id !== undefined && requestedId !== null && requestedId !== source.id) {\n mappingIssues.push({\n code: \"mapping.rename-existing-id-conflict\",\n key: rename.key,\n message: `RENAMED source '${rename.from}' already has Requirement-ID '${source.id}'; mapping cannot replace it with '${requestedId}'.`,\n });\n }\n rename.requirementId = source.id ?? requestedId;\n rename.status = rename.requirementId === null ? \"needsIdentity\" : \"mapped\";\n const routedServices = servicesForRequirement(rename.capability, rename.from);\n if (rename.requirementId !== null) {\n const collisionServices = routedServices.filter((service) =>\n (livingByService.get(service) ?? []).some(\n (entry) => entry.requirement !== source && entry.requirement.id === rename.requirementId,\n ));\n if (collisionServices.length > 0) {\n mappingIssues.push({\n code: \"mapping.rename-id-conflict\",\n key: rename.key,\n message: `RENAMED identity '${rename.requirementId}' already belongs to another living requirement in mapped service(s): ${collisionServices.join(\", \")}.`,\n });\n }\n }\n const targetCollisionServices = routedServices.filter((service) =>\n (livingByService.get(service) ?? []).some(\n (entry) => entry.requirement !== source && entry.requirement.name === rename.to,\n ));\n if (rename.to === rename.from || targetCollisionServices.length > 0) {\n mappingIssues.push({\n code: \"mapping.rename-target-conflict\",\n key: rename.key,\n message: rename.to === rename.from\n ? `RENAMED target '${rename.to}' is the same as its living source.`\n : `RENAMED target '${rename.to}' conflicts in mapped service(s): ${targetCollisionServices.join(\", \")}.`,\n });\n }\n }\n\n const renameSources = new Map<string, OpenSpecRenamedUsage[]>();\n const renameTargets = new Map<string, OpenSpecRenamedUsage[]>();\n for (const rename of activeRenames) {\n if (rename.from === null || rename.to === null) continue;\n for (const service of servicesForRequirement(rename.capability, rename.from)) {\n const sourceKey = `${service}\\0${rename.from}`;\n const targetKey = `${service}\\0${rename.to}`;\n const sources = renameSources.get(sourceKey) ?? [];\n sources.push(rename);\n renameSources.set(sourceKey, sources);\n const targets = renameTargets.get(targetKey) ?? [];\n targets.push(rename);\n renameTargets.set(targetKey, targets);\n }\n }\n for (const [key, uses] of renameSources) {\n if (uses.length > 1) {\n mappingIssues.push({\n code: \"mapping.rename-double-source\",\n key: key.replace(\"\\0\", \":\"),\n message: `Living requirement '${uses[0]!.from}' is renamed by multiple active changes: ${uses.map((item) => item.changeId).join(\", \")}.`,\n });\n }\n }\n for (const [key, uses] of renameTargets) {\n if (uses.length > 1) {\n mappingIssues.push({\n code: \"mapping.rename-double-target\",\n key: key.replace(\"\\0\", \":\"),\n message: `Multiple active renames target '${uses[0]!.to}' in mapped service '${key.split(\"\\0\")[0]}'.`,\n });\n }\n if (renameSources.has(key)) {\n mappingIssues.push({\n code: \"mapping.rename-chain\",\n key: key.replace(\"\\0\", \":\"),\n message: `Active rename chain through '${uses[0]!.to}' must be collapsed into one reviewed rename.`,\n });\n }\n }\n const renameIdOwners = new Map<string, Set<string>>();\n for (const rename of activeRenames) {\n if (rename.requirementId === null || rename.from === null) continue;\n for (const service of servicesForRequirement(rename.capability, rename.from)) {\n const key = `${service}\\0${rename.requirementId}`;\n const owners = renameIdOwners.get(key) ?? new Set<string>();\n owners.add(`${rename.capability}:${rename.from}`);\n renameIdOwners.set(key, owners);\n }\n }\n for (const [key, owners] of renameIdOwners) {\n if (owners.size > 1) {\n const [service, requirementId] = key.split(\"\\0\");\n mappingIssues.push({\n code: \"mapping.rename-id-conflict\",\n key,\n message: `Requirement-ID '${requirementId}' is assigned to different RENAMED sources in mapped service '${service}': ${[...owners].join(\", \")}.`,\n });\n }\n }\n\n const decisionKinds = new Set<OpenSpecArtifactKind>([\"proposal\", \"tasks\", \"change-design\"]);\n const artifactDecisions: OpenSpecArtifactDecision[] = artifacts\n // Never offer a disposition for an artifact no enumerated change owns —\n // dot-prefixed change directories are refused, not migrated, and a\n // `selectedDisposition` recorded for one is a decision about nothing.\n .filter((artifact): artifact is OpenSpecArtifact & { kind: \"proposal\" | \"tasks\" | \"change-design\" } =>\n artifact.scope === \"active\"\n && decisionKinds.has(artifact.kind)\n && artifact.changeId !== undefined\n && activeChangeIds.has(artifact.changeId))\n .map((artifact) => {\n const selected = ownValue(mapping.artifacts, artifact.path) ?? null;\n return {\n path: artifact.path,\n kind: artifact.kind,\n suggestedDisposition: artifact.disposition,\n disposition: selected,\n status: selected === null ? \"needsDisposition\" as const : \"mapped\" as const,\n };\n });\n const artifactPaths = new Set(artifactDecisions.map((decision) => decision.path));\n const dispositionsByKind: Record<OpenSpecArtifactDecision[\"kind\"], Set<OpenSpecArtifactDisposition>> = {\n proposal: new Set([\"convert-to-intent\", \"retain-read-only\", \"manual-review\"]),\n tasks: new Set([\"preserve-as-legacy-checklist\", \"retain-read-only\", \"manual-review\"]),\n \"change-design\": new Set([\"review-as-feature-adr\", \"retain-read-only\", \"manual-review\"]),\n };\n for (const [path, disposition] of Object.entries(mapping.artifacts)) {\n if (!artifactPaths.has(path)) {\n mappingIssues.push({\n code: \"mapping.unknown-artifact\",\n key: path,\n message: `Mapping names unknown active authored artifact '${path}'.`,\n });\n } else {\n const decision = artifactDecisions.find((item) => item.path === path)!;\n if (dispositionsByKind[decision.kind].has(disposition)) continue;\n mappingIssues.push({\n code: \"mapping.invalid-artifact-disposition\",\n key: path,\n message: `${decision.kind} artifact '${path}' has unsupported disposition '${disposition}'.`,\n });\n }\n }\n mappingIssues.sort((a, b) => compareIds(a.key, b.key) || compareIds(a.code, b.code));\n\n renamed.sort((a, b) => compareIds(a.path, b.path) || a.line - b.line || compareIds(a.key, b.key));\n sortIssues(blockers);\n sortIssues(archiveDiagnostics);\n const livingIssueCount = blockers.filter((item) => item.scope === \"workspace\" || item.scope === \"living\").length;\n const activeIssueCount = blockers.filter((item) => item.scope === \"active\").length;\n const needsMapping = mappingDecisions.filter((decision) => decision.status === \"needsMapping\");\n const needsChangeMapping = changeDecisions.filter((decision) => decision.status === \"needsFeature\");\n const needsDisposition = artifactDecisions.filter((decision) => decision.status === \"needsDisposition\");\n const unresolvedActiveRenames = renamed.filter(\n (rename) => rename.scope === \"active\" && rename.status === \"needsIdentity\",\n );\n const mechanicallyCompatible = livingIssueCount === 0 && activeIssueCount === 0;\n const ready = mechanicallyCompatible\n && needsMapping.length === 0\n && needsChangeMapping.length === 0\n && unresolvedActiveRenames.length === 0\n && needsDisposition.length === 0\n && mappingIssues.length === 0;\n\n return {\n baselines: OPENSPEC_BASELINES,\n inputRoot,\n root,\n inventoryDigest,\n workspace: {\n kind: located.kind,\n config,\n storeMetadataPath: storeMetadataExists ? sourceInventoryPath(root, storeMetadata) : null,\n },\n ready,\n mechanicallyCompatible,\n readiness: {\n living: { compatible: livingIssueCount === 0, issueCount: livingIssueCount },\n active: { compatible: activeIssueCount === 0, issueCount: activeIssueCount },\n sourceCurrent: !mappingIssues.some((item) => item.code.startsWith(\"mapping.source-\")),\n mappingsResolved: needsMapping.length === 0 && !mappingIssues.some((item) =>\n item.code === \"mapping.unknown-capability\"\n || item.code === \"mapping.unknown-requirement\"\n || item.code.startsWith(\"mapping.requirement-\")\n || item.code === \"mapping.service-allocation-empty\"),\n changesResolved: needsChangeMapping.length === 0 && !mappingIssues.some((item) =>\n item.code === \"mapping.unknown-change\"\n || item.code === \"mapping.change-title-missing\"\n || item.code.startsWith(\"mapping.feature-id-\")),\n renamesResolved: unresolvedActiveRenames.length === 0 && !mappingIssues.some((item) => item.code.includes(\"rename\") || item.code.includes(\"requirement-id\")),\n dispositionsResolved: needsDisposition.length === 0 && !mappingIssues.some((item) => item.code.includes(\"artifact\")),\n migrationReady: ready,\n },\n living: { ...livingCounts, capabilities },\n changes: {\n active,\n archived,\n counts: { active: active.length, archived: archived.length },\n },\n renamed,\n unsupported: blockers,\n archiveDiagnostics,\n mappingDecisions,\n needsMapping,\n changeDecisions,\n needsChangeMapping,\n mappingIssues,\n artifacts,\n artifactDecisions,\n needsDisposition,\n };\n}\n"]}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Resolve caller-controlled paths without letting them leave an owned tree.
3
+ *
4
+ * A lexical `relative()` check is not enough: an existing component may be a
5
+ * symlink whose target lives elsewhere. Conversely, checking only the final
6
+ * path misses destinations that do not exist yet but whose nearest existing
7
+ * parent is a symlink. This helper checks both views before a caller reads,
8
+ * writes, walks, or removes anything.
9
+ */
10
+ import { lstatSync, realpathSync } from "node:fs";
11
+ import { dirname, isAbsolute, relative, resolve, sep, win32 } from "node:path";
12
+ export class UnsafePathError extends Error {
13
+ candidate;
14
+ constructor(candidate, message) {
15
+ super(message);
16
+ this.candidate = candidate;
17
+ this.name = "UnsafePathError";
18
+ }
19
+ }
20
+ /** True when `target` is `root` or one of its descendants. */
21
+ export function isPathInside(root, target) {
22
+ const rel = relative(resolve(root), resolve(target));
23
+ return rel === "" || (!isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`));
24
+ }
25
+ /**
26
+ * Resolve a relative path beneath `root`, rejecting absolute paths, explicit
27
+ * parent traversal, and symlink escape. The final path may be absent: its
28
+ * nearest existing ancestor is checked in that case.
29
+ */
30
+ export function resolveInside(root, candidate, label = "path") {
31
+ if (candidate.length === 0) {
32
+ throw new UnsafePathError(candidate, `${label} must not be empty`);
33
+ }
34
+ // win32.isAbsolute is intentional even on POSIX. Persisted/configured paths
35
+ // may be moved between operating systems, and `C:\\...` must never turn into
36
+ // an innocuous relative filename merely because validation ran on Linux.
37
+ if (isAbsolute(candidate) || win32.isAbsolute(candidate)) {
38
+ throw new UnsafePathError(candidate, `${label} must be relative to its owning directory`);
39
+ }
40
+ if (candidate.split(/[\\/]/).includes("..")) {
41
+ throw new UnsafePathError(candidate, `${label} must not contain '..' path segments`);
42
+ }
43
+ const rootAbs = resolve(root);
44
+ const target = resolve(rootAbs, candidate);
45
+ if (!isPathInside(rootAbs, target)) {
46
+ throw new UnsafePathError(candidate, `${label} resolves outside its owning directory`);
47
+ }
48
+ let rootReal;
49
+ let existing;
50
+ try {
51
+ rootReal = realpathSync(rootAbs);
52
+ existing = nearestExisting(target, rootAbs);
53
+ }
54
+ catch (err) {
55
+ const detail = err instanceof Error ? err.message : String(err);
56
+ throw new UnsafePathError(candidate, `${label} cannot be resolved safely: ${detail}`);
57
+ }
58
+ let existingReal;
59
+ try {
60
+ existingReal = realpathSync(existing);
61
+ }
62
+ catch (err) {
63
+ // A broken symlink is an existing path according to lstat, but realpath
64
+ // cannot prove where a later write through it would land. Refuse it.
65
+ const detail = err instanceof Error ? err.message : String(err);
66
+ throw new UnsafePathError(candidate, `${label} crosses an unreadable or broken symlink: ${detail}`);
67
+ }
68
+ if (!isPathInside(rootReal, existingReal)) {
69
+ throw new UnsafePathError(candidate, `${label} crosses a symlink outside its owning directory`);
70
+ }
71
+ return target;
72
+ }
73
+ /**
74
+ * Snapshot manifests are portable data, so their path spelling is stricter
75
+ * than an interactive path: forward slashes, no redundant components, and a
76
+ * file (not directory) name at the end.
77
+ */
78
+ export function resolvePortableFileInside(root, candidate, label = "path") {
79
+ if (candidate.includes("\\")) {
80
+ throw new UnsafePathError(candidate, `${label} must use forward slashes`);
81
+ }
82
+ const parts = candidate.split("/");
83
+ if (parts.some((part) => part === "" || part === "." || part === "..")) {
84
+ throw new UnsafePathError(candidate, `${label} must be a canonical relative file path`);
85
+ }
86
+ return resolveInside(root, candidate, label);
87
+ }
88
+ /** Find the closest lexically contained path that exists, including symlinks. */
89
+ function nearestExisting(target, root) {
90
+ let current = target;
91
+ for (;;) {
92
+ try {
93
+ lstatSync(current);
94
+ return current;
95
+ }
96
+ catch (err) {
97
+ const code = err.code;
98
+ if (code !== "ENOENT" && code !== "ENOTDIR")
99
+ throw err;
100
+ }
101
+ if (current === root)
102
+ return root;
103
+ const parent = dirname(current);
104
+ if (parent === current || !isPathInside(root, parent))
105
+ return root;
106
+ current = parent;
107
+ }
108
+ }
109
+ //# sourceMappingURL=path-safety.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-safety.js","sourceRoot":"","sources":["../../src/core/path-safety.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAE/E,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAE7B,SAAS;IADpB,YACW,SAAiB,EAC1B,OA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()` check is not enough: an existing component may be a\n * symlink whose target lives elsewhere. Conversely, checking only the final\n * path misses destinations that do not exist yet but whose nearest existing\n * parent is a symlink. This helper checks both views before a caller reads,\n * writes, walks, or removes anything.\n */\nimport { lstatSync, realpathSync } from \"node:fs\";\nimport { dirname, isAbsolute, relative, resolve, sep, win32 } from \"node:path\";\n\nexport class UnsafePathError extends Error {\n constructor(\n readonly candidate: string,\n message: string,\n ) {\n super(message);\n this.name = \"UnsafePathError\";\n }\n}\n\n/** True when `target` is `root` or one of its descendants. */\nexport function isPathInside(root: string, target: string): boolean {\n const rel = relative(resolve(root), resolve(target));\n return rel === \"\" || (!isAbsolute(rel) && rel !== \"..\" && !rel.startsWith(`..${sep}`));\n}\n\n/**\n * Resolve a relative path beneath `root`, rejecting absolute paths, explicit\n * parent traversal, and symlink escape. The final path may be absent: its\n * nearest existing ancestor is checked in that case.\n */\nexport function resolveInside(root: string, candidate: string, label = \"path\"): string {\n if (candidate.length === 0) {\n throw new UnsafePathError(candidate, `${label} must not be empty`);\n }\n // win32.isAbsolute is intentional even on POSIX. Persisted/configured paths\n // may be moved between operating systems, and `C:\\\\...` must never turn into\n // an innocuous relative filename merely because validation ran on Linux.\n if (isAbsolute(candidate) || win32.isAbsolute(candidate)) {\n throw new UnsafePathError(candidate, `${label} must be relative to its owning directory`);\n }\n if (candidate.split(/[\\\\/]/).includes(\"..\")) {\n throw new UnsafePathError(candidate, `${label} must not contain '..' path segments`);\n }\n\n const rootAbs = resolve(root);\n const target = resolve(rootAbs, candidate);\n if (!isPathInside(rootAbs, target)) {\n throw new UnsafePathError(candidate, `${label} resolves outside its owning directory`);\n }\n\n let rootReal: string;\n let existing: string;\n try {\n rootReal = realpathSync(rootAbs);\n existing = nearestExisting(target, rootAbs);\n } catch (err) {\n const detail = err instanceof Error ? err.message : String(err);\n throw new UnsafePathError(candidate, `${label} cannot be resolved safely: ${detail}`);\n }\n\n let existingReal: string;\n try {\n existingReal = realpathSync(existing);\n } catch (err) {\n // A broken symlink is an existing path according to lstat, but realpath\n // cannot prove where a later write through it would land. Refuse it.\n const detail = err instanceof Error ? err.message : String(err);\n throw new UnsafePathError(candidate, `${label} crosses an unreadable or broken symlink: ${detail}`);\n }\n if (!isPathInside(rootReal, existingReal)) {\n throw new UnsafePathError(candidate, `${label} crosses a symlink outside its owning directory`);\n }\n return target;\n}\n\n/**\n * Snapshot manifests are portable data, so their path spelling is stricter\n * than an interactive path: forward slashes, no redundant components, and a\n * file (not directory) name at the end.\n */\nexport function resolvePortableFileInside(root: string, candidate: string, label = \"path\"): string {\n if (candidate.includes(\"\\\\\")) {\n throw new UnsafePathError(candidate, `${label} must use forward slashes`);\n }\n const parts = candidate.split(\"/\");\n if (parts.some((part) => part === \"\" || part === \".\" || part === \"..\")) {\n throw new UnsafePathError(candidate, `${label} must be a canonical relative file path`);\n }\n return resolveInside(root, candidate, label);\n}\n\n/** Find the closest lexically contained path that exists, including symlinks. */\nfunction nearestExisting(target: string, root: string): string {\n let current = target;\n for (;;) {\n try {\n lstatSync(current);\n return current;\n } catch (err) {\n const code = (err as NodeJS.ErrnoException).code;\n if (code !== \"ENOENT\" && code !== \"ENOTDIR\") throw err;\n }\n if (current === root) return root;\n const parent = dirname(current);\n if (parent === current || !isPathInside(root, parent)) return root;\n current = parent;\n }\n}\n"]}