@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.
Files changed (126) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/COMPARISON.md +63 -0
  3. package/LICENSE +21 -0
  4. package/MIGRATING-from-OpenSpec.md +202 -0
  5. package/README.md +246 -9
  6. package/SCHEMA.md +425 -0
  7. package/SECURITY.md +9 -0
  8. package/dist/cli.js +142 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/commands/adopt.js +240 -0
  11. package/dist/commands/adopt.js.map +1 -0
  12. package/dist/commands/archive.js +1313 -0
  13. package/dist/commands/archive.js.map +1 -0
  14. package/dist/commands/delta.js +388 -0
  15. package/dist/commands/delta.js.map +1 -0
  16. package/dist/commands/dependencies.js +83 -0
  17. package/dist/commands/dependencies.js.map +1 -0
  18. package/dist/commands/docs-repo-gate.js +104 -0
  19. package/dist/commands/docs-repo-gate.js.map +1 -0
  20. package/dist/commands/doctor.js +85 -0
  21. package/dist/commands/doctor.js.map +1 -0
  22. package/dist/commands/explore.js +195 -0
  23. package/dist/commands/explore.js.map +1 -0
  24. package/dist/commands/format.js +17 -0
  25. package/dist/commands/format.js.map +1 -0
  26. package/dist/commands/gherkin.js +309 -0
  27. package/dist/commands/gherkin.js.map +1 -0
  28. package/dist/commands/init.js +250 -0
  29. package/dist/commands/init.js.map +1 -0
  30. package/dist/commands/instructions.js +70 -0
  31. package/dist/commands/instructions.js.map +1 -0
  32. package/dist/commands/list.js +291 -0
  33. package/dist/commands/list.js.map +1 -0
  34. package/dist/commands/migrate-openspec.js +950 -0
  35. package/dist/commands/migrate-openspec.js.map +1 -0
  36. package/dist/commands/new.js +413 -0
  37. package/dist/commands/new.js.map +1 -0
  38. package/dist/commands/rebase.js +356 -0
  39. package/dist/commands/rebase.js.map +1 -0
  40. package/dist/commands/show.js +320 -0
  41. package/dist/commands/show.js.map +1 -0
  42. package/dist/commands/status.js +254 -0
  43. package/dist/commands/status.js.map +1 -0
  44. package/dist/commands/unarchive.js +317 -0
  45. package/dist/commands/unarchive.js.map +1 -0
  46. package/dist/commands/validate.js +1591 -0
  47. package/dist/commands/validate.js.map +1 -0
  48. package/dist/commands/verify.js +775 -0
  49. package/dist/commands/verify.js.map +1 -0
  50. package/dist/commands/vouch.js +343 -0
  51. package/dist/commands/vouch.js.map +1 -0
  52. package/dist/core/agent.js +2065 -0
  53. package/dist/core/agent.js.map +1 -0
  54. package/dist/core/agents-stamp.js +68 -0
  55. package/dist/core/agents-stamp.js.map +1 -0
  56. package/dist/core/arch.js +130 -0
  57. package/dist/core/arch.js.map +1 -0
  58. package/dist/core/brief.js +733 -0
  59. package/dist/core/brief.js.map +1 -0
  60. package/dist/core/coherence.js +577 -0
  61. package/dist/core/coherence.js.map +1 -0
  62. package/dist/core/concurrency.js +51 -0
  63. package/dist/core/concurrency.js.map +1 -0
  64. package/dist/core/config.js +180 -0
  65. package/dist/core/config.js.map +1 -0
  66. package/dist/core/delta.js +476 -0
  67. package/dist/core/delta.js.map +1 -0
  68. package/dist/core/dependencies.js +356 -0
  69. package/dist/core/dependencies.js.map +1 -0
  70. package/dist/core/docs.js +144 -0
  71. package/dist/core/docs.js.map +1 -0
  72. package/dist/core/doctor.js +559 -0
  73. package/dist/core/doctor.js.map +1 -0
  74. package/dist/core/document-bytes.js +59 -0
  75. package/dist/core/document-bytes.js.map +1 -0
  76. package/dist/core/explore.js +225 -0
  77. package/dist/core/explore.js.map +1 -0
  78. package/dist/core/fleet-context.js +225 -0
  79. package/dist/core/fleet-context.js.map +1 -0
  80. package/dist/core/frontmatter.js +199 -0
  81. package/dist/core/frontmatter.js.map +1 -0
  82. package/dist/core/gherkin.js +463 -0
  83. package/dist/core/gherkin.js.map +1 -0
  84. package/dist/core/health.js +67 -0
  85. package/dist/core/health.js.map +1 -0
  86. package/dist/core/ids.js +122 -0
  87. package/dist/core/ids.js.map +1 -0
  88. package/dist/core/issue.js +9 -0
  89. package/dist/core/issue.js.map +1 -0
  90. package/dist/core/json.js +74 -0
  91. package/dist/core/json.js.map +1 -0
  92. package/dist/core/likec4.js +479 -0
  93. package/dist/core/likec4.js.map +1 -0
  94. package/dist/core/maturity.js +66 -0
  95. package/dist/core/maturity.js.map +1 -0
  96. package/dist/core/openapi-merge.js +552 -0
  97. package/dist/core/openapi-merge.js.map +1 -0
  98. package/dist/core/openapi.js +255 -0
  99. package/dist/core/openapi.js.map +1 -0
  100. package/dist/core/openspec-inventory.js +1440 -0
  101. package/dist/core/openspec-inventory.js.map +1 -0
  102. package/dist/core/path-safety.js +168 -0
  103. package/dist/core/path-safety.js.map +1 -0
  104. package/dist/core/provenance.js +720 -0
  105. package/dist/core/provenance.js.map +1 -0
  106. package/dist/core/records.js +33 -0
  107. package/dist/core/records.js.map +1 -0
  108. package/dist/core/repo.js +436 -0
  109. package/dist/core/repo.js.map +1 -0
  110. package/dist/core/report.js +47 -0
  111. package/dist/core/report.js.map +1 -0
  112. package/dist/core/results.js +199 -0
  113. package/dist/core/results.js.map +1 -0
  114. package/dist/core/spec.js +481 -0
  115. package/dist/core/spec.js.map +1 -0
  116. package/dist/core/staging.js +890 -0
  117. package/dist/core/staging.js.map +1 -0
  118. package/dist/core/status.js +1104 -0
  119. package/dist/core/status.js.map +1 -0
  120. package/dist/core/steps.js +72 -0
  121. package/dist/core/steps.js.map +1 -0
  122. package/dist/core/verify.js +807 -0
  123. package/dist/core/verify.js.map +1 -0
  124. package/dist/core/version.js +24 -0
  125. package/dist/core/version.js.map +1 -0
  126. package/package.json +63 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo.js","sourceRoot":"","sources":["../../src/core/repo.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAe,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,M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AC,IAAI;QAChG,mCAAmC,CACpC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAe,EACf,GAAW,EACX,OAAsB;IAEtB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACpE,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,CACL,YAAY,OAAO,CAAC,EAAE,2CAA2C,OAAO,CAAC,OAAO,MAAM;YACtF,eAAe,OAAO,CAAC,EAAE,iCAAiC,OAAO,CAAC,EAAE,iBAAiB,CACtF,CAAC;IACJ,CAAC;IACD,OAAO,eAAe,GAAG,WAAW,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC;AAC9D,CAAC","sourcesContent":["/**\n * Read model of the docs repo — the single place that knows its layout.\n *\n * Enumeration goes by the filesystem, and only by the filesystem: files are the\n * source of truth, so `services/` IS the list of services and there is no\n * manifest that can disagree with it. Every command that needs \"which services\n * exist\", \"which features are in flight\" or \"where does artifact X live\" asks\n * here, so the layout is spelled exactly once.\n */\nimport { existsSync, statSync, type Dirent } from \"node:fs\";\nimport { readdir } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { listField, readFrontmatter, stringField } from \"./frontmatter.js\";\nimport type { FleetContext } from \"./fleet-context.js\";\nimport { serviceIdProblem } from \"./ids.js\";\nimport type { Finding } from \"./report.js\";\n\n/** Directory under features/ holding shipped features. Never a feature itself. */\nconst ARCHIVE_DIR = \"archive\";\n\nexport interface ServiceArtifacts {\n model: boolean;\n spec: boolean;\n openapi: boolean;\n runbook: boolean;\n health: boolean;\n}\n\nexport interface ServiceEntry {\n /** Canonical service id — the directory name under services/. */\n id: string;\n /** Absolute path to services/<id>/. */\n dir: string;\n has: ServiceArtifacts;\n /** Number of ADR files under adrs/. */\n adrs: number;\n /** `status` from the living spec's frontmatter; null when nobody has said. */\n status: string | null;\n /**\n * Provenance signals from the living spec's frontmatter: whether it declares\n * any `sources`, and whether a `sources_digest` stamp exists. Presence only —\n * whether the digest still matches the code is `validate`'s question, and it\n * can only be answered from inside the service's own repo.\n */\n sources: { declared: boolean; stamped: boolean };\n /**\n * Why no loam command can author this directory, or absent when the name is a\n * legal service id — `serviceIdProblem`'s own sentence, so the read model and\n * the refusal say the same thing.\n *\n * The enumeration still LISTS it: the directory is there, it holds somebody's\n * documents, and hiding it would repeat the symlink mistake one field up. But\n * every authoring command (`adopt`, `delta`, `rebase`, `new --touches`,\n * `init`) refuses this id with `invalid-option`, so grading it as an ordinary\n * service left the fleet gate demanding fixes no loam command can make. The\n * NAME is the finding — see `serviceIdFindings`.\n */\n idProblem?: string;\n}\n\nexport interface FeatureEntry {\n /** Feature id, derived from the directory name (FEAT-1-split -> FEAT-1). */\n id: string;\n /** The directory name as it is on disk, slug and all. */\n dirName: string;\n /** Absolute path to the feature directory. */\n dir: string;\n archived: boolean;\n /** Services this feature carries a delta for, from specs/<svc>/. */\n services: string[];\n has: { intent: boolean; delta: boolean };\n}\n\n/**\n * Compare ids so digit runs sort numerically: FEAT-2 before FEAT-10.\n * Deterministic and locale-independent — ordering is part of the output\n * contract for `list`, and `--json` consumers diff it.\n */\nexport function compareIds(a: string, b: string): number {\n const ta = tokenize(a);\n const tb = tokenize(b);\n for (let i = 0; i < Math.max(ta.length, tb.length); i += 1) {\n const x = ta[i];\n const y = tb[i];\n if (x === undefined) return -1;\n if (y === undefined) return 1;\n if (typeof x === \"number\" && typeof y === \"number\") {\n if (x !== y) return x - y;\n } else if (String(x) !== String(y)) {\n return String(x) < String(y) ? -1 : 1;\n }\n }\n return 0;\n}\n\nfunction tokenize(s: string): (string | number)[] {\n return (s.match(/\\d+|\\D+/g) ?? []).map((t) => (/^\\d/.test(t) ? Number(t) : t));\n}\n\n/**\n * Known ids within a small edit distance of `id`, closest first, at most three.\n *\n * The did-you-mean hint for a name somebody typed: `loam new --touches` and\n * `loam delta <svc>` answer the same mistake, and each carried its own copy of\n * these twenty-four lines. It belongs here because the ids being scored are\n * this module's ids — service directory names, feature ids — and because\n * `compareIds` right above is the tiebreak that keeps the list deterministic\n * when two candidates score equally. Not in `core/ids.ts`: `compareIds` lives\n * here and repo.ts imports ids.js, so putting it there would close a cycle.\n *\n * `arch.ts`'s `closeIds` looks similar and is not: substring and prefix, capped\n * at five, answering \"which element could this be\" rather than \"did you\n * misspell a directory\". Two rules, two homes.\n */\nexport function nearestIds(id: string, known: string[]): string[] {\n const budget = Math.max(1, Math.floor(id.length / 4));\n return known\n .map((candidate) => ({ candidate, distance: editDistance(id.toLowerCase(), candidate.toLowerCase()) }))\n .filter((scored) => scored.distance <= budget)\n .sort((a, b) => a.distance - b.distance || compareIds(a.candidate, b.candidate))\n .slice(0, 3)\n .map((scored) => scored.candidate);\n}\n\n/** Plain Levenshtein — ids are short, and the row-at-a-time form keeps it obvious. */\nfunction editDistance(a: string, b: string): number {\n let previous = Array.from({ length: b.length + 1 }, (_, i) => i);\n for (let i = 1; i <= a.length; i += 1) {\n const current = [i];\n for (let j = 1; j <= b.length; j += 1) {\n const substitution = previous[j - 1]! + (a[i - 1] === b[j - 1] ? 0 : 1);\n current.push(Math.min(previous[j]! + 1, current[j - 1]! + 1, substitution));\n }\n previous = current;\n }\n return previous[b.length]!;\n}\n\n/**\n * Feature id from a directory name: everything up to and including the first\n * number run (`FEAT-101-payment-splitting` -> `FEAT-101`). A name with no\n * `<word>-<number>` head is its own id. Quirk: a dated slug keeps only its first\n * segment (`release-2024-01-x` -> `release-2024`) — ids are not meant to be dates.\n */\nexport function featureIdFromDirName(dirName: string): string {\n const m = /^(.*?-\\d+)(?:-|$)/.exec(dirName);\n return m ? m[1]! : dirName;\n}\n\n/* ------------------------------------------------------------------ */\n/* Paths — artifact filenames are spelled here and nowhere else */\n/* ------------------------------------------------------------------ */\n\nexport interface ServicePaths {\n dir: string;\n model: string;\n spec: string;\n archSpec: string;\n openapi: string;\n runbook: string;\n health: string;\n adrsDir: string;\n}\n\nexport function servicePaths(docsDir: string, service: string): ServicePaths {\n const dir = join(docsDir, \"services\", service);\n return {\n dir,\n model: join(dir, \"model.likec4\"),\n spec: join(dir, \"spec.md\"),\n archSpec: join(dir, \"arch.spec.md\"),\n openapi: join(dir, \"openapi.yaml\"),\n runbook: join(dir, \"runbook.md\"),\n health: join(dir, \"health.yaml\"),\n adrsDir: join(dir, \"adrs\"),\n };\n}\n\n/**\n * The pair of requirement-carrying spec files, living and delta alike: the\n * business spec and the architecture spec. Same grammar, same delta algebra,\n * same merge — everything that walks \"the spec files\" of a service walks this\n * list, so the two axes cannot drift apart in what handles them. `key` indexes\n * ServicePaths/FeatureSpecPaths; `label` is how the axis names itself in prose.\n */\nexport const SPEC_AXES = [\n { key: \"spec\", file: \"spec.md\", label: \"requirements\" },\n { key: \"archSpec\", file: \"arch.spec.md\", label: \"arch requirements\" },\n] as const;\nexport type SpecAxis = (typeof SPEC_AXES)[number];\n\nexport interface FeaturePaths {\n dir: string;\n intent: string;\n delta: string;\n specsDir: string;\n adrsDir: string;\n}\n\nexport function featurePaths(featureDir: string): FeaturePaths {\n return {\n dir: featureDir,\n intent: join(featureDir, \"intent.md\"),\n delta: join(featureDir, \"delta.likec4\"),\n specsDir: join(featureDir, \"specs\"),\n adrsDir: join(featureDir, \"adrs\"),\n };\n}\n\nexport interface FeatureSpecPaths {\n dir: string;\n spec: string;\n archSpec: string;\n openapi: string;\n}\n\nexport function featureSpecPaths(featureDir: string, service: string): FeatureSpecPaths {\n const dir = join(featureDir, \"specs\", service);\n return {\n dir,\n spec: join(dir, \"spec.md\"),\n archSpec: join(dir, \"arch.spec.md\"),\n openapi: join(dir, \"openapi.yaml\"),\n };\n}\n\nexport function landscapePath(docsDir: string): string {\n return join(docsDir, \"architecture\", \"landscape.likec4\");\n}\n\nexport function featuresDir(docsDir: string): string {\n return join(docsDir, \"features\");\n}\n\n/**\n * The agent contract's filename, and where it sits in a docs repo.\n *\n * Both spellings are exported because the two questions are different: `init`,\n * `doctor` and `validate` want a path under a docsDir they already hold, while\n * `docs.ts` builds the scaffold as `[relative path, bytes]` pairs and needs the\n * bare name. Four modules spelled the literal out for themselves, and one of\n * them — `init` — uses it to decide whether a directory IS a docs repo at all,\n * so a rename that reached three of the four would leave `init` recognising a\n * file nothing else writes any more.\n *\n * `openspec-inventory.ts`'s \"AGENTS.md\" is deliberately NOT this constant: it\n * names a file in a foreign OpenSpec tree that happens to share the name.\n */\nexport const AGENTS_FILENAME = \"AGENTS.md\";\n\nexport function agentsPath(docsDir: string): string {\n return join(docsDir, AGENTS_FILENAME);\n}\n\n/**\n * Where shipped features live. `features/archive/` is spelled here and nowhere\n * else for the same reason every other artifact path is: `archive` and\n * `unarchive` move directories in and out of it, and a layout string that two\n * commands re-derive is a layout two commands can disagree about. The\n * `features/archive/…` strings in refusal PROSE are not this path — they are\n * what a reader types into `ls`, and they stay spelled out.\n */\nexport function archiveDir(docsDir: string): string {\n return join(featuresDir(docsDir), ARCHIVE_DIR);\n}\n\n/* ------------------------------------------------------------------ */\n/* Is there a docs repo there at all? */\n/* ------------------------------------------------------------------ */\n\n/**\n * What is actually at `docsDir`. Three answers, because they point at three\n * different fixes and the enumeration below used to give all of them the same\n * one — an empty list:\n *\n * - `missing` — nothing there (or not a directory): `docsDir` in loam.json\n * is wrong, or the docs repo was never cloned;\n * - `no-services` — a directory, but with no `services/`: it is some other\n * directory, most often the service repo itself after a typo;\n * - `ok` — a docs repo. `services/` may still be EMPTY, and that is a\n * legitimate state: a docs repo before the first `loam adopt`.\n *\n * \"Empty fleet\" and \"wrong path\" are the same output only if nobody asks this\n * question, and a green `loam list` over a docsDir that does not exist is worse\n * than a red one: it says the fleet is fine.\n */\nexport type DocsRepoKind = \"missing\" | \"no-services\" | \"ok\";\n\nexport interface DocsRepoState {\n kind: DocsRepoKind;\n /** The path examined, so a caller can quote it without re-deriving it. */\n path: string;\n}\n\nexport function docsRepoState(docsDir: string): DocsRepoState {\n const path = docsDir;\n let isDir = false;\n try {\n isDir = statSync(path).isDirectory();\n } catch {\n isDir = false;\n }\n if (!isDir) return { kind: \"missing\", path };\n return { kind: existsSync(join(path, \"services\")) ? \"ok\" : \"no-services\", path };\n}\n\n/**\n * The docs repo is not there. Thrown rather than returned because every caller\n * of the enumeration wants the same thing — to stop — and a `[]` return is the\n * bug this closes. `message` is written for a human at a terminal: the CLI's\n * top-level handler prints it verbatim, and commands that catch it report\n * `repository-unavailable`.\n */\nexport class DocsRepoUnavailableError extends Error {\n constructor(\n readonly state: DocsRepoState,\n message: string,\n ) {\n super(message);\n this.name = \"DocsRepoUnavailableError\";\n }\n}\n\n/**\n * Refuse to enumerate a docs repo that is not one. `allow` names the states the\n * caller can honestly survive: features/ may be absent from a real docs repo\n * (nothing is in flight yet), so feature enumeration only insists the docs repo\n * EXISTS, while service enumeration insists it is shaped like a docs repo — a\n * `services/` directory is what makes it one.\n */\nfunction requireDocsRepo(docsDir: string, allow: DocsRepoKind[]): void {\n const state = docsRepoState(docsDir);\n if (allow.includes(state.kind)) return;\n if (state.kind === \"missing\") {\n throw new DocsRepoUnavailableError(\n state,\n `The configured docs repo does not exist: ${state.path}. ` +\n \"Fix `docsDir` in loam.json, clone the docs repo there, \" +\n \"or run `loam init --docs <dir> --create` to make a new one.\",\n );\n }\n throw new DocsRepoUnavailableError(\n state,\n `${state.path} is not a docs repo — it has no services/ directory. ` +\n \"Point `docsDir` in loam.json at the shared docs repo, \" +\n \"or run `loam init --docs <dir> --create` to make one.\",\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Enumeration */\n/* ------------------------------------------------------------------ */\n\n/**\n * What a directory entry IS, following a symlink to find out.\n *\n * `readdir(withFileTypes)` does not follow symlinks: for a symlink `Dirent`\n * every `isDirectory()`/`isFile()` is false, whatever it points at. That made a\n * symlinked `services/<id>/` or `features/<id>/` vanish from every enumeration\n * at once — `list`, `validate --all`, the fleet gate — with no diagnostic\n * anywhere, which is the one outcome a shared docs repo cannot survive: the\n * fleet gate reported a service that is not there as fine because it never saw\n * it. Composing a docs repo out of symlinks (a worktree, a submodule, one\n * service's directory shared between two checkouts) is legitimate, so they are\n * FOLLOWED rather than refused. A dangling link stats as nothing and is skipped\n * exactly as an absent directory is — it is not a service, and saying so would\n * mean inventing an entry to hang the complaint on.\n */\nfunction entryIs(dir: string, e: Dirent, want: \"dir\" | \"file\"): boolean {\n if (!e.isSymbolicLink()) return want === \"dir\" ? e.isDirectory() : e.isFile();\n try {\n const s = statSync(join(dir, e.name));\n return want === \"dir\" ? s.isDirectory() : s.isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * Sorted names of the real subdirectories of `dir` (dot-dirs and files skipped).\n * A missing `dir` is an empty list — the swallow is deliberate but narrow: it\n * only ever runs INSIDE a docs repo that `requireDocsRepo` has already\n * confirmed, where an absent `features/` or `specs/` means \"none yet\" and\n * nothing else.\n */\nasync function subdirs(dir: string): Promise<string[]> {\n if (!existsSync(dir)) return [];\n const entries = await readdir(dir, { withFileTypes: true });\n return entries\n .filter((e) => !e.name.startsWith(\".\") && entryIs(dir, e, \"dir\"))\n .map((e) => e.name)\n .sort(compareIds);\n}\n\n/**\n * Markdown files sitting directly in `dir` — the ADR count, and the only place\n * that rule is spelled. Exported because `show` kept a second copy that tested\n * `Dirent.isFile()` itself: always false for a symlink, whatever it points at,\n * so a docs repo composed of symlinks (the layout `entryIs` above exists to\n * support) had `loam list` and `loam show` reporting different ADR counts for\n * the same service. One rule, one answer.\n */\nexport async function countMarkdown(dir: string): Promise<number> {\n if (!existsSync(dir)) return 0;\n const entries = await readdir(dir, { withFileTypes: true });\n return entries.filter((e) => e.name.endsWith(\".md\") && entryIs(dir, e, \"file\")).length;\n}\n\n/** Services a feature carries a delta for, ordered — the subdirs of its specs/. */\nexport async function featureSpecServices(\n featureDir: string,\n context?: FleetContext,\n): Promise<string[]> {\n if (context !== undefined) return context.featureSpecServices(featureDir);\n return subdirs(featurePaths(featureDir).specsDir);\n}\n\n/** Every service in the docs repo, ordered by id. */\nexport async function listServices(docsDir: string, context?: FleetContext): Promise<ServiceEntry[]> {\n if (context !== undefined) return context.listServices(docsDir);\n requireDocsRepo(docsDir, [\"ok\"]);\n const names = await subdirs(join(docsDir, \"services\"));\n return Promise.all(\n names.map(async (id): Promise<ServiceEntry> => {\n const p = servicePaths(docsDir, id);\n const fm = await readFrontmatter(p.spec);\n const idProblem = serviceIdProblem(id, \"directory name\");\n return {\n id,\n dir: p.dir,\n ...(idProblem === null ? {} : { idProblem }),\n has: {\n model: existsSync(p.model),\n spec: existsSync(p.spec),\n openapi: existsSync(p.openapi),\n runbook: existsSync(p.runbook),\n health: existsSync(p.health),\n },\n adrs: await countMarkdown(p.adrsDir),\n status: stringField(fm, \"status\") ?? null,\n sources: {\n declared: listField(fm, \"sources\").length > 0,\n stamped: stringField(fm, \"sources_digest\") !== undefined,\n },\n };\n }),\n );\n}\n\n/**\n * The directories under `services/` that no loam command can address.\n *\n * A finding rather than a silent skip, and an ERROR rather than a warning,\n * because the state is not survivable in either direction: `loam adopt`,\n * `loam delta`, `loam rebase` and `loam new --touches` all refuse the id with\n * `invalid-option`, so the documents in there can never be updated by loam\n * again, while `validate --all` used to grade the directory as an ordinary\n * service and demand `model.likec4`, a spec and a landscape binding for it. The\n * fix is a rename, and it is a rename loam cannot do for you — the id is\n * spelled in the landscape binding, in the frontmatter and in every feature\n * that touched the service — so the message names all three.\n *\n * Emitted from the fleet target (`validate --all`), where the SET of service\n * directories is the thing being checked; a per-service run is already refused\n * by its own `--service` guard before it gets here.\n */\nexport function serviceIdFindings(services: ServiceEntry[]): Finding[] {\n return services\n .filter((s) => s.idProblem !== undefined)\n .map((s) => ({\n severity: \"error\" as const,\n code: \"service.id-invalid\",\n subject: s.id,\n message:\n `services/${s.id}/ — ${s.idProblem} ` +\n `Every authoring command refuses this id (\\`loam adopt\\`, \\`loam delta\\`, \\`loam new --touches\\`), so nothing in that directory can be changed through loam. ` +\n `Rename the directory to a legal id, then update its \\`service:\\` frontmatter, its \\`metadata { service '${s.id}' }\\` binding in architecture/landscape.likec4, and any features/<FEAT>/specs/${s.id}/ that names it.`,\n }));\n}\n\nasync function readFeature(dir: string, dirName: string, archived: boolean): Promise<FeatureEntry> {\n const p = featurePaths(dir);\n return {\n id: featureIdFromDirName(dirName),\n dirName,\n dir,\n archived,\n services: await subdirs(p.specsDir),\n has: { intent: existsSync(p.intent), delta: existsSync(p.delta) },\n };\n}\n\n/**\n * Features in the docs repo, ordered by id (active and archived interleaved when\n * both are asked for). `features/archive/` is the archive, never a feature.\n */\nexport async function listFeatures(\n docsDir: string,\n opts: { includeArchived?: boolean } = {},\n context?: FleetContext,\n): Promise<FeatureEntry[]> {\n if (context !== undefined) return context.listFeatures(docsDir, opts);\n // \"no-services\" is tolerated here on purpose: a docs repo whose services/ is\n // gone is broken, but it is `listServices` (and `loam doctor`) that says so.\n // Refusing here too would turn one diagnosis into two contradictory ones.\n requireDocsRepo(docsDir, [\"ok\", \"no-services\"]);\n const root = featuresDir(docsDir);\n const active = (await subdirs(root)).filter((n) => n !== ARCHIVE_DIR);\n const out = await Promise.all(active.map((n) => readFeature(join(root, n), n, false)));\n\n if (opts.includeArchived) {\n const archiveRoot = join(root, ARCHIVE_DIR);\n const archived = await subdirs(archiveRoot);\n out.push(...(await Promise.all(archived.map((n) => readFeature(join(archiveRoot, n), n, true)))));\n }\n\n return out.sort((a, b) => compareIds(a.id, b.id) || compareIds(a.dirName, b.dirName));\n}\n\n/**\n * Which side of `features/archive/` a lookup may land on. The policy is an\n * argument, not a default, so every command's stance on shipped features is\n * visible at its call site: delta/validate/archive work on in-flight features\n * (\"exclude\"), show/verify/new read shipped ones too (\"include\"), unarchive\n * takes back nothing else (\"only\").\n */\nexport type ArchivedPolicy = \"exclude\" | \"include\" | \"only\";\n\n/**\n * Resolve a feature argument — a canonical id (`FEAT-5`) or an exact directory\n * name (`FEAT-5-slug`) — to its entry. The entry's `id` is the canonical\n * spelling, and it is the only name a caller may use from here on: tag filters,\n * coherence, and the cross-feature self-exclusion scans all compare against\n * `feature.id`, never against the raw argument.\n *\n * Matching is EXACT, on one of two spellings: the directory name as it is on\n * disk, or the canonical id derived from it. It used to also match any dirName\n * starting with `arg + \"-\"`, which made the argument a prefix query in\n * disguise: with FEAT-401 and FEAT-402 in flight, `loam archive FEAT` archived\n * whichever sorted first, and `loam delta billing` reached into\n * `billing-7-rewrite`. A destructive command must never pick a target the\n * caller did not name, so a prefix now resolves to nothing at all.\n *\n * An exact directory name still wins over the id spelling (`FEAT-5` the\n * directory over `FEAT-5-slug`, whose id is also `FEAT-5`), and under \"include\"\n * an active feature wins over an archived one. Ties among equally-exact\n * candidates go to the first by name — deterministic, unlike the raw readdir\n * order this replaces; `ambiguousFeatureMessage` lists them for the caller.\n */\nexport async function resolveFeature(\n docsDir: string,\n arg: string,\n archived: ArchivedPolicy,\n context?: FleetContext,\n): Promise<FeatureEntry | null> {\n return (await featureCandidates(docsDir, arg, archived, context))[0] ?? null;\n}\n\n/**\n * Every feature the argument names exactly, best first. Split out of\n * `resolveFeature` so a caller that wants to REFUSE an ambiguous argument can\n * see the tie instead of inheriting the winner.\n */\nexport async function featureCandidates(\n docsDir: string,\n arg: string,\n archived: ArchivedPolicy,\n context?: FleetContext,\n): Promise<FeatureEntry[]> {\n const all = await listFeatures(docsDir, { includeArchived: archived !== \"exclude\" }, context);\n return all\n .filter((f) => archived === \"include\" || f.archived === (archived === \"only\"))\n .filter((f) => f.dirName === arg || f.id === arg)\n .sort(\n (a, b) =>\n Number(b.dirName === arg) - Number(a.dirName === arg) ||\n Number(a.archived) - Number(b.archived) ||\n compareIds(a.dirName, b.dirName),\n );\n}\n\n/**\n * The message for an argument that names more than one feature — two directories\n * carrying the same id (`FEAT-6-aaa` and `FEAT-6-zzz`). `resolveFeature` still\n * picks one deterministically, but a command that is about to WRITE should say\n * which directories collided and make the caller spell one out.\n */\nexport function ambiguousFeatureMessage(arg: string, candidates: FeatureEntry[]): string {\n return (\n `'${arg}' names ${candidates.length} features: ${candidates.map((c) => c.dirName).join(\", \")}. ` +\n \"Pass the directory name you mean.\"\n );\n}\n\n/**\n * The message for an exclude-mode miss. When the feature exists under\n * `features/archive/`, \"no feature\" is a lie the caller would have to debug —\n * the honest answer is \"already archived\", plus how to look at it. The `--json`\n * code stays `unknown-target` either way: the target is unknown to the command\n * that asked, and the prose carries the diagnosis.\n */\nexport async function missingFeatureMessage(\n docsDir: string,\n arg: string,\n context?: FleetContext,\n): Promise<string> {\n const shipped = await resolveFeature(docsDir, arg, \"only\", context);\n if (shipped !== null) {\n return (\n `Feature '${shipped.id}' is already archived (features/archive/${shipped.dirName}) — ` +\n `\\`loam show ${shipped.id}\\` reads it, \\`loam unarchive ${shipped.id}\\` re-opens it.`\n );\n }\n return `No feature '${arg}' under ${featuresDir(docsDir)}.`;\n}\n"]}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The validation report — what `loam validate` produces before anything is
3
+ * printed.
4
+ *
5
+ * Checks build findings; renderers turn them into a human view or into the JSON
6
+ * contract. Keeping the two apart is what makes `--all` and `--json` possible
7
+ * without a second implementation of every check, and it is why a finding
8
+ * carries a stable `code`: prose is for people, codes are for callers.
9
+ */
10
+ /**
11
+ * The glyph each severity is printed with. Five sites had written it out
12
+ * themselves — four as a two-armed ternary that spelled `error` and let
13
+ * everything else fall to ⚠ — and a reader who learns the marks from one
14
+ * command's output has to be able to read them in the next. It lives beside
15
+ * `Severity` because it is a fact about the union, not about any one renderer;
16
+ * `TextHint.marker` above already describes it as "the ✓/⚠/✗ marker".
17
+ */
18
+ export const SEVERITY_MARK = { ok: "✓", warn: "⚠", error: "✗" };
19
+ /** A target is valid when nothing in it is an error. Warnings never gate. */
20
+ export function targetValid(target) {
21
+ return !target.findings.some((f) => f.severity === "error");
22
+ }
23
+ export function reportValid(targets) {
24
+ return targets.every(targetValid);
25
+ }
26
+ export function countSeverity(targets, severity) {
27
+ return targets.reduce((n, t) => n + t.findings.filter((f) => f.severity === severity).length, 0);
28
+ }
29
+ export function findingJson(f) {
30
+ return {
31
+ severity: f.severity,
32
+ code: f.code,
33
+ ...(f.subject === undefined ? {} : { subject: f.subject }),
34
+ ...(f.gates === undefined ? {} : { gates: f.gates }),
35
+ message: f.message,
36
+ details: f.details ?? [],
37
+ };
38
+ }
39
+ export function targetJson(t) {
40
+ return {
41
+ kind: t.kind,
42
+ id: t.id,
43
+ valid: targetValid(t),
44
+ findings: t.findings.map(findingJson),
45
+ };
46
+ }
47
+ //# sourceMappingURL=report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/core/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAA6B,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AA8C1F,6EAA6E;AAC7E,MAAM,UAAU,WAAW,CAAC,MAAoB;IAC9C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAuB;IACjD,OAAO,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAuB,EAAE,QAAkB;IACvE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACnG,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,OAAO;QACL,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,GAAG,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QAC1D,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACpD,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,EAAE;KACzB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAe;IACxC,OAAO;QACL,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;QACrB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC;KACtC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The validation report — what `loam validate` produces before anything is\n * printed.\n *\n * Checks build findings; renderers turn them into a human view or into the JSON\n * contract. Keeping the two apart is what makes `--all` and `--json` possible\n * without a second implementation of every check, and it is why a finding\n * carries a stable `code`: prose is for people, codes are for callers.\n */\n\nexport type Severity = \"ok\" | \"warn\" | \"error\";\n\n/**\n * The glyph each severity is printed with. Five sites had written it out\n * themselves — four as a two-armed ternary that spelled `error` and let\n * everything else fall to ⚠ — and a reader who learns the marks from one\n * command's output has to be able to read them in the next. It lives beside\n * `Severity` because it is a fact about the union, not about any one renderer;\n * `TextHint.marker` above already describes it as \"the ✓/⚠/✗ marker\".\n */\nexport const SEVERITY_MARK: Record<Severity, string> = { ok: \"✓\", warn: \"⚠\", error: \"✗\" };\n\n/** How the text renderer should lay a finding out. The JSON contract ignores this. */\nexport interface TextHint {\n /** Leading spaces. Default 0. */\n indent?: number;\n /** Print the ✓/⚠/✗ marker. Default true. */\n marker?: boolean;\n /** Block header printed once, before the first finding that carries it. */\n header?: string;\n /** Prefix for each detail line (e.g. \"- \" for a list of names). */\n detailPrefix?: string;\n}\n\nexport interface Finding {\n severity: Severity;\n /** Stable machine identifier — prose may change, this may not. */\n code: string;\n message: string;\n /**\n * What the finding is about, when that is narrower than the target: the\n * service a feature's per-service check ran on, say. Without it a caller\n * would have to read the service name back out of the message.\n */\n subject?: string;\n details?: string[];\n /**\n * Coherence findings only: whether `loam archive` refuses on this issue\n * without `--approve` (issue.ts explains why severity alone cannot say).\n * Absent on findings that never face the archive gate.\n */\n gates?: boolean;\n text?: TextHint;\n}\n\nexport interface TargetReport {\n /**\n * What was validated. `landscape` is the fleet itself — the checks that need\n * every service and every element in view at once, so they belong to no single\n * service and only run under `--all`.\n */\n kind: \"service\" | \"feature\" | \"landscape\";\n id: string;\n findings: Finding[];\n}\n\n/** A target is valid when nothing in it is an error. Warnings never gate. */\nexport function targetValid(target: TargetReport): boolean {\n return !target.findings.some((f) => f.severity === \"error\");\n}\n\nexport function reportValid(targets: TargetReport[]): boolean {\n return targets.every(targetValid);\n}\n\nexport function countSeverity(targets: TargetReport[], severity: Severity): number {\n return targets.reduce((n, t) => n + t.findings.filter((f) => f.severity === severity).length, 0);\n}\n\nexport function findingJson(f: Finding): Record<string, unknown> {\n return {\n severity: f.severity,\n code: f.code,\n ...(f.subject === undefined ? {} : { subject: f.subject }),\n ...(f.gates === undefined ? {} : { gates: f.gates }),\n message: f.message,\n details: f.details ?? [],\n };\n}\n\nexport function targetJson(t: TargetReport): Record<string, unknown> {\n return {\n kind: t.kind,\n id: t.id,\n valid: targetValid(t),\n findings: t.findings.map(findingJson),\n };\n}\n"]}
@@ -0,0 +1,199 @@
1
+ /**
2
+ * `loam verify --results` — the cucumber report as an answer sheet.
3
+ *
4
+ * `loam gherkin` tags every generated scenario `@loam-digest-<16hex>`, and
5
+ * cucumber's JSON format carries tags per scenario — so a test report says,
6
+ * mechanically, which spec scenarios ran green. This module reads that report
7
+ * and answers `scenario.tested` claims from it. The digest is the ONLY
8
+ * identity: a claim's `digest` and the tag are the same 16 hex of the same
9
+ * body hash, and names match nothing — rewording a scenario breaks the match,
10
+ * which is the point, because an agent must not be able to SAY a scenario is
11
+ * tested; only a green run may.
12
+ *
13
+ * That identity is CONTENT, and content stops one step short of a fleet: two
14
+ * services whose specs word a scenario identically share a digest, so one
15
+ * repository's report matches the other repository's claim. Those claims are
16
+ * refused rather than answered — see {@link contestedDigests}.
17
+ *
18
+ * Parsing is deliberately tolerant of everything except the shape it matches
19
+ * on. The format is what cucumber-js `--format json`, cucumber-jvm, behave and
20
+ * SpecFlow emit — an array of features, each `elements[]` (scenarios) with
21
+ * `name`, `tags[] {name}` and `steps[] {result {status}}`, plus the two
22
+ * places those dialects put a failure the steps never see: cucumber-jvm
23
+ * reports @Before/@After hook results in per-element `before[]`/`after[]`
24
+ * arrays (a teardown assertion fails there while every step stays `passed`),
25
+ * and behave carries an element-level `status` that a hook failure flips.
26
+ * Only those fields are contract: unknown fields, tagless elements
27
+ * (backgrounds, hand-written scenarios) and stray entries are skipped without
28
+ * comment. What is NOT tolerated is a file that is not that array at all: a
29
+ * report loam cannot recognize must refuse rather than quietly answer every
30
+ * claim "not found".
31
+ */
32
+ import { DIGEST_TAG_RE, scenarioDigestTag } from "./gherkin.js";
33
+ import { isRecord } from "./records.js";
34
+ /**
35
+ * Read a parsed cucumber JSON document down to its digest-tagged scenarios.
36
+ * `reportName` is how the caller spelled the file, for the refusal message.
37
+ */
38
+ export function readCucumberReport(doc, reportName) {
39
+ if (!Array.isArray(doc)) {
40
+ return {
41
+ ok: false,
42
+ message: `${reportName} is not a cucumber JSON report — expected the top-level array of features ` +
43
+ "that `cucumber-js --format json` (or cucumber-jvm, behave, SpecFlow) emits.",
44
+ };
45
+ }
46
+ const scenarios = [];
47
+ for (const feature of doc) {
48
+ if (!isRecord(feature))
49
+ continue;
50
+ const featureName = str(feature["uri"]) ?? str(feature["name"]) ?? "(unnamed feature)";
51
+ const elements = feature["elements"];
52
+ if (!Array.isArray(elements))
53
+ continue;
54
+ for (const el of elements) {
55
+ if (!isRecord(el))
56
+ continue;
57
+ const digests = [];
58
+ const tags = el["tags"];
59
+ if (Array.isArray(tags)) {
60
+ for (const t of tags) {
61
+ const name = typeof t === "string" ? t : isRecord(t) ? str(t["name"]) : undefined;
62
+ const m = name === undefined ? null : DIGEST_TAG_RE.exec(name);
63
+ if (m)
64
+ digests.push(m[1]);
65
+ }
66
+ }
67
+ // No digest tag, nothing to match: a background, a hand-written
68
+ // scenario, another tool's output. Invisible here, deliberately.
69
+ if (digests.length === 0)
70
+ continue;
71
+ const resultStatuses = (raw) => {
72
+ if (!Array.isArray(raw))
73
+ return [];
74
+ return raw.map((s) => {
75
+ const status = isRecord(s) && isRecord(s["result"]) ? str(s["result"]["status"]) : undefined;
76
+ return (status ?? "unknown").toLowerCase();
77
+ });
78
+ };
79
+ const steps = resultStatuses(el["steps"]);
80
+ // cucumber-jvm's @Before/@After hooks: separate arrays, same result shape.
81
+ const hooks = [...resultStatuses(el["before"]), ...resultStatuses(el["after"])];
82
+ // behave's element-level status — a hook failure flips it while the
83
+ // steps that already ran keep "passed".
84
+ const status = str(el["status"])?.toLowerCase();
85
+ scenarios.push({
86
+ where: `${featureName} › ${str(el["name"]) ?? "(unnamed scenario)"}`,
87
+ digests,
88
+ steps,
89
+ hooks,
90
+ ...(status === undefined ? {} : { status }),
91
+ });
92
+ }
93
+ }
94
+ return { ok: true, scenarios };
95
+ }
96
+ /**
97
+ * The digests that more than one service claims, with the services that claim
98
+ * them — a scenario worded identically in two services' specs.
99
+ *
100
+ * The digest is a hash of the scenario body and of nothing else, so `loam
101
+ * gherkin` stamps the same tag into both repositories and a report from either
102
+ * one matches both claims. A report says which scenario ran; it never says
103
+ * whose suite ran it, and the two repositories never ran each other's tests.
104
+ * loam has no way to tell them apart, so it does not choose: the answer is
105
+ * refused, with the services named, and `--service` is the way to give a report
106
+ * an owner (it narrows the checklist to one repository's claims before the
107
+ * matching starts, so nothing here is contested).
108
+ *
109
+ * Only the SERVICE boundary counts. One service's spec repeating a scenario
110
+ * word for word is genuinely one test — that is the documented meaning of the
111
+ * stamp — and both claims may be answered by the one run.
112
+ */
113
+ export function contestedDigests(claims) {
114
+ const owners = new Map();
115
+ for (const c of claims) {
116
+ if (c.digest === undefined)
117
+ continue;
118
+ const seen = owners.get(c.digest) ?? new Set();
119
+ seen.add(c.subject);
120
+ owners.set(c.digest, seen);
121
+ }
122
+ const contested = new Map();
123
+ for (const [digest, services] of owners) {
124
+ if (services.size > 1)
125
+ contested.set(digest, [...services].sort());
126
+ }
127
+ return contested;
128
+ }
129
+ /**
130
+ * Answer every claim from the report — the runner's half of the record. Meant
131
+ * for `scenario.tested` claims (the only kind carrying a digest); a claim
132
+ * without one is answered `unconfirmed` rather than skipped, because silence
133
+ * must never read as checked.
134
+ *
135
+ * Confirmation is strict on purpose: every matching occurrence — a digest the
136
+ * report holds twice is a re-run, and all of them count — ran at least one
137
+ * step, every step `passed`, every before/after hook `passed`, and the
138
+ * element-level status (when the dialect reports one) is `passed`. One failed
139
+ * occurrence wins as failure, a skipped-only run is "skipped" not green, and
140
+ * no match at all is "not found in report". A digest two services share is
141
+ * refused before any of that: see {@link contestedDigests}.
142
+ */
143
+ export function runnerAnswers(claims, scenarios, reportName) {
144
+ const contested = contestedDigests(claims);
145
+ return claims.map((c) => {
146
+ const rivals = c.digest === undefined ? undefined : contested.get(c.digest);
147
+ if (rivals !== undefined) {
148
+ return answer(c.id, "unconfirmed", [], `${scenarioDigestTag(c.digest)} is worded identically in ${rivals.join(", ")}, so ${reportName} cannot say whose suite ran it. ` +
149
+ "Record each service's claims from its own repo with --service.");
150
+ }
151
+ const runs = c.digest === undefined ? [] : scenarios.filter((s) => s.digests.includes(c.digest));
152
+ if (runs.length === 0) {
153
+ const tag = c.digest === undefined ? "a digest tag" : scenarioDigestTag(c.digest);
154
+ return answer(c.id, "unconfirmed", [], `not found in report — no scenario in ${reportName} carries ${tag}`);
155
+ }
156
+ const failing = runs.filter((r) => !passed(r));
157
+ if (failing.length === 0) {
158
+ return answer(c.id, "confirmed", runs.map((r) => `${reportName}: ${r.where}`));
159
+ }
160
+ const first = failing[0];
161
+ const rerun = runs.length > 1 ? ` — ${failing.length} of ${runs.length} matching runs failed` : "";
162
+ return answer(c.id, "unconfirmed", [], `${reason(first)} (${reportName}: ${first.where})${rerun}`);
163
+ });
164
+ }
165
+ function answer(id, verdict, evidence, note) {
166
+ return { id, verdict, evidence, ...(note === undefined ? {} : { note }), answered_by: "runner" };
167
+ }
168
+ /**
169
+ * Green means green: at least one step, every step `passed`, every before/
170
+ * after hook `passed`, and the element-level status (when the dialect carries
171
+ * one) `passed` too. The last two exist because a run the runner itself
172
+ * reports as FAILED — a teardown assertion in an @After hook, exactly the
173
+ * shape the arch axis's outbox checks take — used to read as confirmed here:
174
+ * the steps all passed, and the hook failure lived in fields nobody read.
175
+ */
176
+ function passed(r) {
177
+ return (r.steps.length > 0 &&
178
+ r.steps.every((s) => s === "passed") &&
179
+ r.hooks.every((h) => h === "passed") &&
180
+ (r.status === undefined || r.status === "passed"));
181
+ }
182
+ /** Why a run did not pass, naming the step, hook or element status that says so. */
183
+ function reason(r) {
184
+ if (r.steps.length === 0)
185
+ return "no steps ran";
186
+ const i = r.steps.findIndex((s) => s !== "passed" && s !== "skipped");
187
+ if (i >= 0)
188
+ return `${r.steps[i]} at step ${i + 1}`;
189
+ if (r.steps.some((s) => s === "skipped"))
190
+ return "skipped";
191
+ const h = r.hooks.findIndex((s) => s !== "passed");
192
+ if (h >= 0)
193
+ return `${r.hooks[h]} in a before/after hook`;
194
+ return `scenario status '${r.status ?? "unknown"}'`;
195
+ }
196
+ function str(v) {
197
+ return typeof v === "string" && v.trim().length > 0 ? v : undefined;
198
+ }
199
+ //# sourceMappingURL=results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"results.js","sourceRoot":"","sources":["../../src/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-digest-<16hex>`, and\n * cucumber's JSON format carries tags per scenario — so a test report says,\n * mechanically, which spec scenarios ran green. This module reads that report\n * and answers `scenario.tested` claims from it. The digest is the ONLY\n * identity: a claim's `digest` and the tag are the same 16 hex of the same\n * body hash, and names match nothing — rewording a scenario breaks the match,\n * which is the point, because an agent must not be able to SAY a scenario is\n * tested; only a green run may.\n *\n * That identity is CONTENT, and content stops one step short of a fleet: two\n * services whose specs word a scenario identically share a digest, so one\n * repository's report matches the other repository's claim. Those claims are\n * refused rather than answered — see {@link contestedDigests}.\n *\n * Parsing is deliberately tolerant of everything except the shape it matches\n * on. The format is what cucumber-js `--format json`, cucumber-jvm, behave and\n * SpecFlow emit — an array of features, each `elements[]` (scenarios) with\n * `name`, `tags[] {name}` and `steps[] {result {status}}`, plus the two\n * places those dialects put a failure the steps never see: cucumber-jvm\n * reports @Before/@After hook results in per-element `before[]`/`after[]`\n * arrays (a teardown assertion fails there while every step stays `passed`),\n * and behave carries an element-level `status` that a hook failure flips.\n * Only those fields are contract: unknown fields, tagless elements\n * (backgrounds, hand-written scenarios) and stray entries are skipped without\n * comment. What is NOT tolerated is a file that is not that array at all: a\n * report loam cannot recognize must refuse rather than quietly answer every\n * claim \"not found\".\n */\nimport { DIGEST_TAG_RE, scenarioDigestTag } from \"./gherkin.js\";\nimport { isRecord } from \"./records.js\";\nimport type { Answer, Claim } from \"./verify.js\";\n\n/** One report scenario, reduced to what matching needs. */\nexport interface ReportScenario {\n /** `<feature uri or name> › <scenario name>` — where the run can be seen. */\n where: string;\n /** Digests carried as `@loam-digest-…` tags. Usually one; hand-tagging can add more. */\n digests: string[];\n /** Step statuses, lowercased, in order. */\n steps: string[];\n /** Hook statuses from cucumber-jvm's `before[]`/`after[]`, lowercased, in order. */\n hooks: string[];\n /** behave's element-level status, lowercased — absent in the other dialects. */\n status?: string;\n}\n\nexport type ReportRead =\n | { ok: true; scenarios: ReportScenario[] }\n | { ok: false; message: string };\n\n/**\n * Read a parsed cucumber JSON document down to its digest-tagged scenarios.\n * `reportName` is how the caller spelled the file, for the refusal message.\n */\nexport function readCucumberReport(doc: unknown, reportName: string): ReportRead {\n if (!Array.isArray(doc)) {\n return {\n ok: false,\n message:\n `${reportName} is not a cucumber JSON report — expected the top-level array of features ` +\n \"that `cucumber-js --format json` (or cucumber-jvm, behave, SpecFlow) emits.\",\n };\n }\n const scenarios: ReportScenario[] = [];\n for (const feature of doc) {\n if (!isRecord(feature)) continue;\n const featureName = str(feature[\"uri\"]) ?? str(feature[\"name\"]) ?? \"(unnamed feature)\";\n const elements = feature[\"elements\"];\n if (!Array.isArray(elements)) continue;\n for (const el of elements) {\n if (!isRecord(el)) continue;\n const digests: string[] = [];\n const tags = el[\"tags\"];\n if (Array.isArray(tags)) {\n for (const t of tags) {\n const name = typeof t === \"string\" ? t : isRecord(t) ? str(t[\"name\"]) : undefined;\n const m = name === undefined ? null : DIGEST_TAG_RE.exec(name);\n if (m) digests.push(m[1]!);\n }\n }\n // No digest tag, nothing to match: a background, a hand-written\n // scenario, another tool's output. Invisible here, deliberately.\n if (digests.length === 0) continue;\n const resultStatuses = (raw: unknown): string[] => {\n if (!Array.isArray(raw)) return [];\n return raw.map((s) => {\n const status = isRecord(s) && isRecord(s[\"result\"]) ? str(s[\"result\"][\"status\"]) : undefined;\n return (status ?? \"unknown\").toLowerCase();\n });\n };\n const steps = resultStatuses(el[\"steps\"]);\n // cucumber-jvm's @Before/@After hooks: separate arrays, same result shape.\n const hooks = [...resultStatuses(el[\"before\"]), ...resultStatuses(el[\"after\"])];\n // behave's element-level status — a hook failure flips it while the\n // steps that already ran keep \"passed\".\n const status = str(el[\"status\"])?.toLowerCase();\n scenarios.push({\n where: `${featureName} › ${str(el[\"name\"]) ?? \"(unnamed scenario)\"}`,\n digests,\n steps,\n hooks,\n ...(status === undefined ? {} : { status }),\n });\n }\n }\n return { ok: true, scenarios };\n}\n\n/**\n * The digests that more than one service claims, with the services that claim\n * them — a scenario worded identically in two services' specs.\n *\n * The digest is a hash of the scenario body and of nothing else, so `loam\n * gherkin` stamps the same tag into both repositories and a report from either\n * one matches both claims. A report says which scenario ran; it never says\n * whose suite ran it, and the two repositories never ran each other's tests.\n * loam has no way to tell them apart, so it does not choose: the answer is\n * refused, with the services named, and `--service` is the way to give a report\n * an owner (it narrows the checklist to one repository's claims before the\n * matching starts, so nothing here is contested).\n *\n * Only the SERVICE boundary counts. One service's spec repeating a scenario\n * word for word is genuinely one test — that is the documented meaning of the\n * stamp — and both claims may be answered by the one run.\n */\nexport function contestedDigests(claims: readonly Claim[]): Map<string, string[]> {\n const owners = new Map<string, Set<string>>();\n for (const c of claims) {\n if (c.digest === undefined) continue;\n const seen = owners.get(c.digest) ?? new Set<string>();\n seen.add(c.subject);\n owners.set(c.digest, seen);\n }\n const contested = new Map<string, string[]>();\n for (const [digest, services] of owners) {\n if (services.size > 1) contested.set(digest, [...services].sort());\n }\n return contested;\n}\n\n/**\n * Answer every claim from the report — the runner's half of the record. Meant\n * for `scenario.tested` claims (the only kind carrying a digest); a claim\n * without one is answered `unconfirmed` rather than skipped, because silence\n * must never read as checked.\n *\n * Confirmation is strict on purpose: every matching occurrence — a digest the\n * report holds twice is a re-run, and all of them count — ran at least one\n * step, every step `passed`, every before/after hook `passed`, and the\n * element-level status (when the dialect reports one) is `passed`. One failed\n * occurrence wins as failure, a skipped-only run is \"skipped\" not green, and\n * no match at all is \"not found in report\". A digest two services share is\n * refused before any of that: see {@link contestedDigests}.\n */\nexport function runnerAnswers(\n claims: Claim[],\n scenarios: ReportScenario[],\n reportName: string,\n): Answer[] {\n const contested = contestedDigests(claims);\n return claims.map((c) => {\n const rivals = c.digest === undefined ? undefined : contested.get(c.digest);\n if (rivals !== undefined) {\n return answer(\n c.id,\n \"unconfirmed\",\n [],\n `${scenarioDigestTag(c.digest!)} is worded identically in ${rivals.join(\", \")}, so ${reportName} cannot say whose suite ran it. ` +\n \"Record each service's claims from its own repo with --service.\",\n );\n }\n const runs = c.digest === undefined ? [] : scenarios.filter((s) => s.digests.includes(c.digest!));\n if (runs.length === 0) {\n const tag = c.digest === undefined ? \"a digest tag\" : scenarioDigestTag(c.digest);\n return answer(c.id, \"unconfirmed\", [], `not found in report — no scenario in ${reportName} carries ${tag}`);\n }\n const failing = runs.filter((r) => !passed(r));\n if (failing.length === 0) {\n return answer(c.id, \"confirmed\", runs.map((r) => `${reportName}: ${r.where}`));\n }\n const first = failing[0]!;\n const rerun = runs.length > 1 ? ` — ${failing.length} of ${runs.length} matching runs failed` : \"\";\n return answer(c.id, \"unconfirmed\", [], `${reason(first)} (${reportName}: ${first.where})${rerun}`);\n });\n}\n\nfunction answer(id: string, verdict: Answer[\"verdict\"], evidence: string[], note?: string): Answer {\n return { id, verdict, evidence, ...(note === undefined ? {} : { note }), answered_by: \"runner\" };\n}\n\n/**\n * Green means green: at least one step, every step `passed`, every before/\n * after hook `passed`, and the element-level status (when the dialect carries\n * one) `passed` too. The last two exist because a run the runner itself\n * reports as FAILED — a teardown assertion in an @After hook, exactly the\n * shape the arch axis's outbox checks take — used to read as confirmed here:\n * the steps all passed, and the hook failure lived in fields nobody read.\n */\nfunction passed(r: ReportScenario): boolean {\n return (\n r.steps.length > 0 &&\n r.steps.every((s) => s === \"passed\") &&\n r.hooks.every((h) => h === \"passed\") &&\n (r.status === undefined || r.status === \"passed\")\n );\n}\n\n/** Why a run did not pass, naming the step, hook or element status that says so. */\nfunction reason(r: ReportScenario): string {\n if (r.steps.length === 0) return \"no steps ran\";\n const i = r.steps.findIndex((s) => s !== \"passed\" && s !== \"skipped\");\n if (i >= 0) return `${r.steps[i]} at step ${i + 1}`;\n if (r.steps.some((s) => s === \"skipped\")) return \"skipped\";\n const h = r.hooks.findIndex((s) => s !== \"passed\");\n if (h >= 0) return `${r.hooks[h]} in a before/after hook`;\n return `scenario status '${r.status ?? \"unknown\"}'`;\n}\n\nfunction str(v: unknown): string | undefined {\n return typeof v === \"string\" && v.trim().length > 0 ? v : undefined;\n}\n"]}