@ybotok/loam 0.0.0 → 0.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +138 -0
- package/COMPARISON.md +63 -0
- package/LICENSE +21 -0
- package/MIGRATING-from-OpenSpec.md +202 -0
- package/README.md +246 -9
- package/SCHEMA.md +425 -0
- package/SECURITY.md +9 -0
- package/dist/cli.js +142 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/adopt.js +240 -0
- package/dist/commands/adopt.js.map +1 -0
- package/dist/commands/archive.js +1313 -0
- package/dist/commands/archive.js.map +1 -0
- package/dist/commands/delta.js +388 -0
- package/dist/commands/delta.js.map +1 -0
- package/dist/commands/dependencies.js +83 -0
- package/dist/commands/dependencies.js.map +1 -0
- package/dist/commands/docs-repo-gate.js +104 -0
- package/dist/commands/docs-repo-gate.js.map +1 -0
- package/dist/commands/doctor.js +85 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/explore.js +195 -0
- package/dist/commands/explore.js.map +1 -0
- package/dist/commands/format.js +17 -0
- package/dist/commands/format.js.map +1 -0
- package/dist/commands/gherkin.js +309 -0
- package/dist/commands/gherkin.js.map +1 -0
- package/dist/commands/init.js +250 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/instructions.js +70 -0
- package/dist/commands/instructions.js.map +1 -0
- package/dist/commands/list.js +291 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/migrate-openspec.js +950 -0
- package/dist/commands/migrate-openspec.js.map +1 -0
- package/dist/commands/new.js +413 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/rebase.js +356 -0
- package/dist/commands/rebase.js.map +1 -0
- package/dist/commands/show.js +320 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/status.js +254 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/unarchive.js +317 -0
- package/dist/commands/unarchive.js.map +1 -0
- package/dist/commands/validate.js +1591 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/verify.js +775 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/commands/vouch.js +343 -0
- package/dist/commands/vouch.js.map +1 -0
- package/dist/core/agent.js +2065 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/agents-stamp.js +68 -0
- package/dist/core/agents-stamp.js.map +1 -0
- package/dist/core/arch.js +130 -0
- package/dist/core/arch.js.map +1 -0
- package/dist/core/brief.js +733 -0
- package/dist/core/brief.js.map +1 -0
- package/dist/core/coherence.js +577 -0
- package/dist/core/coherence.js.map +1 -0
- package/dist/core/concurrency.js +51 -0
- package/dist/core/concurrency.js.map +1 -0
- package/dist/core/config.js +180 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/delta.js +476 -0
- package/dist/core/delta.js.map +1 -0
- package/dist/core/dependencies.js +356 -0
- package/dist/core/dependencies.js.map +1 -0
- package/dist/core/docs.js +144 -0
- package/dist/core/docs.js.map +1 -0
- package/dist/core/doctor.js +559 -0
- package/dist/core/doctor.js.map +1 -0
- package/dist/core/document-bytes.js +59 -0
- package/dist/core/document-bytes.js.map +1 -0
- package/dist/core/explore.js +225 -0
- package/dist/core/explore.js.map +1 -0
- package/dist/core/fleet-context.js +225 -0
- package/dist/core/fleet-context.js.map +1 -0
- package/dist/core/frontmatter.js +199 -0
- package/dist/core/frontmatter.js.map +1 -0
- package/dist/core/gherkin.js +463 -0
- package/dist/core/gherkin.js.map +1 -0
- package/dist/core/health.js +67 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/ids.js +122 -0
- package/dist/core/ids.js.map +1 -0
- package/dist/core/issue.js +9 -0
- package/dist/core/issue.js.map +1 -0
- package/dist/core/json.js +74 -0
- package/dist/core/json.js.map +1 -0
- package/dist/core/likec4.js +479 -0
- package/dist/core/likec4.js.map +1 -0
- package/dist/core/maturity.js +66 -0
- package/dist/core/maturity.js.map +1 -0
- package/dist/core/openapi-merge.js +552 -0
- package/dist/core/openapi-merge.js.map +1 -0
- package/dist/core/openapi.js +255 -0
- package/dist/core/openapi.js.map +1 -0
- package/dist/core/openspec-inventory.js +1440 -0
- package/dist/core/openspec-inventory.js.map +1 -0
- package/dist/core/path-safety.js +168 -0
- package/dist/core/path-safety.js.map +1 -0
- package/dist/core/provenance.js +720 -0
- package/dist/core/provenance.js.map +1 -0
- package/dist/core/records.js +33 -0
- package/dist/core/records.js.map +1 -0
- package/dist/core/repo.js +436 -0
- package/dist/core/repo.js.map +1 -0
- package/dist/core/report.js +47 -0
- package/dist/core/report.js.map +1 -0
- package/dist/core/results.js +199 -0
- package/dist/core/results.js.map +1 -0
- package/dist/core/spec.js +481 -0
- package/dist/core/spec.js.map +1 -0
- package/dist/core/staging.js +890 -0
- package/dist/core/staging.js.map +1 -0
- package/dist/core/status.js +1104 -0
- package/dist/core/status.js.map +1 -0
- package/dist/core/steps.js +72 -0
- package/dist/core/steps.js.map +1 -0
- package/dist/core/verify.js +807 -0
- package/dist/core/verify.js.map +1 -0
- package/dist/core/version.js +24 -0
- package/dist/core/version.js.map +1 -0
- package/package.json +63 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-merge.js","sourceRoot":"","sources":["../../src/core/openapi-merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,+EAA+E;AAC/E,6DAA6D;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAexC;;;;;;;;;GASG;AACH,MAAM,UAAU,yBAAyB,CAAC,SAAkB,EAAE,QAAiB;IAC7E,OAAO,uBAAuB,CAC5B,mBAAmB,CAAC,SAAS,CAAC,EAC9B,eAAe,CAAC,SAA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,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { isDeepStrictEqual } from \"node:util\";\nimport { isMap, parseDocument } from \"yaml\";\nimport {\n HTTP_METHODS,\n OPENAPI_BASELINE_KEY,\n classifyBaselineDigests,\n operationBaselineOf,\n operationDigest,\n withoutOperationBaseline,\n} from \"./openapi.js\";\n// Every `isRecord` below asks one question of a resolved plain tree: is this a\n// node that can hold OpenAPI keys — an object, not an array?\nimport { isRecord } from \"./records.js\";\n\n/**\n * What a feature's operation IS, relative to the living contract — the one\n * judgement that tells a QUOTE from an EDIT.\n *\n * A feature's openapi.yaml is a complete document, so most of what it spells is\n * quotation: the author restated the living contract around the slot they were\n * changing. Without a pin the merge cannot tell the two apart and upserts both,\n * which is how a feature that only meant to touch `cancelOrder` silently\n * reverted another team's landed change to `refundOrder` — no overlap between\n * the features required, just two deltas over one service.\n */\nexport type OperationBaselineVerdict = ReturnType<typeof classifyBaselineDigests>;\n\n/**\n * Classify one feature operation against its living counterpart, from the raw\n * YAML trees the merge works in. The rule itself lives in core/openapi.ts, so\n * the gate and the merge cannot drift apart about which operations get written.\n *\n * A malformed pin matches no digest and lands in `stale`, which merges rather\n * than skips. Deliberate: `openapi.baseline-invalid` refuses it at the gate, and\n * a value nobody can evaluate must never be the reason a merge quietly drops an\n * operation.\n */\nexport function classifyOperationBaseline(featureOp: unknown, livingOp: unknown): OperationBaselineVerdict {\n return classifyBaselineDigests(\n operationBaselineOf(featureOp),\n operationDigest(featureOp),\n livingOp === undefined ? undefined : operationDigest(livingOp),\n );\n}\n\n/** What happened to one operation's `x-loam-based-on`. */\nexport interface OperationPin {\n path: string;\n method: string;\n /** Empty when the operation declares none — the slot is still the identity. */\n operationId: string;\n status:\n /** It had no pin and now has one. */\n | \"pinned\"\n /** It named an older living version; it now names the current one. */\n | \"repinned\"\n /** It already named the current living version — no write. */\n | \"unchanged\"\n /** The living contract has no operation at this slot: this feature is adding it. */\n | \"unresolved\"\n /** Written as a YAML alias — one shared value backs every use, so loam will not stamp through it. */\n | \"unwritable\";\n from: string | null;\n to: string | null;\n}\n\nexport interface OpenapiPinPlan {\n /** The rewritten contract, or null when no pin changes. */\n text: string | null;\n pins: OperationPin[];\n}\n\n/**\n * Pin every operation in a feature contract against the living one — what\n * `loam rebase` writes on this axis.\n *\n * The pin is always `operationDigest` of the LIVING operation, never of the\n * delta's own, and that single rule produces both merge verdicts by itself: an\n * operation the author only QUOTED is byte-equal to living, so its pin equals\n * its own content and `classifyOperationBaseline` calls it a quote; one the\n * author EDITED differs from its pin, so the merge writes it. Nothing has to\n * guess at intent — the document already records it, and the pin makes it\n * legible to the merge.\n *\n * Slot-keyed (path + method), exactly as the merge upserts. An operationId that\n * moved to another slot is a new slot with nothing living behind it, which is\n * `unresolved` and correct: there is no living version of an operation at a\n * path the contract does not serve yet.\n */\nexport function pinOpenapiOperations(featureText: string, livingText: string, service: string): OpenapiPinPlan {\n const doc = parseDocument(featureText);\n if (doc.errors.length > 0) throw new OpenapiMergeError(\"feature\", service, doc.errors[0]!.message);\n let featPlain: unknown;\n let livingPlain: unknown;\n try {\n featPlain = doc.toJS() ?? {};\n } catch (error) {\n throw new OpenapiMergeError(\"feature\", service, errorMessage(error));\n }\n try {\n const parsed = parseDocument(livingText);\n if (parsed.errors.length > 0) throw new OpenapiMergeError(\"living\", service, parsed.errors[0]!.message);\n livingPlain = parsed.toJS() ?? {};\n } catch (error) {\n if (error instanceof OpenapiMergeError) throw error;\n throw new OpenapiMergeError(\"living\", service, errorMessage(error));\n }\n\n const featPaths = plainChild(featPlain, \"paths\");\n if (!isRecord(featPaths)) return { text: null, pins: [] };\n const livingPaths = plainChild(livingPlain, \"paths\");\n\n const pins: OperationPin[] = [];\n let edited = false;\n for (const [path, item] of Object.entries(featPaths)) {\n if (!isRecord(item)) continue;\n for (const [method, op] of Object.entries(item)) {\n if (!HTTP_METHODS.has(method) || !isRecord(op)) continue;\n // A removal marker asserts a slot rather than restating an operation, so\n // it has nothing to be based on; `openapi.remove-target-mismatch` is what\n // guards it against a living slot that moved under it.\n if (isRemoval(op)) continue;\n\n const id = typeof op[\"operationId\"] === \"string\" ? op[\"operationId\"] : \"\";\n const at = { path, method, operationId: id };\n const from = operationBaselineOf(op) ?? null;\n const livingItem = plainChild(livingPaths, path);\n const livingOp = isRecord(livingItem) ? livingItem[method] : undefined;\n if (!isRecord(livingOp)) {\n pins.push({ ...at, status: \"unresolved\", from, to: null });\n continue;\n }\n const digest = operationDigest(livingOp);\n if (from === digest) {\n pins.push({ ...at, status: \"unchanged\", from: digest, to: digest });\n continue;\n }\n // One shared value backs every use of an anchor, so `setIn` through an\n // alias would pin every other use of it too — the same reason\n // stripOpenapiRemovalMarkers refuses to edit aliases in place.\n if (!isMap(doc.getIn([\"paths\", path, method]))) {\n pins.push({ ...at, status: \"unwritable\", from, to: null });\n continue;\n }\n pins.push({ ...at, status: from === null ? \"pinned\" : \"repinned\", from, to: digest });\n doc.setIn([\"paths\", path, method, OPENAPI_BASELINE_KEY], digest);\n edited = true;\n }\n }\n\n if (!edited) return { text: null, pins };\n try {\n return { text: doc.toString(), pins };\n } catch (error) {\n throw new OpenapiMergeError(\"feature\", service, errorMessage(error));\n }\n}\n\n/** What an OpenAPI path merge computed, including every condition the caller must surface. */\nexport interface OpenapiMergeResult {\n /** The merged living document, or null when the feature document has no paths to merge. */\n text: string | null;\n /** Labels of existing operations overwritten with different content. */\n modified: string[];\n /**\n * Labels of PATH-LEVEL keys (`parameters`, `servers`, `summary`, `x-*`)\n * overwritten with different content. They are not operations, so they were\n * excluded from the difference check entirely and overwritten in silence —\n * a delta restating a path with a shorter `parameters` list dropped shared\n * parameters from every operation under it, and the plan said nothing.\n */\n pathItemModified: string[];\n /** Labels of living operations deleted by `x-loam-remove: true` markers. */\n removed: string[];\n /**\n * Labels of operations the delta QUOTED — pinned, and equal to their own\n * baseline — so the merge left the living contract's own copy alone. Reported\n * rather than silent: \"your delta mentions this and I did not write it\" is\n * exactly the sentence whose absence made the revert invisible.\n */\n quoted: string[];\n /**\n * Labels of operations whose pin matches neither the delta's own content nor\n * the living one: edited here AND changed by somebody else in between.\n * `openapi.baseline-stale` refuses these at the gate; the merge still\n * overwrites, because reaching it at all means `--approve` said to.\n */\n baselineStale: string[];\n /** `<kind>/<name>` of living components overwritten with different content. */\n componentsModified: string[];\n /** Local refs reachable from merged content that resolve in neither document. */\n unresolved: Array<{ ref: string; from: string }>;\n}\n\nexport type OpenapiMergeSource = \"feature\" | \"living\";\n\n/** A document the merge planner cannot read. Commands map this domain error to their own envelope. */\nexport class OpenapiMergeError extends Error {\n override readonly name = \"OpenapiMergeError\";\n\n constructor(\n readonly source: OpenapiMergeSource,\n readonly service: string,\n detail: string,\n ) {\n super(`${source} openapi for ${service} is not valid YAML: ${detail}`);\n }\n}\n\n/**\n * Remove feature-only operation-removal markers before a feature contract is\n * used to create a brand-new living document. Normally coherence refuses this\n * shape because there cannot be a removal target; this guard also keeps\n * `--approve` from ever persisting the marker into living docs.\n */\nexport function stripOpenapiRemovalMarkers(featureText: string, service: string): string {\n const feature = parseDocument(featureText);\n if (feature.errors.length > 0) {\n throw new OpenapiMergeError(\"feature\", service, feature.errors[0]!.message);\n }\n let plain: unknown;\n try {\n plain = feature.toJS() ?? {};\n } catch (error) {\n throw new OpenapiMergeError(\"feature\", service, errorMessage(error));\n }\n // Shape from the RESOLVED tree, for the same reason the merge reads it there:\n // an aliased `paths` or path item is not a map node, and treating it as\n // \"nothing to strip\" is how a feature-only marker reached a living contract.\n const paths = plainChild(plain, \"paths\");\n if (!isRecord(paths)) return featureText;\n\n const cleaned: Record<string, unknown> = {};\n let stripped = false;\n for (const [path, item] of Object.entries(paths)) {\n const kept = withoutFeatureMarkers(item);\n if (!isDeepStrictEqual(kept, item)) stripped = true;\n // A path the strip emptied goes with its last operation: `\\/x: {}` is a\n // path the contract advertises and nothing answers.\n if (kept !== undefined) cleaned[path] = kept;\n }\n if (!stripped) return featureText;\n\n // Edit the AST in place when every node the strip touches IS a node — the\n // author's comments, key order and formatting are theirs to keep. An alias\n // cannot be edited in place (there is one shared value behind it, and\n // deleting a key through it would change every use), so those documents get\n // their `paths` rewritten from the resolved tree instead: losing formatting\n // is a cost, shipping the marker is a corruption.\n //\n // The test has to reach the OPERATION nodes too, not just the path items. The\n // in-place branch strips a surviving operation's pin through\n // `[\"paths\", p, m, x-loam-based-on]`, and an aliased operation is exactly one\n // level below where the check used to look — so `deleteIn` walked into a node\n // that is not a collection and threw out of archive as `internal`, on a\n // document whose only fault was writing one operation twice.\n //\n // What disqualifies a method is \"there is something here to strip and I cannot\n // reach it\", not \"this is not a map node\". Only a resolved MAPPING can be a\n // removal marker or carry a pin, so a method spelled as a scalar — `get: ~`,\n // or a string — is nothing the in-place branch would have touched; demanding a\n // map node of it too demoted whole documents to the rewrite branch and cost\n // their author every comment, anchor and hand-chosen key order inside `paths`,\n // in the bytes archive installs as the living contract. What is left is the\n // real hazard: a mapping the AST does not hand back as a map. An alias is the\n // one node kind that resolves to a mapping without being one, and a method\n // whose KEY is an alias is not findable by name at all, so `deleteIn` reports\n // nothing deleted and the marker ships in silence. Both answer `undefined` or\n // a non-map here, and both belong on the safe branch.\n const editable =\n isMap(feature.get(\"paths\")) &&\n Object.entries(paths).every(\n ([p, item]) =>\n isMap(feature.getIn([\"paths\", p])) &&\n (!isRecord(item) ||\n Object.entries(item).every(\n ([m, op]) => !HTTP_METHODS.has(m) || !isRecord(op) || isMap(feature.getIn([\"paths\", p, m])),\n )),\n );\n if (!editable) {\n feature.setIn([\"paths\"], cleaned);\n } else {\n for (const [path, item] of Object.entries(paths)) {\n if (!isRecord(item)) continue;\n for (const [m, value] of Object.entries(item)) {\n // A loam marker at PATH level, deleted here for the same reason the\n // resolved-tree branch drops it: the two branches must agree exactly\n // about what a living contract may carry.\n if (FEATURE_ONLY_KEYS.has(m)) feature.deleteIn([\"paths\", path, m]);\n if (!HTTP_METHODS.has(m)) continue;\n if (isRemoval(value)) feature.deleteIn([\"paths\", path, m]);\n // The surviving operations keep their formatting but lose their pin:\n // the in-place branch must strip everything the resolved-tree branch\n // does, or the two disagree about what a living contract may carry.\n else if (operationBaselineOf(value) !== undefined) {\n feature.deleteIn([\"paths\", path, m, OPENAPI_BASELINE_KEY]);\n }\n }\n const remaining = feature.getIn([\"paths\", path]);\n if (isMap(remaining) && remaining.items.length === 0) feature.deleteIn([\"paths\", path]);\n }\n }\n try {\n return feature.toString();\n } catch (error) {\n throw new OpenapiMergeError(\"feature\", service, errorMessage(error));\n }\n}\n\n/**\n * Merge the feature's `paths` into the living OpenAPI structurally (YAML AST, not\n * text splicing). A feature document without paths is a successful no-op.\n * The merged operations' local component-ref closure rides along recursively;\n * external refs are left untouched and never gated.\n *\n * Every SHAPE question — is there a `paths` mapping, is this path item a\n * mapping, which methods does it hold — is answered from the RESOLVED plain\n * trees, never from the AST node. Asking the AST (`isMap(node)`) answers a\n * different question: an alias node is not a map even when it resolves to one.\n * `paths: *alias` therefore read as \"no paths to merge\" and the whole contract\n * delta was dropped with a successful exit, and an aliased path ITEM fell into\n * the wholesale-replace branch and deleted every living operation on that path\n * that the alias did not restate. Aliases are legal OpenAPI and the natural way\n * to write a delta that repeats a shape; nothing here may treat them as absent.\n * An alias that cannot be resolved at all is a document loam cannot read, and\n * says so — it is never \"nothing to merge\".\n */\nexport function mergeOpenapiPaths(\n livingText: string,\n featureText: string,\n service: string,\n): OpenapiMergeResult {\n const feature = parseDocument(featureText);\n if (feature.errors.length > 0) {\n throw new OpenapiMergeError(\"feature\", service, feature.errors[0]!.message);\n }\n let featPlain: unknown;\n try {\n // Resolve aliases once with the document's own anchor context. Calling an\n // individual AST node's toJSON() loses that context and can silently turn\n // an aliased operation or component into the wrong value.\n featPlain = feature.toJS() ?? {};\n } catch (error) {\n throw new OpenapiMergeError(\"feature\", service, errorMessage(error));\n }\n const featPathsPlain = plainChild(featPlain, \"paths\");\n if (featPathsPlain === undefined || featPathsPlain === null) {\n return noop();\n }\n if (!isRecord(featPathsPlain)) {\n throw new OpenapiMergeError(\"feature\", service, \"`paths` is not a mapping\");\n }\n const featPathEntries = Object.entries(featPathsPlain);\n if (featPathEntries.length === 0) return noop();\n\n const living = parseDocument(livingText);\n if (living.errors.length > 0) {\n throw new OpenapiMergeError(\"living\", service, living.errors[0]!.message);\n }\n let livingPlain: unknown;\n try {\n livingPlain = living.toJS() ?? {};\n } catch (error) {\n throw new OpenapiMergeError(\"living\", service, errorMessage(error));\n }\n const livingPathsPlain = plainChild(livingPlain, \"paths\");\n if (livingPathsPlain !== undefined && livingPathsPlain !== null && !isRecord(livingPathsPlain)) {\n throw new OpenapiMergeError(\"living\", service, \"`paths` is not a mapping\");\n }\n const modified: string[] = [];\n const pathItemModified: string[] = [];\n const removed: string[] = [];\n const quoted: string[] = [];\n const baselineStale: string[] = [];\n for (const [path, featItemPlain] of featPathEntries) {\n const existing = living.getIn([\"paths\", path]);\n const existingPlain = plainChild(livingPathsPlain, path);\n if (existing !== undefined && !isRecord(existingPlain)) {\n // The living contract holds this path as something other than a path\n // item. Replacing it wholesale is the one branch that may delete living\n // operations without naming them, so it is reserved for paths the living\n // contract does not have at all.\n throw new OpenapiMergeError(\"living\", service, `path '${path}' is not a mapping`);\n }\n if (existing !== undefined) {\n if (!isRecord(featItemPlain)) {\n throw new OpenapiMergeError(\"feature\", service, `path '${path}' is not a mapping`);\n }\n // EVERY branch publishes through withoutFeatureMarkers. This one used to\n // copy every key of the feature path item and guard only the HTTP\n // methods, so a path-level `x-loam-remove` landed in the living contract\n // with `modified: []` and no warning. A key the strip drops is never\n // written; the removal handling below still reads the RAW item, because\n // that is where the markers it acts on live.\n const publish = withoutFeatureMarkers(featItemPlain);\n const publishable = isRecord(publish) ? publish : {};\n for (const [m, afterPlain] of Object.entries(featItemPlain)) {\n const before = living.getIn([\"paths\", path, m]);\n const beforePlain = plainChild(existingPlain, m);\n if (HTTP_METHODS.has(m) && isRemoval(afterPlain)) {\n // Coherence validates the marker and gates absent/mismatched targets.\n // The merge remains defensive under --approve: never delete a\n // different operation merely because it occupies the requested slot.\n if (\n before !== undefined &&\n operationIdOf(beforePlain) !== undefined &&\n operationIdOf(beforePlain) === operationIdOf(afterPlain)\n ) {\n removed.push(opLabel(beforePlain, afterPlain, m, path));\n living.deleteIn([\"paths\", path, m]);\n }\n continue;\n }\n if (HTTP_METHODS.has(m)) {\n const verdict = classifyOperationBaseline(afterPlain, before === undefined ? undefined : beforePlain);\n // A QUOTE is not a merge input. The author wrote this operation down\n // because the document is complete, not because they changed it, so\n // the living contract keeps whatever it holds — including a change\n // that landed after this delta was written. This is mechanical, not a\n // judgement, so `--approve` does not turn it back on: overriding a\n // gate is a decision, reverting an operation nobody edited is a bug.\n if (verdict === \"quote\") {\n quoted.push(opLabel(beforePlain, afterPlain, m, path));\n continue;\n }\n if (verdict === \"stale\") baselineStale.push(opLabel(beforePlain, afterPlain, m, path));\n }\n if (!(m in publishable)) {\n // A feature-only marker at path level. It is never published, and\n // never reported as a path-item overwrite either — it is not a key of\n // the contract at all. The archive gate names it to the author.\n continue;\n }\n // The difference check covers EVERY key of the path item; only the\n // LABEL depends on whether the key is an HTTP method.\n if (before !== undefined && !isDeepStrictEqual(beforePlain, afterPlain)) {\n if (HTTP_METHODS.has(m)) modified.push(opLabel(beforePlain, afterPlain, m, path));\n else pathItemModified.push(`'${m}' (${path})`);\n }\n // Every shape question above was answered from the RESOLVED tree, which\n // is exactly what makes an aliased path item read as an ordinary\n // mapping. The WRITE cannot be that forgiving: `setIn` walks the AST,\n // and one shared value backs every use of an anchor, so an operation\n // merged through the alias would land in every other path that\n // references it. There is no way to write into one use of an anchor and\n // not the rest, so this is a refusal rather than a fallback — and it is\n // asked here, at the write, because reading is safe and writing is not.\n if (!isMap(living.getIn([\"paths\", path]))) {\n throw new OpenapiMergeError(\n \"living\",\n service,\n `path '${path}' is written as a YAML alias — one shared value backs every use, so merging into it would rewrite every other path that aliases it. Expand it before archiving.`,\n );\n }\n // Without the strip the living contract would grow a pin to a version\n // of itself, and the NEXT feature's baseline would hash it.\n living.setIn([\"paths\", path, m], publishable[m]);\n }\n // Removing the last method leaves `\\/x: {}` — a path the contract still\n // advertises and nothing answers. The same cleanup\n // stripOpenapiRemovalMarkers already does on the feature side.\n const remaining = living.getIn([\"paths\", path]);\n if (isMap(remaining) && remaining.items.length === 0) living.deleteIn([\"paths\", path]);\n continue;\n }\n if (!isRecord(featItemPlain)) {\n throw new OpenapiMergeError(\"feature\", service, `path '${path}' is not a mapping`);\n }\n const clean = withoutFeatureMarkers(featItemPlain);\n if (clean !== undefined) living.setIn([\"paths\", path], clean);\n }\n\n const componentsModified: string[] = [];\n const unresolved: OpenapiMergeResult[\"unresolved\"] = [];\n const visited = new Set<string>();\n const copies: Array<{ kind: string; name: string; value: unknown }> = [];\n\n const visitRef = (ref: string, from: string): void => {\n if (!ref.startsWith(\"#/\")) return;\n const match = /^#\\/components\\/([^/]+)\\/([^/]+)(?:\\/|$)/.exec(ref);\n if (!match) {\n if (!resolvePointer(featPlain, ref).found && !resolvePointer(livingPlain, ref).found) {\n unresolved.push({ ref, from });\n }\n return;\n }\n const kind = match[1]!;\n const name = match[2]!;\n const key = `${kind}/${name}`;\n if (visited.has(key)) return;\n visited.add(key);\n const inFeature = resolvePointer(featPlain, `#/components/${kind}/${name}`);\n if (inFeature.found) {\n copies.push({ kind, name, value: inFeature.value });\n walk(inFeature.value, `components/${key}`);\n return;\n }\n if (!resolvePointer(livingPlain, `#/components/${kind}/${name}`).found) {\n unresolved.push({ ref, from });\n }\n };\n\n const walk = (node: unknown, from: string): void => {\n for (const ref of collectRefs(node)) visitRef(ref, from);\n };\n\n for (const [path, featItemPlain] of featPathEntries) {\n walk(withoutFeatureMarkers(featItemPlain), `paths ${path}`);\n }\n\n for (const { kind, name, value } of copies) {\n const existing = living.getIn([\"components\", kind, name]);\n if (existing !== undefined) {\n const existingPlain = resolvePointer(livingPlain, `#/components/${kind}/${name}`);\n if (existingPlain.found && isDeepStrictEqual(existingPlain.value, value)) continue;\n componentsModified.push(`${kind}/${name}`);\n }\n living.setIn([\"components\", kind, name], value);\n }\n\n let text: string;\n try {\n text = living.toString();\n } catch (error) {\n throw new OpenapiMergeError(\"living\", service, errorMessage(error));\n }\n return { text, modified, pathItemModified, removed, quoted, baselineStale, componentsModified, unresolved };\n}\n\n/** The successful \"the feature document has nothing to merge\" answer. */\nfunction noop(): OpenapiMergeResult {\n return {\n text: null,\n modified: [],\n pathItemModified: [],\n removed: [],\n quoted: [],\n baselineStale: [],\n componentsModified: [],\n unresolved: [],\n };\n}\n\n/** Every `$ref` string value anywhere in a plain JS tree, in document order. */\nexport function collectRefs(node: unknown): string[] {\n const out: string[] = [];\n const walk = (current: unknown): void => {\n if (Array.isArray(current)) {\n for (const value of current) walk(value);\n return;\n }\n if (current !== null && typeof current === \"object\") {\n for (const [key, value] of Object.entries(current)) {\n if (key === \"$ref\" && typeof value === \"string\") out.push(value);\n else walk(value);\n }\n }\n };\n walk(node);\n return out;\n}\n\n/** Resolve a local JSON pointer (`#/a/b~1c`) against a plain JS tree. */\nexport function resolvePointer(root: unknown, ref: string): { found: boolean; value: unknown } {\n let current: unknown = root;\n for (const raw of ref.slice(2).split(\"/\")) {\n const segment = raw.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n if (Array.isArray(current)) {\n const index = Number(segment);\n if (!Number.isInteger(index) || index < 0 || index >= current.length) {\n return { found: false, value: undefined };\n }\n current = current[index];\n } else if (current !== null && typeof current === \"object\" && segment in (current as Record<string, unknown>)) {\n current = (current as Record<string, unknown>)[segment];\n } else {\n return { found: false, value: undefined };\n }\n }\n return { found: true, value: current };\n}\n\n/** Name an overwritten operation by its operationId (feature's, else living's), or path+method. */\nfunction opLabel(before: unknown, after: unknown, method: string, path: string): string {\n const operation = operationIdOf(after) ?? operationIdOf(before);\n return operation !== undefined ? `'${operation}' (${method} ${path})` : `${method} ${path}`;\n}\n\n/** Is this operation node a feature-only explicit removal marker? */\nfunction isRemoval(node: unknown): boolean {\n return node !== null &&\n typeof node === \"object\" &&\n (node as Record<string, unknown>)[\"x-loam-remove\"] === true;\n}\n\n/** Read an operationId from a YAML or plain operation node. */\nfunction operationIdOf(node: unknown): string | undefined {\n const value = isMap(node)\n ? node.get(\"operationId\")\n : node !== null && typeof node === \"object\"\n ? (node as Record<string, unknown>)[\"operationId\"]\n : undefined;\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n}\n\n/**\n * Every key that is an instruction to loam rather than part of the contract.\n * At PATH level neither has any meaning — `x-loam-remove` addresses one\n * operation and `x-loam-based-on` pins one — so a path item carrying either is\n * an authoring mistake, and one that must not be published whatever else is\n * done about it.\n */\nconst FEATURE_ONLY_KEYS = new Set([\"x-loam-remove\", OPENAPI_BASELINE_KEY]);\n\n/**\n * Copy a path item without anything that belongs to the FEATURE rather than to\n * the contract: removal-marker operations, the `x-loam-based-on` pins on the\n * operations that survive, and a loam marker written at PATH level. All three\n * are instructions to loam, and a living contract that carries any of them is\n * lying to the next reader — and, for the pin, to the next feature's baseline.\n *\n * The path-level case used to fall through: the filter guarded only HTTP\n * methods, so `x-loam-remove: true` beside the methods was copied verbatim into\n * the fleet's living contract, where it also kept the empty-path cleanup from\n * ever seeing an empty path.\n */\nfunction withoutFeatureMarkers(node: unknown): unknown {\n if (node === null || typeof node !== \"object\" || Array.isArray(node)) return node;\n const entries = Object.entries(node as Record<string, unknown>)\n .filter(([key, value]) => !FEATURE_ONLY_KEYS.has(key) && !(HTTP_METHODS.has(key) && isRemoval(value)))\n .map(([key, value]) => [key, HTTP_METHODS.has(key) ? withoutOperationBaseline(value) : value] as const);\n return entries.length === 0 ? undefined : Object.fromEntries(entries);\n}\n\nfunction plainChild(parent: unknown, key: string): unknown {\n return parent !== null && typeof parent === \"object\"\n ? (parent as Record<string, unknown>)[key]\n : undefined;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"]}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { isUtf8 } from "node:buffer";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { parse } from "yaml";
|
|
6
|
+
import { featureSpecPaths, servicePaths } from "./repo.js";
|
|
7
|
+
/**
|
|
8
|
+
* The path-item keys that hold operations. A path item also carries `summary`,
|
|
9
|
+
* `parameters`, `servers` and vendor `x-*` extensions — an object-valued one with
|
|
10
|
+
* an `operationId` inside (x-legacy and friends) is not an operation, and a
|
|
11
|
+
* phantom id from it would make a broken contract look "available" to the
|
|
12
|
+
* op-exists checks. Shared with archive's merge, which asks the same question
|
|
13
|
+
* of the same keys.
|
|
14
|
+
*/
|
|
15
|
+
export const HTTP_METHODS = new Set(["get", "put", "post", "delete", "options", "head", "patch", "trace"]);
|
|
16
|
+
/**
|
|
17
|
+
* The baseline marker: which living version of this operation a FEATURE delta
|
|
18
|
+
* was written against. Same idea as a requirement's `Based-On:` (core/spec.ts),
|
|
19
|
+
* in the vendor-extension shape this axis already uses for `x-loam-remove`.
|
|
20
|
+
*
|
|
21
|
+
* This axis needs it MORE than the requirement axis does, because a feature's
|
|
22
|
+
* openapi.yaml is a COMPLETE document rather than a patch: authors restate the
|
|
23
|
+
* living contract around the slot they are changing, and the merge upserts every
|
|
24
|
+
* operation the document spells. So a feature that never meant to touch
|
|
25
|
+
* `refundOrder` — it merely quoted it — pushes its authoring-time copy back over
|
|
26
|
+
* whatever landed in between, reverting another team's shipped change without
|
|
27
|
+
* either feature overlapping the other at all. The pin is what lets the merge
|
|
28
|
+
* tell a QUOTE from an EDIT: a quote equals its own baseline, and is skipped.
|
|
29
|
+
*/
|
|
30
|
+
export const OPENAPI_BASELINE_KEY = "x-loam-based-on";
|
|
31
|
+
/** How much of the sha256 an `x-loam-based-on` carries — the length every loam digest uses. */
|
|
32
|
+
export const OPERATION_DIGEST_LENGTH = 16;
|
|
33
|
+
/** The value shape of an `x-loam-based-on`, exactly as `operationDigest` writes it. */
|
|
34
|
+
export const OPERATION_DIGEST_RE = new RegExp(`^[0-9a-f]{${OPERATION_DIGEST_LENGTH}}$`);
|
|
35
|
+
/**
|
|
36
|
+
* Canonical JSON for a resolved YAML value: object keys sorted, arrays left in
|
|
37
|
+
* order, everything else as JSON writes it.
|
|
38
|
+
*
|
|
39
|
+
* Key ORDER must not matter, because the merge's own idea of "this operation
|
|
40
|
+
* differs" is `isDeepStrictEqual` (core/openapi-merge.ts), which ignores it. A
|
|
41
|
+
* digest that disagreed with that comparison would go stale over a reordered
|
|
42
|
+
* `summary`/`operationId` pair the merge itself calls identical — a false
|
|
43
|
+
* collision on the one check whose worth is that it fires only for real ones.
|
|
44
|
+
*/
|
|
45
|
+
function canonicalJson(node) {
|
|
46
|
+
if (node === null || typeof node !== "object")
|
|
47
|
+
return JSON.stringify(node) ?? "null";
|
|
48
|
+
if (Array.isArray(node))
|
|
49
|
+
return `[${node.map(canonicalJson).join(",")}]`;
|
|
50
|
+
const entries = Object.entries(node)
|
|
51
|
+
.filter(([, value]) => value !== undefined)
|
|
52
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
53
|
+
return `{${entries.map(([key, value]) => `${JSON.stringify(key)}:${canonicalJson(value)}`).join(",")}}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The operation without its own baseline marker — what a digest is taken over,
|
|
57
|
+
* and what the merge writes.
|
|
58
|
+
*
|
|
59
|
+
* A pin is a statement ABOUT a delta, never part of the operation it describes.
|
|
60
|
+
* Inside the digest input, an operation's identity would depend on the pin
|
|
61
|
+
* pointing at it and no baseline could ever be self-consistent; inside the
|
|
62
|
+
* merged contract, a living operation would carry a pin to a version of itself
|
|
63
|
+
* and the next feature's baseline would hash the previous feature's bookkeeping.
|
|
64
|
+
*/
|
|
65
|
+
export function withoutOperationBaseline(node) {
|
|
66
|
+
if (node === null || typeof node !== "object" || Array.isArray(node))
|
|
67
|
+
return node;
|
|
68
|
+
const record = node;
|
|
69
|
+
if (!(OPENAPI_BASELINE_KEY in record))
|
|
70
|
+
return node;
|
|
71
|
+
const rest = { ...record };
|
|
72
|
+
delete rest[OPENAPI_BASELINE_KEY];
|
|
73
|
+
return rest;
|
|
74
|
+
}
|
|
75
|
+
/** The identity of an operation's CONTENT: sha256 of its canonical form, pin excluded. */
|
|
76
|
+
export function operationDigest(node) {
|
|
77
|
+
return createHash("sha256")
|
|
78
|
+
.update(canonicalJson(withoutOperationBaseline(node)), "utf8")
|
|
79
|
+
.digest("hex")
|
|
80
|
+
.slice(0, OPERATION_DIGEST_LENGTH);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* What a pin says, from digests alone — the one definition both the gate
|
|
84
|
+
* (core/coherence.ts, which has parsed Operations) and the merge
|
|
85
|
+
* (core/openapi-merge.ts, which has raw YAML trees) decide by. Two spellings of
|
|
86
|
+
* this rule would eventually disagree about which operations a merge writes,
|
|
87
|
+
* and the disagreement would be invisible until a contract came back wrong.
|
|
88
|
+
*
|
|
89
|
+
* Order matters: `quote` is settled against the delta's OWN content before the
|
|
90
|
+
* living contract is consulted. An operation equal to its own baseline was not
|
|
91
|
+
* edited, so what living holds now is nobody's business but the feature that
|
|
92
|
+
* put it there.
|
|
93
|
+
*/
|
|
94
|
+
export function classifyBaselineDigests(pin, ownDigest, livingDigest) {
|
|
95
|
+
if (pin === undefined)
|
|
96
|
+
return "unpinned";
|
|
97
|
+
if (livingDigest === undefined)
|
|
98
|
+
return "unfounded";
|
|
99
|
+
if (pin === ownDigest)
|
|
100
|
+
return "quote";
|
|
101
|
+
if (pin === livingDigest)
|
|
102
|
+
return "edit";
|
|
103
|
+
return "stale";
|
|
104
|
+
}
|
|
105
|
+
/** The `x-loam-based-on` a node declares, or undefined — non-strings included, so validate can refuse them. */
|
|
106
|
+
export function operationBaselineOf(node) {
|
|
107
|
+
if (node === null || typeof node !== "object" || Array.isArray(node))
|
|
108
|
+
return undefined;
|
|
109
|
+
const value = node[OPENAPI_BASELINE_KEY];
|
|
110
|
+
if (value === undefined)
|
|
111
|
+
return undefined;
|
|
112
|
+
return typeof value === "string" ? value.trim() : String(value);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Extract operations from an OpenAPI document by walking the parsed YAML
|
|
116
|
+
* structure (paths.<path>.<method>, method filtered to the HTTP set).
|
|
117
|
+
* Structure-aware on purpose: a regex scan both drops legal ids (kebab-case,
|
|
118
|
+
* dotted) and picks up phantom ids from description text. Each operation
|
|
119
|
+
* carries its id and its `deprecated: true` flag (exactly `true` counts —
|
|
120
|
+
* strings and truthy noise do not). `ops` is the defined set, keyed by the
|
|
121
|
+
* (path, method) SLOT — not by operationId.
|
|
122
|
+
*
|
|
123
|
+
* Keying by id used to drop the second slot claiming a name, which made the
|
|
124
|
+
* single most common contract edit invisible: relocating an endpoint is a
|
|
125
|
+
* removal marker at the old slot plus an upsert at the new one, the SAME
|
|
126
|
+
* operationId twice. Whichever came second in document order vanished, so
|
|
127
|
+
* either the marker addressed a slot loam could not see (`remove-target-missing`
|
|
128
|
+
* on a perfectly good delta) or the new definition did. Two slots claiming one
|
|
129
|
+
* id in a LIVING contract is a real ambiguity rather than a merge failure, so
|
|
130
|
+
* it rides out as `duplicateIds` for the caller to grade.
|
|
131
|
+
*
|
|
132
|
+
* An unreadable document yields [] ops PLUS the `unreadable` flag. Parsers
|
|
133
|
+
* never diagnose — the policy of every reader here — so the failure travels as
|
|
134
|
+
* a flag for validate to grade (`openapi.invalid`). Swallowing it into a bare
|
|
135
|
+
* [] made a broken contract indistinguishable from an EMPTY one, and the spine
|
|
136
|
+
* check then reported every inbound edge broken (`spine.op-undefined`) — a
|
|
137
|
+
* false diagnosis pointing at the landscape when the truth was this file.
|
|
138
|
+
*/
|
|
139
|
+
export async function readOpenapi(openapiPath, context) {
|
|
140
|
+
if (context !== undefined)
|
|
141
|
+
return context.readOpenapi(openapiPath);
|
|
142
|
+
if (!existsSync(openapiPath))
|
|
143
|
+
return empty();
|
|
144
|
+
const bytes = await readFile(openapiPath);
|
|
145
|
+
// A contract whose bytes are not UTF-8 is as unreadable as broken YAML, and
|
|
146
|
+
// for a worse reason: `toString("utf8")` would substitute U+FFFD and hand the
|
|
147
|
+
// parser a document nobody wrote. It travels as `unreadable` so validate
|
|
148
|
+
// grades it `openapi.invalid` — the file is the error, and every check that
|
|
149
|
+
// reads the contract stays suspended.
|
|
150
|
+
if (!isUtf8(bytes))
|
|
151
|
+
return { ...empty(), unreadable: true, error: "file is not valid UTF-8" };
|
|
152
|
+
let doc;
|
|
153
|
+
try {
|
|
154
|
+
doc = parse(bytes.toString("utf8"));
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
return { ...empty(), unreadable: true, error: e instanceof Error ? e.message : String(e) };
|
|
158
|
+
}
|
|
159
|
+
// A scalar or sequence document is as unreadable as broken YAML: there is no
|
|
160
|
+
// mapping to look `paths` up in, so nothing can be concluded from it. null
|
|
161
|
+
// (an empty file) stays readable — it defines nothing, and says so honestly.
|
|
162
|
+
if (doc !== null && (typeof doc !== "object" || Array.isArray(doc))) {
|
|
163
|
+
return { ...empty(), unreadable: true, error: "document is not a YAML mapping" };
|
|
164
|
+
}
|
|
165
|
+
const paths = doc?.paths;
|
|
166
|
+
if (!paths || typeof paths !== "object")
|
|
167
|
+
return empty();
|
|
168
|
+
const ops = [];
|
|
169
|
+
const anonymousRemovals = [];
|
|
170
|
+
const pathLevelRemovals = [];
|
|
171
|
+
const seen = new Map();
|
|
172
|
+
for (const [path, item] of Object.entries(paths)) {
|
|
173
|
+
if (!item || typeof item !== "object")
|
|
174
|
+
continue;
|
|
175
|
+
if (item["x-loam-remove"] === true)
|
|
176
|
+
pathLevelRemovals.push(path);
|
|
177
|
+
for (const [method, op] of Object.entries(item)) {
|
|
178
|
+
if (!HTTP_METHODS.has(method))
|
|
179
|
+
continue;
|
|
180
|
+
if (!op || typeof op !== "object")
|
|
181
|
+
continue;
|
|
182
|
+
const id = op["operationId"];
|
|
183
|
+
const remove = op["x-loam-remove"] === true;
|
|
184
|
+
if (typeof id !== "string" || id.length === 0) {
|
|
185
|
+
if (remove)
|
|
186
|
+
anonymousRemovals.push({ path, method });
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
seen.set(id, (seen.get(id) ?? 0) + 1);
|
|
190
|
+
const basedOn = operationBaselineOf(op);
|
|
191
|
+
ops.push({
|
|
192
|
+
id,
|
|
193
|
+
deprecated: op["deprecated"] === true,
|
|
194
|
+
remove,
|
|
195
|
+
path,
|
|
196
|
+
method,
|
|
197
|
+
digest: operationDigest(op),
|
|
198
|
+
...(basedOn === undefined ? {} : { basedOn }),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const duplicateIds = [...seen].filter(([, n]) => n > 1).map(([id]) => id);
|
|
203
|
+
return { ops, duplicateIds, anonymousRemovals, pathLevelRemovals, unreadable: false };
|
|
204
|
+
}
|
|
205
|
+
function empty() {
|
|
206
|
+
return { ops: [], duplicateIds: [], anonymousRemovals: [], pathLevelRemovals: [], unreadable: false };
|
|
207
|
+
}
|
|
208
|
+
/** The operations alone — for every caller whose own finding already covers the unreadable case. */
|
|
209
|
+
export async function operations(openapiPath, context) {
|
|
210
|
+
return (await readOpenapi(openapiPath, context)).ops;
|
|
211
|
+
}
|
|
212
|
+
/** The operationIds alone — `operations` for every caller that asks only "does it exist". */
|
|
213
|
+
export async function operationIds(openapiPath, context) {
|
|
214
|
+
return (await operations(openapiPath, context)).map((o) => o.id);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The operationIds a service will provide after a feature is applied: living
|
|
218
|
+
* operations, plus feature upserts, minus explicit feature removals.
|
|
219
|
+
*
|
|
220
|
+
* Removals are applied BEFORE upserts, which is what makes the answer
|
|
221
|
+
* independent of the order the feature's document happens to spell them in.
|
|
222
|
+
* Interleaving them one operation at a time meant a relocation — the same id
|
|
223
|
+
* removed from `/old` and defined on `/new` — answered "defined" or "gone"
|
|
224
|
+
* depending on which path sorted first in the YAML, and the requirement
|
|
225
|
+
* governing it was reported undefined (`spec-api.op-undefined`) on exactly one
|
|
226
|
+
* of the two spellings of the same change.
|
|
227
|
+
*
|
|
228
|
+
* A context is threaded into the READS and never asked for the answer. It used
|
|
229
|
+
* to own a second copy of this function, and that copy interleaved removals
|
|
230
|
+
* with upserts — the exact bug the paragraph above describes as fixed. So the
|
|
231
|
+
* commands that pass a context (`validate`, `status`) and the one that does not
|
|
232
|
+
* (`archive`) disagreed about whether a relocated operation still existed, and
|
|
233
|
+
* `spec-api.op-undefined` — an error that gates archive — fired or not
|
|
234
|
+
* depending on which path key the author happened to type first. Memoising is
|
|
235
|
+
* the context's job; the ordering rule is this function's, and there is one of
|
|
236
|
+
* it.
|
|
237
|
+
*/
|
|
238
|
+
export async function serviceOperationIds(docsDir, service, featureDir, context) {
|
|
239
|
+
const ids = new Set((await operations(servicePaths(docsDir, service).openapi, context)).filter((op) => !op.remove).map((op) => op.id));
|
|
240
|
+
// Absence is `undefined`, the shape the optional parameter declares. The
|
|
241
|
+
// truthiness test also read "" as "no feature", which is a caller mistake
|
|
242
|
+
// worth surfacing rather than answering as though the feature carried no
|
|
243
|
+
// contract delta.
|
|
244
|
+
if (featureDir !== undefined) {
|
|
245
|
+
const featOps = await operations(featureSpecPaths(featureDir, service).openapi, context);
|
|
246
|
+
for (const op of featOps)
|
|
247
|
+
if (op.remove)
|
|
248
|
+
ids.delete(op.id);
|
|
249
|
+
for (const op of featOps)
|
|
250
|
+
if (!op.remove)
|
|
251
|
+
ids.add(op.id);
|
|
252
|
+
}
|
|
253
|
+
return [...ids];
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=openapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../src/core/openapi.ts"],"names":[],"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AyE;IACzE,kBAAkB;IAClB,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACzF,KAAK,MAAM,EAAE,IAAI,OAAO;YAAE,IAAI,EAAE,CAAC,MAAM;gBAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC3D,KAAK,MAAM,EAAE,IAAI,OAAO;YAAE,IAAI,CAAC,EAAE,CAAC,MAAM;gBAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;AAClB,CAAC","sourcesContent":["import { isUtf8 } from \"node:buffer\";\nimport { createHash } from \"node:crypto\";\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { parse } from \"yaml\";\nimport type { FleetContext } from \"./fleet-context.js\";\nimport { featureSpecPaths, servicePaths } from \"./repo.js\";\n\n/**\n * The path-item keys that hold operations. A path item also carries `summary`,\n * `parameters`, `servers` and vendor `x-*` extensions — an object-valued one with\n * an `operationId` inside (x-legacy and friends) is not an operation, and a\n * phantom id from it would make a broken contract look \"available\" to the\n * op-exists checks. Shared with archive's merge, which asks the same question\n * of the same keys.\n */\nexport const HTTP_METHODS = new Set([\"get\", \"put\", \"post\", \"delete\", \"options\", \"head\", \"patch\", \"trace\"]);\n\n/**\n * The baseline marker: which living version of this operation a FEATURE delta\n * was written against. Same idea as a requirement's `Based-On:` (core/spec.ts),\n * in the vendor-extension shape this axis already uses for `x-loam-remove`.\n *\n * This axis needs it MORE than the requirement axis does, because a feature's\n * openapi.yaml is a COMPLETE document rather than a patch: authors restate the\n * living contract around the slot they are changing, and the merge upserts every\n * operation the document spells. So a feature that never meant to touch\n * `refundOrder` — it merely quoted it — pushes its authoring-time copy back over\n * whatever landed in between, reverting another team's shipped change without\n * either feature overlapping the other at all. The pin is what lets the merge\n * tell a QUOTE from an EDIT: a quote equals its own baseline, and is skipped.\n */\nexport const OPENAPI_BASELINE_KEY = \"x-loam-based-on\";\n\n/** How much of the sha256 an `x-loam-based-on` carries — the length every loam digest uses. */\nexport const OPERATION_DIGEST_LENGTH = 16;\n\n/** The value shape of an `x-loam-based-on`, exactly as `operationDigest` writes it. */\nexport const OPERATION_DIGEST_RE = new RegExp(`^[0-9a-f]{${OPERATION_DIGEST_LENGTH}}$`);\n\n/**\n * Canonical JSON for a resolved YAML value: object keys sorted, arrays left in\n * order, everything else as JSON writes it.\n *\n * Key ORDER must not matter, because the merge's own idea of \"this operation\n * differs\" is `isDeepStrictEqual` (core/openapi-merge.ts), which ignores it. A\n * digest that disagreed with that comparison would go stale over a reordered\n * `summary`/`operationId` pair the merge itself calls identical — a false\n * collision on the one check whose worth is that it fires only for real ones.\n */\nfunction canonicalJson(node: unknown): string {\n if (node === null || typeof node !== \"object\") return JSON.stringify(node) ?? \"null\";\n if (Array.isArray(node)) return `[${node.map(canonicalJson).join(\",\")}]`;\n const entries = Object.entries(node as Record<string, unknown>)\n .filter(([, value]) => value !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n return `{${entries.map(([key, value]) => `${JSON.stringify(key)}:${canonicalJson(value)}`).join(\",\")}}`;\n}\n\n/**\n * The operation without its own baseline marker — what a digest is taken over,\n * and what the merge writes.\n *\n * A pin is a statement ABOUT a delta, never part of the operation it describes.\n * Inside the digest input, an operation's identity would depend on the pin\n * pointing at it and no baseline could ever be self-consistent; inside the\n * merged contract, a living operation would carry a pin to a version of itself\n * and the next feature's baseline would hash the previous feature's bookkeeping.\n */\nexport function withoutOperationBaseline(node: unknown): unknown {\n if (node === null || typeof node !== \"object\" || Array.isArray(node)) return node;\n const record = node as Record<string, unknown>;\n if (!(OPENAPI_BASELINE_KEY in record)) return node;\n const rest = { ...record };\n delete rest[OPENAPI_BASELINE_KEY];\n return rest;\n}\n\n/** The identity of an operation's CONTENT: sha256 of its canonical form, pin excluded. */\nexport function operationDigest(node: unknown): string {\n return createHash(\"sha256\")\n .update(canonicalJson(withoutOperationBaseline(node)), \"utf8\")\n .digest(\"hex\")\n .slice(0, OPERATION_DIGEST_LENGTH);\n}\n\n/**\n * What a pin says, from digests alone — the one definition both the gate\n * (core/coherence.ts, which has parsed Operations) and the merge\n * (core/openapi-merge.ts, which has raw YAML trees) decide by. Two spellings of\n * this rule would eventually disagree about which operations a merge writes,\n * and the disagreement would be invisible until a contract came back wrong.\n *\n * Order matters: `quote` is settled against the delta's OWN content before the\n * living contract is consulted. An operation equal to its own baseline was not\n * edited, so what living holds now is nobody's business but the feature that\n * put it there.\n */\nexport function classifyBaselineDigests(\n pin: string | undefined,\n ownDigest: string,\n livingDigest: string | undefined,\n): \"unpinned\" | \"quote\" | \"edit\" | \"stale\" | \"unfounded\" {\n if (pin === undefined) return \"unpinned\";\n if (livingDigest === undefined) return \"unfounded\";\n if (pin === ownDigest) return \"quote\";\n if (pin === livingDigest) return \"edit\";\n return \"stale\";\n}\n\n/** The `x-loam-based-on` a node declares, or undefined — non-strings included, so validate can refuse them. */\nexport function operationBaselineOf(node: unknown): string | undefined {\n if (node === null || typeof node !== \"object\" || Array.isArray(node)) return undefined;\n const value = (node as Record<string, unknown>)[OPENAPI_BASELINE_KEY];\n if (value === undefined) return undefined;\n return typeof value === \"string\" ? value.trim() : String(value);\n}\n\n/** One operation as the reader sees it, including loam's feature-only removal marker. */\nexport interface Operation {\n id: string;\n /**\n * The standard per-operation OpenAPI `deprecated` flag — lifecycle\n * visibility, the documented first step of retiring an op.\n */\n deprecated: boolean;\n /**\n * `x-loam-remove: true` asks a FEATURE delta to remove this exact operation\n * on archive. The marker is never a callable operation and is illegal in a\n * living contract.\n */\n remove: boolean;\n /** Exact slot the marker/upsert addresses; removal is deliberately path+method-safe. */\n path: string;\n method: string;\n /**\n * `operationDigest` of this operation as it stands in ITS OWN document —\n * computed here so every caller compares content the one way the merge does.\n */\n digest: string;\n /**\n * The living version this operation was written against, from\n * `x-loam-based-on`. Feature deltas only: a living contract never carries one\n * (the merge strips it), and an adopted contract never had one.\n */\n basedOn?: string;\n}\n\n/** A `x-loam-remove: true` marker with no usable operationId — a slot named but no operation named. */\nexport interface AnonymousRemoval {\n path: string;\n method: string;\n}\n\n/** The parse of one OpenAPI document: its operations, and whether the file could be read at all. */\nexport interface OpenapiDoc {\n ops: Operation[];\n /**\n * operationIds this document defines in more than one (path, method) slot.\n * A LIVING contract with two slots claiming one id is ambiguous to every\n * check that joins on the id — a requirement's `Operations:` line, an edge's\n * `metadata { op }`, a removal marker — and the join silently picks one.\n */\n duplicateIds: string[];\n /**\n * Removal markers the operation reader cannot name. They are invisible to\n * every id-keyed check, so a delta carrying one used to archive cleanly and\n * write `x-loam-remove: true` straight into a living contract.\n */\n anonymousRemovals: AnonymousRemoval[];\n /**\n * Paths carrying `x-loam-remove: true` at PATH level, beside the methods\n * rather than inside one.\n *\n * Not an operation, so nothing keyed by (path, method) could see it — and this\n * reader is method-keyed like the merge was. A marker written there addressed\n * no operation, so archive copied it into the living contract verbatim, where\n * it was invisible to `openapi.remove-marker-living` for the same reason and\n * kept the empty-path cleanup from ever firing. Reported as its own list\n * because the answer differs by document: in a FEATURE delta it is an\n * authoring mistake, in a LIVING contract it is a marker that must never have\n * been published.\n */\n pathLevelRemovals: string[];\n /**\n * True when the file EXISTS but cannot be read as an OpenAPI document —\n * broken YAML, or a document that is not a mapping. A missing file is not\n * unreadable (absence is `service.no-openapi`'s question), and an empty one\n * parses to null and honestly defines nothing.\n */\n unreadable: boolean;\n /** The parser's own message, when there is one to quote back. */\n error?: string;\n}\n\n/**\n * Extract operations from an OpenAPI document by walking the parsed YAML\n * structure (paths.<path>.<method>, method filtered to the HTTP set).\n * Structure-aware on purpose: a regex scan both drops legal ids (kebab-case,\n * dotted) and picks up phantom ids from description text. Each operation\n * carries its id and its `deprecated: true` flag (exactly `true` counts —\n * strings and truthy noise do not). `ops` is the defined set, keyed by the\n * (path, method) SLOT — not by operationId.\n *\n * Keying by id used to drop the second slot claiming a name, which made the\n * single most common contract edit invisible: relocating an endpoint is a\n * removal marker at the old slot plus an upsert at the new one, the SAME\n * operationId twice. Whichever came second in document order vanished, so\n * either the marker addressed a slot loam could not see (`remove-target-missing`\n * on a perfectly good delta) or the new definition did. Two slots claiming one\n * id in a LIVING contract is a real ambiguity rather than a merge failure, so\n * it rides out as `duplicateIds` for the caller to grade.\n *\n * An unreadable document yields [] ops PLUS the `unreadable` flag. Parsers\n * never diagnose — the policy of every reader here — so the failure travels as\n * a flag for validate to grade (`openapi.invalid`). Swallowing it into a bare\n * [] made a broken contract indistinguishable from an EMPTY one, and the spine\n * check then reported every inbound edge broken (`spine.op-undefined`) — a\n * false diagnosis pointing at the landscape when the truth was this file.\n */\nexport async function readOpenapi(openapiPath: string, context?: FleetContext): Promise<OpenapiDoc> {\n if (context !== undefined) return context.readOpenapi(openapiPath);\n if (!existsSync(openapiPath)) return empty();\n const bytes = await readFile(openapiPath);\n // A contract whose bytes are not UTF-8 is as unreadable as broken YAML, and\n // for a worse reason: `toString(\"utf8\")` would substitute U+FFFD and hand the\n // parser a document nobody wrote. It travels as `unreadable` so validate\n // grades it `openapi.invalid` — the file is the error, and every check that\n // reads the contract stays suspended.\n if (!isUtf8(bytes)) return { ...empty(), unreadable: true, error: \"file is not valid UTF-8\" };\n let doc: unknown;\n try {\n doc = parse(bytes.toString(\"utf8\"));\n } catch (e) {\n return { ...empty(), unreadable: true, error: e instanceof Error ? e.message : String(e) };\n }\n // A scalar or sequence document is as unreadable as broken YAML: there is no\n // mapping to look `paths` up in, so nothing can be concluded from it. null\n // (an empty file) stays readable — it defines nothing, and says so honestly.\n if (doc !== null && (typeof doc !== \"object\" || Array.isArray(doc))) {\n return { ...empty(), unreadable: true, error: \"document is not a YAML mapping\" };\n }\n const paths = (doc as { paths?: unknown } | null)?.paths;\n if (!paths || typeof paths !== \"object\") return empty();\n const ops: Operation[] = [];\n const anonymousRemovals: AnonymousRemoval[] = [];\n const pathLevelRemovals: string[] = [];\n const seen = new Map<string, number>();\n for (const [path, item] of Object.entries(paths as Record<string, unknown>)) {\n if (!item || typeof item !== \"object\") continue;\n if ((item as Record<string, unknown>)[\"x-loam-remove\"] === true) pathLevelRemovals.push(path);\n for (const [method, op] of Object.entries(item as Record<string, unknown>)) {\n if (!HTTP_METHODS.has(method)) continue;\n if (!op || typeof op !== \"object\") continue;\n const id = (op as Record<string, unknown>)[\"operationId\"];\n const remove = (op as Record<string, unknown>)[\"x-loam-remove\"] === true;\n if (typeof id !== \"string\" || id.length === 0) {\n if (remove) anonymousRemovals.push({ path, method });\n continue;\n }\n seen.set(id, (seen.get(id) ?? 0) + 1);\n const basedOn = operationBaselineOf(op);\n ops.push({\n id,\n deprecated: (op as Record<string, unknown>)[\"deprecated\"] === true,\n remove,\n path,\n method,\n digest: operationDigest(op),\n ...(basedOn === undefined ? {} : { basedOn }),\n });\n }\n }\n const duplicateIds = [...seen].filter(([, n]) => n > 1).map(([id]) => id);\n return { ops, duplicateIds, anonymousRemovals, pathLevelRemovals, unreadable: false };\n}\n\nfunction empty(): OpenapiDoc {\n return { ops: [], duplicateIds: [], anonymousRemovals: [], pathLevelRemovals: [], unreadable: false };\n}\n\n/** The operations alone — for every caller whose own finding already covers the unreadable case. */\nexport async function operations(openapiPath: string, context?: FleetContext): Promise<Operation[]> {\n return (await readOpenapi(openapiPath, context)).ops;\n}\n\n/** The operationIds alone — `operations` for every caller that asks only \"does it exist\". */\nexport async function operationIds(openapiPath: string, context?: FleetContext): Promise<string[]> {\n return (await operations(openapiPath, context)).map((o) => o.id);\n}\n\n/**\n * The operationIds a service will provide after a feature is applied: living\n * operations, plus feature upserts, minus explicit feature removals.\n *\n * Removals are applied BEFORE upserts, which is what makes the answer\n * independent of the order the feature's document happens to spell them in.\n * Interleaving them one operation at a time meant a relocation — the same id\n * removed from `/old` and defined on `/new` — answered \"defined\" or \"gone\"\n * depending on which path sorted first in the YAML, and the requirement\n * governing it was reported undefined (`spec-api.op-undefined`) on exactly one\n * of the two spellings of the same change.\n *\n * A context is threaded into the READS and never asked for the answer. It used\n * to own a second copy of this function, and that copy interleaved removals\n * with upserts — the exact bug the paragraph above describes as fixed. So the\n * commands that pass a context (`validate`, `status`) and the one that does not\n * (`archive`) disagreed about whether a relocated operation still existed, and\n * `spec-api.op-undefined` — an error that gates archive — fired or not\n * depending on which path key the author happened to type first. Memoising is\n * the context's job; the ordering rule is this function's, and there is one of\n * it.\n */\nexport async function serviceOperationIds(\n docsDir: string,\n service: string,\n featureDir?: string,\n context?: FleetContext,\n): Promise<string[]> {\n const ids = new Set(\n (await operations(servicePaths(docsDir, service).openapi, context)).filter((op) => !op.remove).map((op) => op.id),\n );\n // Absence is `undefined`, the shape the optional parameter declares. The\n // truthiness test also read \"\" as \"no feature\", which is a caller mistake\n // worth surfacing rather than answering as though the feature carried no\n // contract delta.\n if (featureDir !== undefined) {\n const featOps = await operations(featureSpecPaths(featureDir, service).openapi, context);\n for (const op of featOps) if (op.remove) ids.delete(op.id);\n for (const op of featOps) if (!op.remove) ids.add(op.id);\n }\n return [...ids];\n}\n"]}
|