@ybotok/loam 0.2.0-alpha.4 → 0.2.0-alpha.6
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 +947 -0
- package/MIGRATING-from-OpenSpec.md +7 -1
- package/QUICKSTART.md +8 -3
- package/README.md +20 -13
- package/ROADMAP.md +329 -22
- package/SCHEMA.md +472 -24
- package/WORKFLOW.md +23 -10
- package/dist/commands/adopt/render.js +47 -8
- package/dist/commands/adopt/render.js.map +1 -1
- package/dist/commands/archive/plan/landscape.js +45 -1
- package/dist/commands/archive/plan/landscape.js.map +1 -1
- package/dist/commands/archive/plan/model/extending.js +85 -0
- package/dist/commands/archive/plan/model/extending.js.map +1 -0
- package/dist/commands/archive/run.js +5 -2
- package/dist/commands/archive/run.js.map +1 -1
- package/dist/commands/context/print.js +11 -1
- package/dist/commands/context/print.js.map +1 -1
- package/dist/commands/doctor.js +46 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/explore.js +12 -2
- package/dist/commands/explore.js.map +1 -1
- package/dist/commands/list/views.js +5 -1
- package/dist/commands/list/views.js.map +1 -1
- package/dist/commands/seed/plan.js +97 -3
- package/dist/commands/seed/plan.js.map +1 -1
- package/dist/commands/seed/seed.js +7 -2
- package/dist/commands/seed/seed.js.map +1 -1
- package/dist/commands/show/feature.js +2 -1
- package/dist/commands/show/feature.js.map +1 -1
- package/dist/commands/show/marks.js +3 -5
- package/dist/commands/show/marks.js.map +1 -1
- package/dist/commands/show/service.js +39 -18
- package/dist/commands/show/service.js.map +1 -1
- package/dist/commands/subsystem/sync.js +184 -39
- package/dist/commands/subsystem/sync.js.map +1 -1
- package/dist/commands/subsystem/txn/exclude.js +132 -0
- package/dist/commands/subsystem/txn/exclude.js.map +1 -0
- package/dist/commands/subsystem/txn/report.js +124 -0
- package/dist/commands/subsystem/txn/report.js.map +1 -0
- package/dist/commands/subsystem/txn/txn.js +29 -3
- package/dist/commands/subsystem/txn/txn.js.map +1 -1
- package/dist/commands/subsystem/txn/views.js +113 -16
- package/dist/commands/subsystem/txn/views.js.map +1 -1
- package/dist/commands/validate/arch-coverage.js +16 -9
- package/dist/commands/validate/arch-coverage.js.map +1 -1
- package/dist/commands/validate/checks/fleet-shape.js +30 -77
- package/dist/commands/validate/checks/fleet-shape.js.map +1 -1
- package/dist/commands/validate/checks/vocabulary.js +4 -19
- package/dist/commands/validate/checks/vocabulary.js.map +1 -1
- package/dist/commands/validate/feature.js +1 -1
- package/dist/commands/validate/feature.js.map +1 -1
- package/dist/commands/validate/fleet/census.js +11 -10
- package/dist/commands/validate/fleet/census.js.map +1 -1
- package/dist/commands/validate/fleet/landscape.js +128 -114
- package/dist/commands/validate/fleet/landscape.js.map +1 -1
- package/dist/commands/validate/fleet/load.js +66 -0
- package/dist/commands/validate/fleet/load.js.map +1 -1
- package/dist/commands/validate/fleet/map/attest.js +103 -0
- package/dist/commands/validate/fleet/map/attest.js.map +1 -0
- package/dist/commands/validate/fleet/map/bindings.js +96 -0
- package/dist/commands/validate/fleet/map/bindings.js.map +1 -0
- package/dist/commands/validate/fleet/map/consumers.js +298 -0
- package/dist/commands/validate/fleet/map/consumers.js.map +1 -0
- package/dist/commands/validate/fleet/map/isolation.js +116 -0
- package/dist/commands/validate/fleet/map/isolation.js.map +1 -0
- package/dist/commands/validate/fleet/map/usecases.js +56 -0
- package/dist/commands/validate/fleet/map/usecases.js.map +1 -0
- package/dist/commands/validate/fleet/usecases/steps.js +49 -17
- package/dist/commands/validate/fleet/usecases/steps.js.map +1 -1
- package/dist/commands/validate/fleet/views/fleet-project.js +217 -0
- package/dist/commands/validate/fleet/views/fleet-project.js.map +1 -0
- package/dist/commands/validate/fleet/views/ids.js +13 -9
- package/dist/commands/validate/fleet/views/ids.js.map +1 -1
- package/dist/commands/validate/fleet/views/projects.js +278 -0
- package/dist/commands/validate/fleet/views/projects.js.map +1 -0
- package/dist/commands/validate/fleet/views/root-documents.js +97 -0
- package/dist/commands/validate/fleet/views/root-documents.js.map +1 -0
- package/dist/commands/validate/fleet/views/stale.js +2 -2
- package/dist/commands/validate/fleet/views/stale.js.map +1 -1
- package/dist/commands/validate/service/model/diverged.js +226 -0
- package/dist/commands/validate/service/model/diverged.js.map +1 -0
- package/dist/commands/validate/service/model/grade.js +163 -0
- package/dist/commands/validate/service/model/grade.js.map +1 -0
- package/dist/commands/validate/service/service.js +110 -34
- package/dist/commands/validate/service/service.js.map +1 -1
- package/dist/commands/validate/service/specs.js +39 -5
- package/dist/commands/validate/service/specs.js.map +1 -1
- package/dist/commands/validate/service/spine.js +41 -3
- package/dist/commands/validate/service/spine.js.map +1 -1
- package/dist/commands/validate/service/usecases/tags.js +113 -0
- package/dist/commands/validate/service/usecases/tags.js.map +1 -0
- package/dist/commands/validate/service/usecases/usecases.js +209 -0
- package/dist/commands/validate/service/usecases/usecases.js.map +1 -0
- package/dist/commands/validate/validate.js +10 -24
- package/dist/commands/validate/validate.js.map +1 -1
- package/dist/core/agent/agents-md/artifacts.js +1 -0
- package/dist/core/agent/agents-md/artifacts.js.map +1 -1
- package/dist/core/agent/agents-md/command-map.js +18 -2
- package/dist/core/agent/agents-md/command-map.js.map +1 -1
- package/dist/core/agent/agents-md/cycle.js +24 -9
- package/dist/core/agent/agents-md/cycle.js.map +1 -1
- package/dist/core/agent/agents-md/map/lenses/context.js +4 -3
- package/dist/core/agent/agents-md/map/lenses/context.js.map +1 -1
- package/dist/core/agent/agents-md/map/subsystem.js +51 -2
- package/dist/core/agent/agents-md/map/subsystem.js.map +1 -1
- package/dist/core/agent/agents-md/map/usecases.js +45 -3
- package/dist/core/agent/agents-md/map/usecases.js.map +1 -1
- package/dist/core/agent/agents-md.js +14 -4
- package/dist/core/agent/agents-md.js.map +1 -1
- package/dist/core/agent/support/report.js +39 -5
- package/dist/core/agent/support/report.js.map +1 -1
- package/dist/core/agent/workflows/adopt.js +125 -6
- package/dist/core/agent/workflows/adopt.js.map +1 -1
- package/dist/core/agent/workflows/check.js +35 -19
- package/dist/core/agent/workflows/check.js.map +1 -1
- package/dist/core/agent/workflows/closing.js +3 -1
- package/dist/core/agent/workflows/closing.js.map +1 -1
- package/dist/core/brief/brief.js +63 -11
- package/dist/core/brief/brief.js.map +1 -1
- package/dist/core/brief/checks.js +138 -3
- package/dist/core/brief/checks.js.map +1 -1
- package/dist/core/brief/landscape.js +212 -129
- package/dist/core/brief/landscape.js.map +1 -1
- package/dist/core/brief/map/extend.js +81 -0
- package/dist/core/brief/map/extend.js.map +1 -0
- package/dist/core/brief/map/owed.js +284 -0
- package/dist/core/brief/map/owed.js.map +1 -0
- package/dist/core/brief/targets.js +30 -26
- package/dist/core/brief/targets.js.map +1 -1
- package/dist/core/brief/unchecked.js +12 -2
- package/dist/core/brief/unchecked.js.map +1 -1
- package/dist/core/c4/likec4.js +23 -1
- package/dist/core/c4/likec4.js.map +1 -1
- package/dist/core/c4/parsed/deployment.js +5 -3
- package/dist/core/c4/parsed/deployment.js.map +1 -1
- package/dist/core/c4/parsed/view-ids.js +39 -1
- package/dist/core/c4/parsed/view-ids.js.map +1 -1
- package/dist/core/c4/prefetch/fleet.js +142 -0
- package/dist/core/c4/prefetch/fleet.js.map +1 -0
- package/dist/core/c4/project/architecture.js +52 -4
- package/dist/core/c4/project/architecture.js.map +1 -1
- package/dist/core/c4/project/batch.js +140 -0
- package/dist/core/c4/project/batch.js.map +1 -0
- package/dist/core/c4/project/documents.js +9 -4
- package/dist/core/c4/project/documents.js.map +1 -1
- package/dist/core/c4/project/load.js +77 -38
- package/dist/core/c4/project/load.js.map +1 -1
- package/dist/core/c4/project/staged.js +46 -12
- package/dist/core/c4/project/staged.js.map +1 -1
- package/dist/core/c4/resolve/attested.js +0 -0
- package/dist/core/c4/resolve/attested.js.map +1 -0
- package/dist/core/c4/resolve/service.js +8 -17
- package/dist/core/c4/resolve/service.js.map +1 -1
- package/dist/core/c4/resolve/steps.js +18 -0
- package/dist/core/c4/resolve/steps.js.map +1 -1
- package/dist/core/c4/root-project/exclude.js +352 -0
- package/dist/core/c4/root-project/exclude.js.map +1 -0
- package/dist/core/c4/service-model/documents.js +47 -0
- package/dist/core/c4/service-model/documents.js.map +1 -0
- package/dist/core/c4/service-model/fleet/extending.js +82 -0
- package/dist/core/c4/service-model/fleet/extending.js.map +1 -0
- package/dist/core/c4/service-model/load.js +165 -0
- package/dist/core/c4/service-model/load.js.map +1 -0
- package/dist/core/c4/service-model/renderer.js +128 -0
- package/dist/core/c4/service-model/renderer.js.map +1 -0
- package/dist/core/c4/service-model/shape.js +126 -0
- package/dist/core/c4/service-model/shape.js.map +1 -0
- package/dist/core/c4/service-model/slice.js +188 -0
- package/dist/core/c4/service-model/slice.js.map +1 -0
- package/dist/core/c4/source-scan.js +26 -0
- package/dist/core/c4/source-scan.js.map +1 -1
- package/dist/core/c4/splice/authored-source.js +60 -13
- package/dist/core/c4/splice/authored-source.js.map +1 -1
- package/dist/core/c4/splice/contract.js.map +1 -1
- package/dist/core/c4/splice/identity/declared.js +87 -0
- package/dist/core/c4/splice/identity/declared.js.map +1 -0
- package/dist/core/c4/splice/identity/edges.js +17 -0
- package/dist/core/c4/splice/identity/edges.js.map +1 -1
- package/dist/core/c4/splice/identity/existing.js +80 -0
- package/dist/core/c4/splice/identity/existing.js.map +1 -0
- package/dist/core/c4/splice/identity/interior.js +80 -0
- package/dist/core/c4/splice/identity/interior.js.map +1 -0
- package/dist/core/c4/splice/identity/owner.js +50 -0
- package/dist/core/c4/splice/identity/owner.js.map +1 -0
- package/dist/core/c4/splice/landscape-merge.js +154 -100
- package/dist/core/c4/splice/landscape-merge.js.map +1 -1
- package/dist/core/c4/splice/model/merge.js +140 -0
- package/dist/core/c4/splice/model/merge.js.map +1 -0
- package/dist/core/c4/splice/placement.js +14 -4
- package/dist/core/c4/splice/placement.js.map +1 -1
- package/dist/core/c4/workspace.js +2 -1
- package/dist/core/c4/workspace.js.map +1 -1
- package/dist/core/coherence/coherence.js +7 -0
- package/dist/core/coherence/coherence.js.map +1 -1
- package/dist/core/delta/delta.js +9 -0
- package/dist/core/delta/delta.js.map +1 -1
- package/dist/core/deployment/delta.js +4 -0
- package/dist/core/deployment/delta.js.map +1 -1
- package/dist/core/diff/base-state.js +21 -5
- package/dist/core/diff/base-state.js.map +1 -1
- package/dist/core/diff/victims.js +10 -1
- package/dist/core/diff/victims.js.map +1 -1
- package/dist/core/docs.js +31 -22
- package/dist/core/docs.js.map +1 -1
- package/dist/core/doctor/config.js +7 -3
- package/dist/core/doctor/config.js.map +1 -1
- package/dist/core/doctor/doctor.js +48 -9
- package/dist/core/doctor/doctor.js.map +1 -1
- package/dist/core/doctor/report.js.map +1 -1
- package/dist/core/doctor/reports/scan.js +242 -0
- package/dist/core/doctor/reports/scan.js.map +1 -0
- package/dist/core/explain/families.js +1 -1
- package/dist/core/explain/families.js.map +1 -1
- package/dist/core/explain/refusals.js +1 -1
- package/dist/core/explain/refusals.js.map +1 -1
- package/dist/core/explore/explore.js +44 -9
- package/dist/core/explore/explore.js.map +1 -1
- package/dist/core/fleet-context.js +47 -0
- package/dist/core/fleet-context.js.map +1 -1
- package/dist/core/gate/partners.js +5 -9
- package/dist/core/gate/partners.js.map +1 -1
- package/dist/core/kernel/ids/fqn/ancestors.js +65 -0
- package/dist/core/kernel/ids/fqn/ancestors.js.map +1 -0
- package/dist/core/pack/living.js +47 -13
- package/dist/core/pack/living.js.map +1 -1
- package/dist/core/pack/pack.js +9 -6
- package/dist/core/pack/pack.js.map +1 -1
- package/dist/core/projection/arch-slice.js +2 -2
- package/dist/core/projection/arch-slice.js.map +1 -1
- package/dist/core/repo/paths.js +40 -0
- package/dist/core/repo/paths.js.map +1 -1
- package/dist/core/repo/tree/render/projects.js +182 -0
- package/dist/core/repo/tree/render/projects.js.map +1 -0
- package/dist/core/repo/tree/render/stale.js +2 -3
- package/dist/core/repo/tree/render/stale.js.map +1 -1
- package/dist/core/repo/tree/render/views.js +51 -3
- package/dist/core/repo/tree/render/views.js.map +1 -1
- package/dist/core/repo/tree/walk.js +45 -2
- package/dist/core/repo/tree/walk.js.map +1 -1
- package/dist/core/scaffold/landscape.js +219 -9
- package/dist/core/scaffold/landscape.js.map +1 -1
- package/dist/core/staging/writes.js.map +1 -1
- package/dist/core/usecases/delta/claims.js +1 -0
- package/dist/core/usecases/delta/claims.js.map +1 -1
- package/dist/core/usecases/delta/overlay.js +4 -0
- package/dist/core/usecases/delta/overlay.js.map +1 -1
- package/dist/core/usecases/fleet.js +18 -6
- package/dist/core/usecases/fleet.js.map +1 -1
- package/dist/core/usecases/operations.js +7 -0
- package/dist/core/usecases/operations.js.map +1 -1
- package/dist/core/usecases/service/exclude.js +119 -0
- package/dist/core/usecases/service/exclude.js.map +1 -0
- package/dist/core/usecases/service/flows.js +161 -0
- package/dist/core/usecases/service/flows.js.map +1 -0
- package/dist/core/vocabulary/maturity.js +10 -0
- package/dist/core/vocabulary/maturity.js.map +1 -1
- package/examples/README.md +23 -0
- package/examples/docs/architecture/landscape.likec4 +41 -0
- package/examples/docs/architecture/usecases/order-notification.likec4 +5 -2
- package/examples/docs/likec4.config.json +0 -1
- package/examples/docs/services/checkout-web/model.likec4 +39 -56
- package/examples/docs/services/order-service/arch.spec.md +13 -6
- package/examples/docs/services/order-service/model.likec4 +53 -67
- package/examples/docs/services/payment-service/arch.spec.md +7 -4
- package/examples/docs/services/payment-service/model.likec4 +32 -33
- package/examples/docs/services/platform/identity-service/arch.spec.md +7 -4
- package/examples/docs/services/platform/identity-service/model.likec4 +29 -33
- package/examples/docs/services/platform/notification-service/health.yaml +8 -3
- package/examples/docs/services/platform/notification-service/model.likec4 +39 -59
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/commands/show/service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAA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AAE,EAAE,EAAE,CAAC;IACjE,+EAA+E;IAC/E,8EAA8E;IAC9E,6EAA6E;IAC7E,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/E,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAEpD,MAAM,OAAO,GAAW,EAAE,CAAC;IAC3B,MAAM,QAAQ,GAAW,EAAE,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,CAAC,OAAe,EAAQ,EAAE,CAAC,CAAC;YACvC,OAAO;YACP,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,IAAI;YAChB,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI;SACvB,CAAC,CAAC;QACH,IAAI,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,OAAO;YAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aAChE,IAAI,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,OAAO;YAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC;AAED,wEAAwE;AACxE,yEAAyE;AACzE,wEAAwE","sourcesContent":["/**\n * One service as `loam show` presents it: its spec, its contract, and the\n * fleet edges into and out of it.\n *\n * Split from `./feature.ts` because a service and a feature answer different\n * questions — what a repository holds now, against what a change proposes —\n * and only the service view has to reach the landscape for its edges.\n */\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { FleetContext } from \"../../core/fleet-context.js\";\nimport { emitJson, repoPath } from \"../../core/envelope/json.js\";\nimport { listField, readFrontmatter, stringField } from \"../../core/document/frontmatter.js\";\nimport { scopeText } from \"../../core/provenance/sample/scope.js\";\nimport { loadFile } from \"../../core/c4/likec4.js\";\nimport { serviceResolver } from \"../../core/c4/resolve/service.js\";\nimport { readOpenapi } from \"../../core/openapi/doc.js\";\nimport type { PathableService } from \"../../core/kernel/ids/service.js\";\nimport { landscapePath } from \"../../core/repo/paths.js\";\nimport { locateServicePaths } from \"../../core/repo/service-target.js\";\nimport { listServices } from \"../../core/repo/repo.js\";\nimport { countMarkdown } from \"../../core/repo/tree/fs.js\";\nimport { parseRequirements } from \"../../core/document/parse.js\";\nimport { type Requirement } from \"../../core/document/spec.js\";\nimport { plural } from \"../policy/format.js\";\nimport { edgeNote, errorText, mark, scenarioCount } from \"./marks.js\";\nimport type { DocsDir } from \"../../core/kernel/ids/dirs.js\";\n\nexport interface Edge {\n service: string;\n op: string | null;\n title: string | null;\n}\n\nexport async function showService(\n docsDir: DocsDir,\n id: PathableService,\n json: boolean,\n context: FleetContext,\n): Promise<void> {\n const paths = await locateServicePaths(docsDir, id, context);\n const has = {\n model: existsSync(paths.model),\n spec: existsSync(paths.spec),\n // The architecture-obligations axis. It was invisible here and in `list`,\n // which made the whole axis unnavigable: a service could carry twenty arch\n // requirements — the outbox, the retries, the alerts — and every command a\n // reader uses to find out what a service documents showed none of them.\n archSpec: existsSync(paths.archSpec),\n openapi: existsSync(paths.openapi),\n runbook: existsSync(paths.runbook),\n health: existsSync(paths.health),\n };\n\n const model = has.model\n ? await loadFile(paths.model)\n : { errors: [], elements: [], relationships: [] };\n const reqs = has.spec ? parseRequirements(await readFile(paths.spec, \"utf8\")) : [];\n const archReqs = has.archSpec ? parseRequirements(await readFile(paths.archSpec, \"utf8\")) : [];\n const adrs = await countMarkdown(paths.adrsDir);\n // `readOpenapi`, not `operationIds`: a contract that exists but does not parse\n // came back from operationIds as an EMPTY operation list, indistinguishable\n // from a service with no endpoints. `show` is what a reader opens to find out\n // what a service offers, and answering \"nothing\" over a YAML error is the\n // worst possible lie for that question. `x-loam-remove` entries are filtered\n // out for the same reason validate filters them: they are deletion markers\n // from a delta, not operations anybody can call.\n const api = await readOpenapi(paths.openapi);\n const ops = api.ops.filter((o) => !o.remove).map((o) => o.id);\n\n // Both axes: the sample is per file, so an arch.spec.md read from a sample\n // beside a fully-read spec.md still means part of this service's\n // documentation was not read, and a badge derived from spec.md alone would\n // not say so.\n const [fm, archFm] = await Promise.all([readFrontmatter(paths.spec), readFrontmatter(paths.archSpec)]);\n const scope = scopeText(fm);\n const archScope = scopeText(archFm);\n const provenance = {\n status: stringField(fm, \"status\") ?? null,\n owner: stringField(fm, \"owner\") ?? null,\n last_verified: stringField(fm, \"last_verified\") ?? null,\n sources: listField(fm, \"sources\"),\n // Additive, under its frontmatter spelling like its siblings: `show` is\n // where a person goes to find out what a service's documents claim, and a\n // `status: verified` that a person reached by reading four sections of the\n // spec is a materially different claim. Verbatim rather than decoded — an\n // unreadable value is still a stamped partial read, and showing it as it\n // stands is what lets a reader see the mangling.\n vouch_scope: scope,\n };\n\n const governs = (op: string): string[] =>\n reqs.filter((r) => r.operations.includes(op)).map((r) => r.name);\n\n const { inbound, outbound } = await landscapeEdges(docsDir, id, context);\n\n const requirementJson = (r: Requirement): Record<string, unknown> => ({\n id: r.id,\n name: r.name,\n kind: r.kind,\n scenarios: r.scenarios.length,\n operations: r.operations,\n covers: r.covers,\n });\n\n if (json) {\n emitJson({\n command: \"show\",\n type: \"service\",\n id,\n path: repoPath(docsDir, paths.dir),\n has,\n adrs,\n frontmatter: provenance,\n model: {\n elements: model.elements.length,\n relationships: model.relationships.length,\n errors: model.errors.map(errorText),\n },\n requirements: reqs.map(requirementJson),\n archSpec: {\n requirements: archReqs.length,\n scenarios: scenarioCount(archReqs),\n entries: archReqs.map(requirementJson),\n // The second axis carries its own scope: one `--sample` run can stamp\n // one of the pair sampled and read the other in full, and the\n // `frontmatter` block above is spec.md's alone.\n vouch_scope: archScope,\n },\n openapi: {\n unreadable: api.unreadable,\n ...(api.error === undefined ? {} : { error: api.error }),\n },\n operations: ops.map((op) => ({ id: op, governedBy: governs(op) })),\n landscape: { inbound, outbound },\n });\n return;\n }\n\n // The badge qualifies the status rather than replacing it: the document\n // still says `verified` and this screen still says so, with what that vouch\n // actually covered attached. A bare `verified` over a sampled stamp is the\n // one reading this whole feature exists to prevent — and either axis earns\n // the qualifier, since either one is part of this service nobody read.\n const shown =\n provenance.status === null || (scope === null && archScope === null)\n ? provenance.status\n : `${provenance.status} (sampled)`;\n const badge = [shown, provenance.owner].filter((s) => s !== null).join(\" · \");\n console.log(`${id} ${repoPath(docsDir, paths.dir)}${badge ? ` ${badge}` : \"\"}\\n`);\n\n if (provenance.sources.length > 0 || provenance.last_verified !== null || archScope !== null) {\n console.log(\" provenance\");\n if (provenance.last_verified !== null) console.log(` verified ${provenance.last_verified}`);\n // Per axis and named, because they can disagree: one file read in full,\n // the other from a sample, is an ordinary outcome of one `--sample` run.\n if (scope !== null) console.log(` scope spec.md ${scope} — the rest of it was not read at that vouch`);\n if (archScope !== null) {\n console.log(` scope arch.spec.md ${archScope} — the rest of it was not read at that vouch`);\n }\n for (const s of provenance.sources) console.log(` sources ${s}`);\n console.log(\"\");\n }\n\n console.log(\" artifacts\");\n const modelNote =\n model.errors.length > 0\n ? `${model.errors.length} error(s)`\n : `${plural(model.elements.length, \"element\")} · ${plural(model.relationships.length, \"relationship\")}`;\n console.log(` ${mark(has.model)} model.likec4 ${has.model ? modelNote : \"\"}`.trimEnd());\n const specNote = (rs: Requirement[]): string =>\n `${plural(rs.length, \"requirement\")} · ${plural(scenarioCount(rs), \"scenario\")}`;\n console.log(` ${mark(has.spec)} spec.md ${has.spec ? specNote(reqs) : \"\"}`.trimEnd());\n console.log(\n ` ${mark(has.archSpec)} arch.spec.md ${has.archSpec ? specNote(archReqs) : \"\"}`.trimEnd(),\n );\n const apiNote = api.unreadable ? \"does not parse\" : plural(ops.length, \"operation\");\n console.log(` ${mark(has.openapi)} openapi.yaml ${has.openapi ? apiNote : \"\"}`.trimEnd());\n console.log(` ${mark(has.runbook)} runbook.md`);\n console.log(` ${mark(has.health)} health.yaml`);\n console.log(` ${mark(adrs > 0)} adrs/ ${adrs > 0 ? plural(adrs, \"decision\") : \"\"}`.trimEnd());\n\n const requirementLine = (r: Requirement): string => {\n const govern = r.operations.length > 0 ? ` → ${r.operations.join(\", \")}` : \"\";\n const covers = r.covers.length > 0 ? ` covers ${r.covers.join(\", \")}` : \"\";\n return ` ${r.name} (${plural(r.scenarios.length, \"scenario\")})${govern}${covers}`;\n };\n if (reqs.length > 0) {\n console.log(\"\\n requirements\");\n for (const r of reqs) console.log(requirementLine(r));\n }\n if (archReqs.length > 0) {\n console.log(\"\\n arch requirements\");\n for (const r of archReqs) console.log(requirementLine(r));\n }\n\n if (api.unreadable) {\n console.log(\"\\n operations\");\n console.log(` ✗ openapi.yaml does not parse — nothing here lists what ${id} offers`);\n if (api.error !== undefined) console.log(` ${api.error}`);\n } else if (ops.length > 0) {\n console.log(\"\\n operations\");\n for (const op of ops) {\n const by = governs(op);\n if (by.length > 0) console.log(` ✓ ${op} governed by ${by.map((n) => `\"${n}\"`).join(\", \")}`);\n else console.log(` ⚠ ${op} not governed by any requirement`);\n }\n }\n\n if (inbound.length > 0 || outbound.length > 0) {\n console.log(\"\\n landscape\");\n for (const e of inbound) console.log(` ← ${e.service}${edgeNote(e)}`);\n for (const e of outbound) console.log(` → ${e.service}${edgeNote(e)}`);\n }\n\n if (model.errors.length > 0) {\n console.log(\"\\n model errors\");\n for (const e of model.errors) console.log(` ✗ ${errorText(e)}`);\n }\n}\n\n/** Inbound/outbound edges for a service, read off the living landscape. */\nexport async function landscapeEdges(\n docsDir: DocsDir,\n service: string,\n context: FleetContext,\n): Promise<{ inbound: Edge[]; outbound: Edge[] }> {\n const path = landscapePath(docsDir);\n if (!existsSync(path)) return { inbound: [], outbound: [] };\n const land = await loadFile(path);\n if (land.errors.length > 0) return { inbound: [], outbound: [] };\n // Edges are filed under the service an element is BOUND to, not under what the\n // box is titled — otherwise renaming a box empties this list without a word —\n // and an edge into a modelled container belongs to the service that owns it.\n const known = new Set((await listServices(docsDir, context)).map((s) => s.id));\n const svcOf = serviceResolver(land.elements, known);\n\n const inbound: Edge[] = [];\n const outbound: Edge[] = [];\n for (const r of land.relationships) {\n const edge = (service: string): Edge => ({\n service,\n op: r.op ?? null,\n title: r.title ?? null,\n });\n if (svcOf(r.target) === service) inbound.push(edge(svcOf(r.source)));\n else if (svcOf(r.source) === service) outbound.push(edge(svcOf(r.target)));\n }\n return { inbound, outbound };\n}\n\n/* ------------------------------------------------------------------ */\n/* Feature */\n/* ------------------------------------------------------------------ */\n"]}
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/commands/show/service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC7F,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAkB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,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OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACjE,+EAA+E;IAC/E,8EAA8E;IAC9E,6EAA6E;IAC7E,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/E,8EAA8E;IAC9E,8EAA8E;IAC9E,+EAA+E;IAC/E,4EAA4E;IAC5E,6EAA6E;IAC7E,4EAA4E;IAC5E,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,iBAAiB,CAAC;QAC9C,EAAE,EAAE,OAAO;QACX,MAAM,EAAE,IAAI;QACZ,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC;KAC7C,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC;AAED,wEAAwE;AACxE,yEAAyE;AACzE,wEAAwE","sourcesContent":["/**\n * One service as `loam show` presents it: its spec, its contract, and the\n * fleet edges into and out of it.\n *\n * Split from `./feature.ts` because a service and a feature answer different\n * questions — what a repository holds now, against what a change proposes —\n * and only the service view has to reach the landscape for its edges.\n */\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { FleetContext } from \"../../core/fleet-context.js\";\nimport { emitJson, repoPath } from \"../../core/envelope/json.js\";\nimport { listField, readFrontmatter, stringField } from \"../../core/document/frontmatter.js\";\nimport { scopeText } from \"../../core/provenance/sample/scope.js\";\nimport { loadFile, type LoadedDoc } from \"../../core/c4/likec4.js\";\nimport { serviceResolver } from \"../../core/c4/resolve/service.js\";\nimport { landscapeEvidence } from \"../../core/vocabulary/maturity.js\";\nimport { readOpenapi } from \"../../core/openapi/doc.js\";\nimport type { PathableService } from \"../../core/kernel/ids/service.js\";\nimport { landscapePath } from \"../../core/repo/paths.js\";\nimport { locateServicePaths } from \"../../core/repo/service-target.js\";\nimport { listServices } from \"../../core/repo/repo.js\";\nimport { countMarkdown } from \"../../core/repo/tree/fs.js\";\nimport { parseRequirements } from \"../../core/document/parse.js\";\nimport { type Requirement } from \"../../core/document/spec.js\";\nimport { plural } from \"../policy/format.js\";\nimport { edgeNote, mark, scenarioCount } from \"./marks.js\";\nimport { errorText } from \"../../core/c4/likec4.js\";\nimport type { DocsDir } from \"../../core/kernel/ids/dirs.js\";\n\nexport interface Edge {\n service: string;\n op: string | null;\n title: string | null;\n}\n\nexport async function showService(\n docsDir: DocsDir,\n id: PathableService,\n json: boolean,\n context: FleetContext,\n): Promise<void> {\n const paths = await locateServicePaths(docsDir, id, context);\n const has = {\n model: existsSync(paths.model),\n spec: existsSync(paths.spec),\n // The architecture-obligations axis. It was invisible here and in `list`,\n // which made the whole axis unnavigable: a service could carry twenty arch\n // requirements — the outbox, the retries, the alerts — and every command a\n // reader uses to find out what a service documents showed none of them.\n archSpec: existsSync(paths.archSpec),\n openapi: existsSync(paths.openapi),\n runbook: existsSync(paths.runbook),\n health: existsSync(paths.health),\n };\n\n // Through the ONE reader of `model.likec4`, so the counts here are the counts\n // `validate` prints: a model that EXTENDS the fleet map is a slice of the\n // project it extends, and opening the file alone would show a screenful of\n // parse errors for a document that is perfectly valid where it is read.\n const read = has.model ? await context.serviceModel(docsDir, paths) : null;\n const model: LoadedDoc =\n read === null\n ? { errors: [], elements: [], relationships: [] }\n : read.mapUnreadable\n ? // The map did not parse, so an extending model could not be read at\n // all. `show` must say that rather than print zeroes: \"0 elements\" is\n // what a service with no architecture looks like, and this one may\n // have plenty.\n {\n errors: [\n {\n message:\n \"architecture/landscape.likec4 does not parse, and this model extends it — \" +\n \"nothing here could be read. `loam validate --all` reports the map's own errors.\",\n },\n ],\n elements: [],\n relationships: [],\n }\n : read.doc;\n const reqs = has.spec ? parseRequirements(await readFile(paths.spec, \"utf8\")) : [];\n const archReqs = has.archSpec ? parseRequirements(await readFile(paths.archSpec, \"utf8\")) : [];\n const adrs = await countMarkdown(paths.adrsDir);\n // `readOpenapi`, not `operationIds`: a contract that exists but does not parse\n // came back from operationIds as an EMPTY operation list, indistinguishable\n // from a service with no endpoints. `show` is what a reader opens to find out\n // what a service offers, and answering \"nothing\" over a YAML error is the\n // worst possible lie for that question. `x-loam-remove` entries are filtered\n // out for the same reason validate filters them: they are deletion markers\n // from a delta, not operations anybody can call.\n const api = await readOpenapi(paths.openapi);\n const ops = api.ops.filter((o) => !o.remove).map((o) => o.id);\n\n // Both axes: the sample is per file, so an arch.spec.md read from a sample\n // beside a fully-read spec.md still means part of this service's\n // documentation was not read, and a badge derived from spec.md alone would\n // not say so.\n const [fm, archFm] = await Promise.all([readFrontmatter(paths.spec), readFrontmatter(paths.archSpec)]);\n const scope = scopeText(fm);\n const archScope = scopeText(archFm);\n const provenance = {\n status: stringField(fm, \"status\") ?? null,\n owner: stringField(fm, \"owner\") ?? null,\n last_verified: stringField(fm, \"last_verified\") ?? null,\n sources: listField(fm, \"sources\"),\n // Additive, under its frontmatter spelling like its siblings: `show` is\n // where a person goes to find out what a service's documents claim, and a\n // `status: verified` that a person reached by reading four sections of the\n // spec is a materially different claim. Verbatim rather than decoded — an\n // unreadable value is still a stamped partial read, and showing it as it\n // stands is what lets a reader see the mangling.\n vouch_scope: scope,\n };\n\n const governs = (op: string): string[] =>\n reqs.filter((r) => r.operations.includes(op)).map((r) => r.name);\n\n const { inbound, outbound } = await landscapeEdges(docsDir, id, context);\n\n const requirementJson = (r: Requirement): Record<string, unknown> => ({\n id: r.id,\n name: r.name,\n kind: r.kind,\n scenarios: r.scenarios.length,\n operations: r.operations,\n covers: r.covers,\n });\n\n if (json) {\n emitJson({\n command: \"show\",\n type: \"service\",\n id,\n path: repoPath(docsDir, paths.dir),\n has,\n adrs,\n frontmatter: provenance,\n model: {\n elements: model.elements.length,\n relationships: model.relationships.length,\n errors: model.errors.map(errorText),\n },\n requirements: reqs.map(requirementJson),\n archSpec: {\n requirements: archReqs.length,\n scenarios: scenarioCount(archReqs),\n entries: archReqs.map(requirementJson),\n // The second axis carries its own scope: one `--sample` run can stamp\n // one of the pair sampled and read the other in full, and the\n // `frontmatter` block above is spec.md's alone.\n vouch_scope: archScope,\n },\n openapi: {\n unreadable: api.unreadable,\n ...(api.error === undefined ? {} : { error: api.error }),\n },\n operations: ops.map((op) => ({ id: op, governedBy: governs(op) })),\n landscape: { inbound, outbound },\n });\n return;\n }\n\n // The badge qualifies the status rather than replacing it: the document\n // still says `verified` and this screen still says so, with what that vouch\n // actually covered attached. A bare `verified` over a sampled stamp is the\n // one reading this whole feature exists to prevent — and either axis earns\n // the qualifier, since either one is part of this service nobody read.\n const shown =\n provenance.status === null || (scope === null && archScope === null)\n ? provenance.status\n : `${provenance.status} (sampled)`;\n const badge = [shown, provenance.owner].filter((s) => s !== null).join(\" · \");\n console.log(`${id} ${repoPath(docsDir, paths.dir)}${badge ? ` ${badge}` : \"\"}\\n`);\n\n if (provenance.sources.length > 0 || provenance.last_verified !== null || archScope !== null) {\n console.log(\" provenance\");\n if (provenance.last_verified !== null) console.log(` verified ${provenance.last_verified}`);\n // Per axis and named, because they can disagree: one file read in full,\n // the other from a sample, is an ordinary outcome of one `--sample` run.\n if (scope !== null) console.log(` scope spec.md ${scope} — the rest of it was not read at that vouch`);\n if (archScope !== null) {\n console.log(` scope arch.spec.md ${archScope} — the rest of it was not read at that vouch`);\n }\n for (const s of provenance.sources) console.log(` sources ${s}`);\n console.log(\"\");\n }\n\n console.log(\" artifacts\");\n const modelNote =\n model.errors.length > 0\n ? `${model.errors.length} error(s)`\n : `${plural(model.elements.length, \"element\")} · ${plural(model.relationships.length, \"relationship\")}`;\n console.log(` ${mark(has.model)} model.likec4 ${has.model ? modelNote : \"\"}`.trimEnd());\n const specNote = (rs: Requirement[]): string =>\n `${plural(rs.length, \"requirement\")} · ${plural(scenarioCount(rs), \"scenario\")}`;\n console.log(` ${mark(has.spec)} spec.md ${has.spec ? specNote(reqs) : \"\"}`.trimEnd());\n console.log(\n ` ${mark(has.archSpec)} arch.spec.md ${has.archSpec ? specNote(archReqs) : \"\"}`.trimEnd(),\n );\n const apiNote = api.unreadable ? \"does not parse\" : plural(ops.length, \"operation\");\n console.log(` ${mark(has.openapi)} openapi.yaml ${has.openapi ? apiNote : \"\"}`.trimEnd());\n console.log(` ${mark(has.runbook)} runbook.md`);\n console.log(` ${mark(has.health)} health.yaml`);\n console.log(` ${mark(adrs > 0)} adrs/ ${adrs > 0 ? plural(adrs, \"decision\") : \"\"}`.trimEnd());\n\n const requirementLine = (r: Requirement): string => {\n const govern = r.operations.length > 0 ? ` → ${r.operations.join(\", \")}` : \"\";\n const covers = r.covers.length > 0 ? ` covers ${r.covers.join(\", \")}` : \"\";\n return ` ${r.name} (${plural(r.scenarios.length, \"scenario\")})${govern}${covers}`;\n };\n if (reqs.length > 0) {\n console.log(\"\\n requirements\");\n for (const r of reqs) console.log(requirementLine(r));\n }\n if (archReqs.length > 0) {\n console.log(\"\\n arch requirements\");\n for (const r of archReqs) console.log(requirementLine(r));\n }\n\n if (api.unreadable) {\n console.log(\"\\n operations\");\n console.log(` ✗ openapi.yaml does not parse — nothing here lists what ${id} offers`);\n if (api.error !== undefined) console.log(` ${api.error}`);\n } else if (ops.length > 0) {\n console.log(\"\\n operations\");\n for (const op of ops) {\n const by = governs(op);\n if (by.length > 0) console.log(` ✓ ${op} governed by ${by.map((n) => `\"${n}\"`).join(\", \")}`);\n else console.log(` ⚠ ${op} not governed by any requirement`);\n }\n }\n\n if (inbound.length > 0 || outbound.length > 0) {\n console.log(\"\\n landscape\");\n for (const e of inbound) console.log(` ← ${e.service}${edgeNote(e)}`);\n for (const e of outbound) console.log(` → ${e.service}${edgeNote(e)}`);\n }\n\n if (model.errors.length > 0) {\n console.log(\"\\n model errors\");\n for (const e of model.errors) console.log(` ✗ ${errorText(e)}`);\n }\n}\n\n/** Inbound/outbound edges for a service, read off the living landscape. */\nexport async function landscapeEdges(\n docsDir: DocsDir,\n service: string,\n context: FleetContext,\n): Promise<{ inbound: Edge[]; outbound: Edge[] }> {\n const path = landscapePath(docsDir);\n if (!existsSync(path)) return { inbound: [], outbound: [] };\n const land = await loadFile(path);\n if (land.errors.length > 0) return { inbound: [], outbound: [] };\n // Edges are filed under the service an element is BOUND to, not under what the\n // box is titled — otherwise renaming a box empties this list without a word —\n // and an edge into a modelled container belongs to the service that owns it.\n const known = new Set((await listServices(docsDir, context)).map((s) => s.id));\n // The ONE shared partition (core/vocabulary/maturity.ts `landscapeEvidence`),\n // not a fourth line-for-line copy of it. This loop was that copy, and it kept\n // the rule the others have dropped: an edge whose two endpoints resolve to the\n // same service is its own internal wiring, so `show` printed `← <id>` for a\n // service nobody calls while `context` — which reads the shared derivation —\n // printed nothing. `Edge` is that module's `LandscapeEdge` field for field.\n const { inbound, outbound } = landscapeEvidence({\n id: service,\n parses: true,\n relationships: land.relationships,\n elementIds: land.elements.map((e) => e.id),\n svcOf: serviceResolver(land.elements, known),\n });\n return { inbound, outbound };\n}\n\n/* ------------------------------------------------------------------ */\n/* Feature */\n/* ------------------------------------------------------------------ */\n"]}
|
|
@@ -1,30 +1,83 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `loam subsystem sync` — the
|
|
3
|
-
*
|
|
4
|
-
* differs, remove it when the tree has no subsystems, and say which.
|
|
2
|
+
* `loam subsystem sync` — the writer of everything under the tree that exists
|
|
3
|
+
* only to be RENDERED, which is the renderer's reading of the tree twice over:
|
|
5
4
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* - `architecture/subsystems.likec4`, the GENERATED views file. Recomputed from
|
|
6
|
+
* the tree on every run, compared, written when it differs, removed when the
|
|
7
|
+
* tree has no subsystems. The ONE repair for `subsystem.views-stale`. Left
|
|
8
|
+
* exactly as it is when the `architecture/` project does not parse and the
|
|
9
|
+
* file already exists — `action: "blocked"`, below.
|
|
10
|
+
* - `services/<…>/<id>/likec4.config.json`, one LikeC4 project file beside
|
|
11
|
+
* every model that STANDS ALONE. Never compared, never rewritten. Created
|
|
12
|
+
* where a standalone model has none, and DELETED where an extending model has
|
|
13
|
+
* one: measured at the 1.59.2 pin, that nested project claims the model out of
|
|
14
|
+
* the root project and the fleet loses the service's interior
|
|
15
|
+
* (`core/repo/tree/render/projects.ts` carries the measurement). This is the
|
|
16
|
+
* repair `service.likec4-config-stray` has always named and, until now, did
|
|
17
|
+
* not perform.
|
|
18
|
+
* - the ROOT `likec4.config.json`'s `exclude` list, and ONLY that key. Derived
|
|
19
|
+
* from the shapes on disk on every run and rewritten when it differs, because
|
|
20
|
+
* the two shapes need opposite answers from it: a standalone model must be
|
|
21
|
+
* excluded (inside the root project every kind it declares is a duplicate)
|
|
22
|
+
* and an extending model must not be (the root project is the only place it
|
|
23
|
+
* parses). `planExclude` below states the gate that keeps an old repository
|
|
24
|
+
* untouched, and `core/c4/service-model/renderer.ts` states which half of the
|
|
25
|
+
* list is loam's and which is the team's. One entry loam did NOT write is
|
|
26
|
+
* taken anyway, and only this one: an entry naming a directory that HIDES an
|
|
27
|
+
* extending model — a subsystem-wide `services/platform/**` survived every
|
|
28
|
+
* sync while `service.model-excluded` named this command as the repair.
|
|
12
29
|
*
|
|
13
|
-
* The
|
|
30
|
+
* The rules differ because the files answer to different owners. The
|
|
31
|
+
* views file is a pure function of the tree and the committed landscape, so
|
|
32
|
+
* every byte of it is loam's and a hand edit is by definition stale. The
|
|
33
|
+
* project file's bytes are a function of the service id ALONE — the identity
|
|
34
|
+
* no verb ever changes — so nothing can make it stale, and the keys LikeC4
|
|
35
|
+
* lets a team add to it (`title`, styles, a contact) are the team's; a compare
|
|
36
|
+
* would fight them, and a rewrite would take them. `core/repo/tree/render/projects.ts`
|
|
37
|
+
* records the measurement behind the file and the naming rule; here, presence
|
|
38
|
+
* is the one question asked of it, through the SAME predicate `validate --all`
|
|
39
|
+
* grades with (`missingProjects`), so the grader can never name a gap this
|
|
40
|
+
* writer would not fill.
|
|
41
|
+
*
|
|
42
|
+
* Nothing under `services/` is written, and no `exclude` is recomputed, unless
|
|
43
|
+
* the ROOT `likec4.config.json` exists. Without it the tree is not a loadable
|
|
44
|
+
* workspace at all — every model would merge into one project and report every
|
|
45
|
+
* declaration as a duplicate — and a nested project beside a missing root is a
|
|
46
|
+
* promise about a renderer that cannot be opened. `loam doctor` prints the root
|
|
47
|
+
* file; sync says so and writes nothing for the services until it is there.
|
|
48
|
+
*
|
|
49
|
+
* Every write goes through the same lock + journaled transaction every docs
|
|
50
|
+
* writer uses (`commitStaged`), and both kinds land in ONE commit: a
|
|
51
|
+
* predecessor's interrupted commit is recovered first and a sync killed
|
|
52
|
+
* mid-swap is rolled forward by the next writer. Idempotent by construction:
|
|
53
|
+
* the expected views bytes are a pure function of the tree, and a project
|
|
54
|
+
* file, once present, is never a gap again — so a second run reports
|
|
55
|
+
* `current` and writes nothing.
|
|
56
|
+
*
|
|
57
|
+
* The expected views bytes come from `./txn/views.ts` — the same module every
|
|
14
58
|
* writer verb renders from, so sync and the transactions cannot disagree
|
|
15
|
-
* about what the file should say.
|
|
59
|
+
* about what the file should say. The subsystem verbs' own commit window
|
|
60
|
+
* (`./txn/txn.ts`) does NOT write project files, and records why. What this run
|
|
61
|
+
* SAYS it did is `./txn/report.ts`: the third answer about the same three files,
|
|
62
|
+
* and the phase that is not part of the commit.
|
|
16
63
|
*/
|
|
17
64
|
import { existsSync } from "node:fs";
|
|
18
65
|
import { readFile } from "node:fs/promises";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
66
|
+
import { resolve } from "node:path";
|
|
67
|
+
import { readModelShapes } from "../../core/c4/service-model/shape.js";
|
|
68
|
+
import { fail, repoPath } from "../../core/envelope/json.js";
|
|
69
|
+
import { LIKEC4_ROOT_PROJECT, rootProjectPath, serviceRenderPaths, subsystemViewsPath, } from "../../core/repo/paths.js";
|
|
21
70
|
import { listFleetTree } from "../../core/repo/repo.js";
|
|
71
|
+
import { renderServiceProject, surveyProjects, } from "../../core/repo/tree/render/projects.js";
|
|
22
72
|
import { stageWrites } from "../../core/staging/commit.js";
|
|
23
73
|
import { InterruptedCommitError } from "../../core/staging/interrupted.js";
|
|
24
74
|
import { acquireDocsLockWaiting, DocsBusyError, LOCK_WAIT_MS } from "../../core/staging/lock.js";
|
|
25
75
|
import { recoverInterruptedCommit } from "../../core/staging/recovery/recover.js";
|
|
26
76
|
import { commitStaged } from "../../core/staging/txn/transaction.js";
|
|
77
|
+
import { planWrite } from "../../core/staging/writes.js";
|
|
27
78
|
import { viewsAgree } from "../../core/repo/tree/render/views.js";
|
|
79
|
+
import { NO_EXCLUDE, planExclude } from "./txn/exclude.js";
|
|
80
|
+
import { reportSync } from "./txn/report.js";
|
|
28
81
|
import { expectedViews } from "./txn/views.js";
|
|
29
82
|
export async function runSync(docsDir, json) {
|
|
30
83
|
let releaseLock;
|
|
@@ -53,7 +106,7 @@ export async function runSync(docsDir, json) {
|
|
|
53
106
|
const tree = await listFleetTree(docsDir);
|
|
54
107
|
const expected = await expectedViews(docsDir, tree);
|
|
55
108
|
const path = subsystemViewsPath(docsDir);
|
|
56
|
-
const expectedBytes = expected === null ? null : Buffer.from(expected, "utf8");
|
|
109
|
+
const expectedBytes = expected.content === null ? null : Buffer.from(expected.content, "utf8");
|
|
57
110
|
// Content, not bytes: `viewsAgree` records why, beside the generator. A
|
|
58
111
|
// Windows clone hands this file back CRLF with not one fact changed, and a
|
|
59
112
|
// byte compare made `sync` answer `updated` and rewrite it LF — after which
|
|
@@ -61,43 +114,135 @@ export async function runSync(docsDir, json) {
|
|
|
61
114
|
// CRLF back. `validate` stopped demanding that rewrite; `sync` must stop
|
|
62
115
|
// offering it, or the two disagree about the same file.
|
|
63
116
|
const actual = existsSync(path) ? await readFile(path, "utf8") : null;
|
|
64
|
-
|
|
65
|
-
|
|
117
|
+
// The render cannot be trusted against a file that already exists when the
|
|
118
|
+
// map is unreadable: without the element join and the style census it is a
|
|
119
|
+
// title and a description, and writing it would take the `include` lines,
|
|
120
|
+
// the boundary comment and the palette reference off a file whose only fault
|
|
121
|
+
// is a sibling document that does not parse.
|
|
122
|
+
const blocked = !expected.known && actual !== null;
|
|
123
|
+
const agree = blocked || viewsAgree(actual, expected.content);
|
|
124
|
+
// ONE read of every model's bytes for the whole run, and the same scan the
|
|
125
|
+
// grader uses: it decides which directories are owed a project file AND
|
|
126
|
+
// which the root project must exclude, and those are opposite answers for
|
|
127
|
+
// the two shapes (`core/repo/tree/render/projects.ts`).
|
|
128
|
+
const shapes = await readModelShapes(tree.services.map((svc) => serviceRenderPaths(svc.dir).model));
|
|
129
|
+
const plan = planProjects(docsDir, tree.services, shapes);
|
|
130
|
+
const exclude = plan.root ? await planExclude(docsDir, tree.services, plan.models) : NO_EXCLUDE;
|
|
131
|
+
// The plan IS the report: every gap is created and every stray removed in
|
|
132
|
+
// the one commit below, and the early return is the branch where both lists
|
|
133
|
+
// are empty.
|
|
134
|
+
const projects = () => ({
|
|
135
|
+
root: plan.root,
|
|
136
|
+
// SORTED BY PATH, which is what the contract says these keys hold and what
|
|
137
|
+
// the survey's own order is not: `surveyProjects` sorts by service id, so
|
|
138
|
+
// `services/svc-a/…` came out before `services/platform/svc-d/…` and a
|
|
139
|
+
// consumer told the list was "sorted" got an order no path sort produces
|
|
140
|
+
// (re-verification 2026-09-04, area C item 6). The text view prints the
|
|
141
|
+
// same array, so the two orders cannot drift apart.
|
|
142
|
+
created: plan.gaps.map((gap) => repoPath(docsDir, gap.path)).sort(),
|
|
143
|
+
removed: plan.strays.map((stray) => repoPath(docsDir, stray.path)).sort(),
|
|
144
|
+
current: plan.current,
|
|
145
|
+
modelled: plan.modelled,
|
|
146
|
+
exclude,
|
|
147
|
+
});
|
|
148
|
+
// `action` still describes the views file alone: a run that only created
|
|
149
|
+
// project files answers `current` for it, exactly as before the projects
|
|
150
|
+
// existed, so nothing reading the key sees a new meaning. `blocked` is the
|
|
151
|
+
// one exception and it is about that same file: it was left as it is.
|
|
152
|
+
const action = blocked
|
|
153
|
+
? "blocked"
|
|
154
|
+
: agree
|
|
155
|
+
? "current"
|
|
156
|
+
: actual === null
|
|
157
|
+
? "created"
|
|
158
|
+
: expectedBytes === null
|
|
159
|
+
? "removed"
|
|
160
|
+
: "updated";
|
|
161
|
+
const say = () => reportSync(json, {
|
|
162
|
+
action,
|
|
163
|
+
subsystems: tree.subsystems.length,
|
|
164
|
+
recovered,
|
|
165
|
+
projects: projects(),
|
|
166
|
+
mapUnreadable: !expected.known,
|
|
167
|
+
});
|
|
168
|
+
if (agree && plan.gaps.length === 0 && plan.strays.length === 0 && exclude.write === null) {
|
|
169
|
+
say();
|
|
66
170
|
return;
|
|
67
171
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
172
|
+
const writes = agree ? [] : [{ path, content: expectedBytes }];
|
|
173
|
+
// `planWrite` marks a non-existent target exclusive — a no-clobber create
|
|
174
|
+
// that fails EEXIST rather than replacing a file another writer landed in
|
|
175
|
+
// the same instant. That IS the create-only rule, enforced by the write
|
|
176
|
+
// path rather than by the `existsSync` the predicate already ran: a file
|
|
177
|
+
// that appears between the check and the swap is somebody's, and stays.
|
|
178
|
+
for (const gap of plan.gaps) {
|
|
179
|
+
writes.push(planWrite(gap.path, renderServiceProject(gap.service.id, LIKEC4_ROOT_PROJECT)));
|
|
180
|
+
}
|
|
181
|
+
// The one file this verb DELETES, and it rides the same journal as the rest,
|
|
182
|
+
// so a run killed mid-swap is rolled forward rather than half-done.
|
|
183
|
+
// `content: null` is the delete the views file already uses.
|
|
184
|
+
for (const stray of plan.strays)
|
|
185
|
+
writes.push({ path: stray.path, content: null });
|
|
186
|
+
// The root project's `exclude`, in the SAME transaction as the files it
|
|
187
|
+
// decides the fate of: a run that wrote the per-service projects and died
|
|
188
|
+
// before the exclude would leave a tree where the renderer loads a
|
|
189
|
+
// standalone model twice — once in the root project, where every kind it
|
|
190
|
+
// declares is a duplicate — which is worse than either end state.
|
|
191
|
+
if (exclude.write !== null)
|
|
192
|
+
writes.push(exclude.write);
|
|
193
|
+
// One lock, one journal, one commit for both kinds of file — a sync killed
|
|
194
|
+
// between the views swap and the project creates would otherwise leave a
|
|
195
|
+
// half-state no later run could tell from a team's deliberate deletion.
|
|
196
|
+
const staged = await stageWrites(writes);
|
|
70
197
|
const committed = await commitStaged({ root: docsDir, command: "subsystem", rerun: "loam subsystem sync", target: "subsystems" }, staged, "synced");
|
|
71
198
|
if (!committed.ok) {
|
|
72
199
|
fail(json, committed.code, committed.message);
|
|
73
200
|
return;
|
|
74
201
|
}
|
|
75
|
-
|
|
202
|
+
say();
|
|
76
203
|
}
|
|
77
204
|
finally {
|
|
78
205
|
await releaseLock();
|
|
79
206
|
}
|
|
80
207
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
208
|
+
/**
|
|
209
|
+
* What the project half of this run owes, from ONE predicate. `surveyProjects`
|
|
210
|
+
* is the shared spelling of "has a model, a legal id, and no file", and it
|
|
211
|
+
* hands back the sizes of the two domains it counted against — every model it
|
|
212
|
+
* walked, and the standalone models a file is owed for — so `current` is a
|
|
213
|
+
* subtraction rather than a second reading of the same two paths. A loop here
|
|
214
|
+
* re-spelling "has a model" was the drift the shared predicate exists to
|
|
215
|
+
* prevent, and it would have kept counting a directory the survey had
|
|
216
|
+
* skipped. Without the root file the gaps are real but stay unfilled —
|
|
217
|
+
* writing them would promise a renderer nobody can open — and `current` is 0
|
|
218
|
+
* because "already had a file" is only a fact about a workspace that exists.
|
|
219
|
+
*/
|
|
220
|
+
function planProjects(docsDir, services, shapes) {
|
|
221
|
+
const root = existsSync(rootProjectPath(docsDir));
|
|
222
|
+
// A model that EXTENDS the map is owed no file, and the survey is where that
|
|
223
|
+
// is decided — one predicate for the writer and the grader, so `validate --all`
|
|
224
|
+
// can never name a gap this run would not fill. An unreadable model classifies
|
|
225
|
+
// as standalone (`readModelShapes`), which is the conservative arm: it gets a
|
|
226
|
+
// project file, which is what every model got before shapes existed.
|
|
227
|
+
const survey = surveyProjects(services, serviceRenderPaths, (model) => shapes.get(resolve(model)) !== "extending");
|
|
228
|
+
if (!root)
|
|
229
|
+
return { root, gaps: [], strays: [], current: 0, modelled: survey.modelled, models: survey.models };
|
|
230
|
+
return {
|
|
231
|
+
root,
|
|
232
|
+
gaps: survey.gaps,
|
|
233
|
+
// The removal is gated on the root file for the same reason the create is:
|
|
234
|
+
// without it the docs root is not a LikeC4 workspace, so nothing there is
|
|
235
|
+
// claiming anything out of a root project that does not exist, and deleting
|
|
236
|
+
// a team's file over a renderer nobody can open is a writer acting on a
|
|
237
|
+
// hazard it cannot see.
|
|
238
|
+
strays: survey.strays,
|
|
239
|
+
// Over the STANDALONE domain, which is the one `gaps` was drawn from: a
|
|
240
|
+
// model that extends the map is owed no file, so it can neither be a gap nor
|
|
241
|
+
// "already have one", and subtracting from `modelled` counted every
|
|
242
|
+
// extending model as the latter.
|
|
243
|
+
current: survey.standalone - survey.gaps.length,
|
|
244
|
+
modelled: survey.modelled,
|
|
245
|
+
models: survey.models,
|
|
100
246
|
};
|
|
101
|
-
console.log(sentence[out.action]);
|
|
102
247
|
}
|
|
103
248
|
//# sourceMappingURL=sync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/subsystem/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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ACzG,OAAO,EAAE,0CAA0C,GAAG,CAAC,UAAU,qBAAqB;QACtF,OAAO,EAAE,4CAA4C,GAAG,CAAC,UAAU,qBAAqB;QACxF,OAAO,EAAE,4GAA4G;KACtH,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/**\n * `loam subsystem sync` — the ONE repair for `subsystem.views-stale`:\n * recompute the generated views file from the tree, write it when it\n * differs, remove it when the tree has no subsystems, and say which.\n *\n * The write goes through the same lock + journaled transaction every docs\n * writer uses (`commitStaged`), so a predecessor's interrupted commit is\n * recovered first and a sync killed mid-swap is rolled forward by the next\n * writer. Idempotent by construction: the expected bytes are a pure function\n * of the tree and the committed landscape, so a second run reports `current`\n * and writes nothing.\n *\n * The expected bytes come from `./txn/views.ts` — the same module every\n * writer verb renders from, so sync and the transactions cannot disagree\n * about what the file should say.\n */\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport type { DocsDir } from \"../../core/kernel/ids/dirs.js\";\nimport { emitJson, fail } from \"../../core/envelope/json.js\";\nimport { subsystemViewsPath } from \"../../core/repo/paths.js\";\nimport { listFleetTree } from \"../../core/repo/repo.js\";\nimport { stageWrites } from \"../../core/staging/commit.js\";\nimport { type CommitRecovery, InterruptedCommitError } from \"../../core/staging/interrupted.js\";\nimport { acquireDocsLockWaiting, DocsBusyError, LOCK_WAIT_MS } from \"../../core/staging/lock.js\";\nimport { recoverInterruptedCommit } from \"../../core/staging/recovery/recover.js\";\nimport { commitStaged } from \"../../core/staging/txn/transaction.js\";\nimport { viewsAgree } from \"../../core/repo/tree/render/views.js\";\nimport { expectedViews } from \"./txn/views.js\";\n\n/** What one sync did to the file. */\ntype SyncAction = \"current\" | \"created\" | \"updated\" | \"removed\";\n\nexport async function runSync(docsDir: DocsDir, json: boolean): Promise<void> {\n let releaseLock: () => Promise<void>;\n try {\n releaseLock = await acquireDocsLockWaiting(docsDir, LOCK_WAIT_MS);\n } catch (err) {\n if (!(err instanceof DocsBusyError)) throw err;\n fail(json, \"docs-busy\", err.message);\n return;\n }\n try {\n // A predecessor's journal is recovered (or refused) before the tree is\n // read: the views file itself may be the half-written one.\n let recovered: CommitRecovery | null;\n try {\n recovered = await recoverInterruptedCommit(docsDir);\n } catch (err) {\n if (!(err instanceof InterruptedCommitError)) throw err;\n fail(json, \"commit-interrupted\", err.message);\n return;\n }\n\n const tree = await listFleetTree(docsDir);\n const expected = await expectedViews(docsDir, tree);\n const path = subsystemViewsPath(docsDir);\n const expectedBytes = expected === null ? null : Buffer.from(expected, \"utf8\");\n // Content, not bytes: `viewsAgree` records why, beside the generator. A\n // Windows clone hands this file back CRLF with not one fact changed, and a\n // byte compare made `sync` answer `updated` and rewrite it LF — after which\n // git shows the file permanently modified and the next checkout puts the\n // CRLF back. `validate` stopped demanding that rewrite; `sync` must stop\n // offering it, or the two disagree about the same file.\n const actual = existsSync(path) ? await readFile(path, \"utf8\") : null;\n if (viewsAgree(actual, expected)) {\n report(json, { action: \"current\", subsystems: tree.subsystems.length, recovered });\n return;\n }\n const action: SyncAction = actual === null ? \"created\" : expectedBytes === null ? \"removed\" : \"updated\";\n const staged = await stageWrites([{ path, content: expectedBytes }]);\n const committed = await commitStaged(\n { root: docsDir, command: \"subsystem\", rerun: \"loam subsystem sync\", target: \"subsystems\" },\n staged,\n \"synced\",\n );\n if (!committed.ok) {\n fail(json, committed.code, committed.message);\n return;\n }\n report(json, { action, subsystems: tree.subsystems.length, recovered });\n } finally {\n await releaseLock();\n }\n}\n\nfunction report(\n json: boolean,\n out: { action: SyncAction; subsystems: number; recovered: CommitRecovery | null },\n): void {\n if (json) {\n emitJson({\n command: \"subsystem\",\n path: \"architecture/subsystems.likec4\",\n action: out.action,\n subsystems: out.subsystems,\n ...(out.recovered === null ? {} : { recovered: out.recovered }),\n });\n return;\n }\n if (out.recovered !== null && out.recovered.outcome !== \"consistent\") {\n console.log(\n `note: recovered an interrupted \\`loam ${out.recovered.command}\\` commit first (${out.recovered.outcome}).`,\n );\n }\n const sentence: Record<SyncAction, string> = {\n current: `architecture/subsystems.likec4 is current (${out.subsystems} subsystem(s)) — nothing to write.`,\n created: `wrote architecture/subsystems.likec4 — ${out.subsystems} subsystem view(s).`,\n updated: `updated architecture/subsystems.likec4 — ${out.subsystems} subsystem view(s).`,\n removed: `removed architecture/subsystems.likec4 — the tree has no subsystems, so the generated file must be absent.`,\n };\n console.log(sentence[out.action]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../../src/commands/subsystem/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAmB,MAAM,sCAAsC,CAAC;AAExF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAEL,oBAAoB,EACpB,cAAc,GAEf,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAuB,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE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\n * only to be RENDERED, which is the renderer's reading of the tree twice over:\n *\n * - `architecture/subsystems.likec4`, the GENERATED views file. Recomputed from\n * the tree on every run, compared, written when it differs, removed when the\n * tree has no subsystems. The ONE repair for `subsystem.views-stale`. Left\n * exactly as it is when the `architecture/` project does not parse and the\n * file already exists — `action: \"blocked\"`, below.\n * - `services/<…>/<id>/likec4.config.json`, one LikeC4 project file beside\n * every model that STANDS ALONE. Never compared, never rewritten. Created\n * where a standalone model has none, and DELETED where an extending model has\n * one: measured at the 1.59.2 pin, that nested project claims the model out of\n * the root project and the fleet loses the service's interior\n * (`core/repo/tree/render/projects.ts` carries the measurement). This is the\n * repair `service.likec4-config-stray` has always named and, until now, did\n * not perform.\n * - the ROOT `likec4.config.json`'s `exclude` list, and ONLY that key. Derived\n * from the shapes on disk on every run and rewritten when it differs, because\n * the two shapes need opposite answers from it: a standalone model must be\n * excluded (inside the root project every kind it declares is a duplicate)\n * and an extending model must not be (the root project is the only place it\n * parses). `planExclude` below states the gate that keeps an old repository\n * untouched, and `core/c4/service-model/renderer.ts` states which half of the\n * list is loam's and which is the team's. One entry loam did NOT write is\n * taken anyway, and only this one: an entry naming a directory that HIDES an\n * extending model — a subsystem-wide `services/platform/**` survived every\n * sync while `service.model-excluded` named this command as the repair.\n *\n * The rules differ because the files answer to different owners. The\n * views file is a pure function of the tree and the committed landscape, so\n * every byte of it is loam's and a hand edit is by definition stale. The\n * project file's bytes are a function of the service id ALONE — the identity\n * no verb ever changes — so nothing can make it stale, and the keys LikeC4\n * lets a team add to it (`title`, styles, a contact) are the team's; a compare\n * would fight them, and a rewrite would take them. `core/repo/tree/render/projects.ts`\n * records the measurement behind the file and the naming rule; here, presence\n * is the one question asked of it, through the SAME predicate `validate --all`\n * grades with (`missingProjects`), so the grader can never name a gap this\n * writer would not fill.\n *\n * Nothing under `services/` is written, and no `exclude` is recomputed, unless\n * the ROOT `likec4.config.json` exists. Without it the tree is not a loadable\n * workspace at all — every model would merge into one project and report every\n * declaration as a duplicate — and a nested project beside a missing root is a\n * promise about a renderer that cannot be opened. `loam doctor` prints the root\n * file; sync says so and writes nothing for the services until it is there.\n *\n * Every write goes through the same lock + journaled transaction every docs\n * writer uses (`commitStaged`), and both kinds land in ONE commit: a\n * predecessor's interrupted commit is recovered first and a sync killed\n * mid-swap is rolled forward by the next writer. Idempotent by construction:\n * the expected views bytes are a pure function of the tree, and a project\n * file, once present, is never a gap again — so a second run reports\n * `current` and writes nothing.\n *\n * The expected views bytes come from `./txn/views.ts` — the same module every\n * writer verb renders from, so sync and the transactions cannot disagree\n * about what the file should say. The subsystem verbs' own commit window\n * (`./txn/txn.ts`) does NOT write project files, and records why. What this run\n * SAYS it did is `./txn/report.ts`: the third answer about the same three files,\n * and the phase that is not part of the commit.\n */\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { readModelShapes, type ModelShape } from \"../../core/c4/service-model/shape.js\";\nimport type { DocsDir } from \"../../core/kernel/ids/dirs.js\";\nimport { fail, repoPath } from \"../../core/envelope/json.js\";\nimport {\n LIKEC4_ROOT_PROJECT,\n rootProjectPath,\n serviceRenderPaths,\n subsystemViewsPath,\n} from \"../../core/repo/paths.js\";\nimport { listFleetTree } from \"../../core/repo/repo.js\";\nimport {\n type ProjectGap,\n renderServiceProject,\n surveyProjects,\n type SurveyedModel,\n} from \"../../core/repo/tree/render/projects.js\";\nimport type { WalkedService } from \"../../core/repo/tree/walk.js\";\nimport { stageWrites } from \"../../core/staging/commit.js\";\nimport { type CommitRecovery, InterruptedCommitError } from \"../../core/staging/interrupted.js\";\nimport { acquireDocsLockWaiting, DocsBusyError, LOCK_WAIT_MS } from \"../../core/staging/lock.js\";\nimport { recoverInterruptedCommit } from \"../../core/staging/recovery/recover.js\";\nimport { commitStaged } from \"../../core/staging/txn/transaction.js\";\nimport { planWrite, type PlannedWrite } from \"../../core/staging/writes.js\";\nimport { viewsAgree } from \"../../core/repo/tree/render/views.js\";\nimport { NO_EXCLUDE, planExclude } from \"./txn/exclude.js\";\nimport { type ProjectsReport, reportSync, type SyncAction } from \"./txn/report.js\";\nimport { expectedViews } from \"./txn/views.js\";\n\n/**\n * The per-service project half of one sync, before the write: what the\n * predicate found, and the two counts the report needs beside it.\n */\ninterface ProjectPlan {\n /** Whether the root project file exists — the gate on every service write. */\n root: boolean;\n /** The files this run will create. Empty whenever `root` is false. */\n gaps: ProjectGap<WalkedService>[];\n /** The files this run will DELETE — a project file beside an extending model. Empty whenever `root` is false. */\n strays: ProjectGap<WalkedService>[];\n /**\n * Services owed a project file that ALREADY had one — so STANDALONE models\n * only; 0 whenever `root` is false. An extending model is owed none, and\n * counting it here said a file was in place beside a model that must not have\n * one (`service.likec4-config-stray` grades exactly that state).\n */\n current: number;\n /** Model-bearing services, root or no root — what the root-missing note is owed to. */\n modelled: number;\n /** Every model this run considered, with its shape — the exclude list is derived from the same walk. */\n models: SurveyedModel<WalkedService>[];\n}\n\nexport async function runSync(docsDir: DocsDir, json: boolean): Promise<void> {\n let releaseLock: () => Promise<void>;\n try {\n releaseLock = await acquireDocsLockWaiting(docsDir, LOCK_WAIT_MS);\n } catch (err) {\n if (!(err instanceof DocsBusyError)) throw err;\n fail(json, \"docs-busy\", err.message);\n return;\n }\n try {\n // A predecessor's journal is recovered (or refused) before the tree is\n // read: the views file itself may be the half-written one.\n let recovered: CommitRecovery | null;\n try {\n recovered = await recoverInterruptedCommit(docsDir);\n } catch (err) {\n if (!(err instanceof InterruptedCommitError)) throw err;\n fail(json, \"commit-interrupted\", err.message);\n return;\n }\n\n const tree = await listFleetTree(docsDir);\n const expected = await expectedViews(docsDir, tree);\n const path = subsystemViewsPath(docsDir);\n const expectedBytes = expected.content === null ? null : Buffer.from(expected.content, \"utf8\");\n // Content, not bytes: `viewsAgree` records why, beside the generator. A\n // Windows clone hands this file back CRLF with not one fact changed, and a\n // byte compare made `sync` answer `updated` and rewrite it LF — after which\n // git shows the file permanently modified and the next checkout puts the\n // CRLF back. `validate` stopped demanding that rewrite; `sync` must stop\n // offering it, or the two disagree about the same file.\n const actual = existsSync(path) ? await readFile(path, \"utf8\") : null;\n // The render cannot be trusted against a file that already exists when the\n // map is unreadable: without the element join and the style census it is a\n // title and a description, and writing it would take the `include` lines,\n // the boundary comment and the palette reference off a file whose only fault\n // is a sibling document that does not parse.\n const blocked = !expected.known && actual !== null;\n const agree = blocked || viewsAgree(actual, expected.content);\n // ONE read of every model's bytes for the whole run, and the same scan the\n // grader uses: it decides which directories are owed a project file AND\n // which the root project must exclude, and those are opposite answers for\n // the two shapes (`core/repo/tree/render/projects.ts`).\n const shapes = await readModelShapes(tree.services.map((svc) => serviceRenderPaths(svc.dir).model));\n const plan = planProjects(docsDir, tree.services, shapes);\n const exclude = plan.root ? await planExclude(docsDir, tree.services, plan.models) : NO_EXCLUDE;\n // The plan IS the report: every gap is created and every stray removed in\n // the one commit below, and the early return is the branch where both lists\n // are empty.\n const projects = (): ProjectsReport => ({\n root: plan.root,\n // SORTED BY PATH, which is what the contract says these keys hold and what\n // the survey's own order is not: `surveyProjects` sorts by service id, so\n // `services/svc-a/…` came out before `services/platform/svc-d/…` and a\n // consumer told the list was \"sorted\" got an order no path sort produces\n // (re-verification 2026-09-04, area C item 6). The text view prints the\n // same array, so the two orders cannot drift apart.\n created: plan.gaps.map((gap) => repoPath(docsDir, gap.path)).sort(),\n removed: plan.strays.map((stray) => repoPath(docsDir, stray.path)).sort(),\n current: plan.current,\n modelled: plan.modelled,\n exclude,\n });\n // `action` still describes the views file alone: a run that only created\n // project files answers `current` for it, exactly as before the projects\n // existed, so nothing reading the key sees a new meaning. `blocked` is the\n // one exception and it is about that same file: it was left as it is.\n const action: SyncAction = blocked\n ? \"blocked\"\n : agree\n ? \"current\"\n : actual === null\n ? \"created\"\n : expectedBytes === null\n ? \"removed\"\n : \"updated\";\n const say = (): void =>\n reportSync(json, {\n action,\n subsystems: tree.subsystems.length,\n recovered,\n projects: projects(),\n mapUnreadable: !expected.known,\n });\n if (agree && plan.gaps.length === 0 && plan.strays.length === 0 && exclude.write === null) {\n say();\n return;\n }\n const writes: PlannedWrite[] = agree ? [] : [{ path, content: expectedBytes }];\n // `planWrite` marks a non-existent target exclusive — a no-clobber create\n // that fails EEXIST rather than replacing a file another writer landed in\n // the same instant. That IS the create-only rule, enforced by the write\n // path rather than by the `existsSync` the predicate already ran: a file\n // that appears between the check and the swap is somebody's, and stays.\n for (const gap of plan.gaps) {\n writes.push(planWrite(gap.path, renderServiceProject(gap.service.id, LIKEC4_ROOT_PROJECT)));\n }\n // The one file this verb DELETES, and it rides the same journal as the rest,\n // so a run killed mid-swap is rolled forward rather than half-done.\n // `content: null` is the delete the views file already uses.\n for (const stray of plan.strays) writes.push({ path: stray.path, content: null });\n // The root project's `exclude`, in the SAME transaction as the files it\n // decides the fate of: a run that wrote the per-service projects and died\n // before the exclude would leave a tree where the renderer loads a\n // standalone model twice — once in the root project, where every kind it\n // declares is a duplicate — which is worse than either end state.\n if (exclude.write !== null) writes.push(exclude.write);\n // One lock, one journal, one commit for both kinds of file — a sync killed\n // between the views swap and the project creates would otherwise leave a\n // half-state no later run could tell from a team's deliberate deletion.\n const staged = await stageWrites(writes);\n const committed = await commitStaged(\n { root: docsDir, command: \"subsystem\", rerun: \"loam subsystem sync\", target: \"subsystems\" },\n staged,\n \"synced\",\n );\n if (!committed.ok) {\n fail(json, committed.code, committed.message);\n return;\n }\n say();\n } finally {\n await releaseLock();\n }\n}\n\n/**\n * What the project half of this run owes, from ONE predicate. `surveyProjects`\n * is the shared spelling of \"has a model, a legal id, and no file\", and it\n * hands back the sizes of the two domains it counted against — every model it\n * walked, and the standalone models a file is owed for — so `current` is a\n * subtraction rather than a second reading of the same two paths. A loop here\n * re-spelling \"has a model\" was the drift the shared predicate exists to\n * prevent, and it would have kept counting a directory the survey had\n * skipped. Without the root file the gaps are real but stay unfilled —\n * writing them would promise a renderer nobody can open — and `current` is 0\n * because \"already had a file\" is only a fact about a workspace that exists.\n */\nfunction planProjects(\n docsDir: DocsDir,\n services: readonly WalkedService[],\n shapes: ReadonlyMap<string, ModelShape>,\n): ProjectPlan {\n const root = existsSync(rootProjectPath(docsDir));\n // A model that EXTENDS the map is owed no file, and the survey is where that\n // is decided — one predicate for the writer and the grader, so `validate --all`\n // can never name a gap this run would not fill. An unreadable model classifies\n // as standalone (`readModelShapes`), which is the conservative arm: it gets a\n // project file, which is what every model got before shapes existed.\n const survey = surveyProjects(services, serviceRenderPaths, (model) => shapes.get(resolve(model)) !== \"extending\");\n if (!root) return { root, gaps: [], strays: [], current: 0, modelled: survey.modelled, models: survey.models };\n return {\n root,\n gaps: survey.gaps,\n // The removal is gated on the root file for the same reason the create is:\n // without it the docs root is not a LikeC4 workspace, so nothing there is\n // claiming anything out of a root project that does not exist, and deleting\n // a team's file over a renderer nobody can open is a writer acting on a\n // hazard it cannot see.\n strays: survey.strays,\n // Over the STANDALONE domain, which is the one `gaps` was drawn from: a\n // model that extends the map is owed no file, so it can neither be a gap nor\n // \"already have one\", and subtracting from `modelled` counted every\n // extending model as the latter.\n current: survey.standalone - survey.gaps.length,\n modelled: survey.modelled,\n models: survey.models,\n };\n}\n"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ROOT `likec4.config.json`'s `exclude` list, as `loam subsystem sync`
|
|
3
|
+
* derives it from the shapes on disk.
|
|
4
|
+
*
|
|
5
|
+
* It sits beside `./views.ts` for that module's reason and by the same seam:
|
|
6
|
+
* both answer "what should this renderer-only file say, given the tree?", both
|
|
7
|
+
* are pure derivations one command writes, and keeping them together is what
|
|
8
|
+
* stops the writer and the grader spelling one rule twice. The difference is
|
|
9
|
+
* ownership, and it is stated in `core/c4/service-model/renderer.ts`: every byte
|
|
10
|
+
* of the generated views file is loam's, while this file is the team's and loam
|
|
11
|
+
* maintains exactly the `services/` entries in it. What an entry COVERS is
|
|
12
|
+
* `core/c4/root-project/exclude.ts`'s question, asked of the directory the entry
|
|
13
|
+
* names rather than of its spelling.
|
|
14
|
+
*
|
|
15
|
+
* It is a module rather than three functions in `../sync.ts` because that file
|
|
16
|
+
* reached its line limit carrying them, and this is the phase boundary inside
|
|
17
|
+
* it: `sync.ts` is the lock, the transaction and the report; this is one of the
|
|
18
|
+
* three things it decides to write.
|
|
19
|
+
*/
|
|
20
|
+
import { readFile } from "node:fs/promises";
|
|
21
|
+
import { excludingEntry, parseRootProject, readRootExclude } from "../../../core/c4/root-project/exclude.js";
|
|
22
|
+
import { standaloneExclude } from "../../../core/c4/service-model/renderer.js";
|
|
23
|
+
import { serviceTreePath } from "../../../core/kernel/ids/dirs.js";
|
|
24
|
+
import { rootProjectPath } from "../../../core/repo/paths.js";
|
|
25
|
+
import { planWrite } from "../../../core/staging/writes.js";
|
|
26
|
+
/** The answer for a run that has no root file to read, and the shape every other arm fills. */
|
|
27
|
+
export const NO_EXCLUDE = {
|
|
28
|
+
updated: false,
|
|
29
|
+
entries: [],
|
|
30
|
+
added: [],
|
|
31
|
+
removed: [],
|
|
32
|
+
write: null,
|
|
33
|
+
unreadable: false,
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The root project's `exclude` list, recomputed from the shapes on disk.
|
|
37
|
+
*
|
|
38
|
+
* WHAT MAKES THIS SAFE TO RUN ON EVERY SYNC is the split `standaloneExclude`
|
|
39
|
+
* enforces: the `services/` half of the list is loam's and every other entry is
|
|
40
|
+
* the team's, kept in order. The scaffold's node_modules glob, `features/**`, a
|
|
41
|
+
* team's own `drafts/**` all survive; only the entries that decide whether a
|
|
42
|
+
* model is renderable are derived. A standalone model MUST be excluded (inside
|
|
43
|
+
* the root project every kind it declares is a duplicate blamed on the map as
|
|
44
|
+
* well) and an extending model must NOT be (the root project is the only place
|
|
45
|
+
* it parses), so a service that migrates from one shape to the other has its
|
|
46
|
+
* entry added or dropped on the next sync instead of quietly blanking a project.
|
|
47
|
+
*
|
|
48
|
+
* THE GATE keeps an old repository untouched. A fleet whose models all stand
|
|
49
|
+
* alone and whose root already says `services/**` is already correct, and
|
|
50
|
+
* rewriting it into one entry per service would be a diff with no fact behind
|
|
51
|
+
* it — so the rewrite happens only when at least one model extends the map (the
|
|
52
|
+
* blanket exclusion is then wrong) or some standalone model is not covered at
|
|
53
|
+
* all (the renderer is merging it into the map right now). Comparing the parsed
|
|
54
|
+
* ARRAYS rather than the bytes is the second half of the same rule: a file whose
|
|
55
|
+
* `exclude` already says what this run would write is left exactly as the team
|
|
56
|
+
* formatted it.
|
|
57
|
+
*
|
|
58
|
+
* A root config loam cannot read an `exclude` list out of is REPORTED and never
|
|
59
|
+
* rewritten. Guessing at the JSON a team hand-wrote is how a writer destroys a
|
|
60
|
+
* file it did not understand.
|
|
61
|
+
*/
|
|
62
|
+
export async function planExclude(docsDir, services, models) {
|
|
63
|
+
const current = await readRootExclude(docsDir);
|
|
64
|
+
if (current === null)
|
|
65
|
+
return { ...NO_EXCLUDE, unreadable: true };
|
|
66
|
+
const standalone = models.filter((m) => m.standalone).map((m) => serviceTreePath(m.service));
|
|
67
|
+
// Both halves of the shape scan travel, not just the standalone one: an entry
|
|
68
|
+
// is loam's to take back either because loam wrote it (a tree the enumeration
|
|
69
|
+
// returns) or because it HIDES a model that only parses in the root project,
|
|
70
|
+
// and only the extending list can answer the second question. Without it a
|
|
71
|
+
// subsystem-wide `services/platform/**` survived every sync while
|
|
72
|
+
// `service.model-excluded` named that same sync as the repair.
|
|
73
|
+
const extending = models.filter((m) => !m.standalone).map((m) => serviceTreePath(m.service));
|
|
74
|
+
const wanted = standaloneExclude(current, {
|
|
75
|
+
standalone,
|
|
76
|
+
extending,
|
|
77
|
+
enumerated: services.map((svc) => serviceTreePath(svc)),
|
|
78
|
+
});
|
|
79
|
+
const uncovered = standalone.some((tree) => excludingEntry(current, tree) === null);
|
|
80
|
+
if (extending.length === 0 && !uncovered)
|
|
81
|
+
return { ...NO_EXCLUDE, entries: [...current] };
|
|
82
|
+
if (current.length === wanted.length && current.every((entry, i) => entry === wanted[i])) {
|
|
83
|
+
return { ...NO_EXCLUDE, entries: wanted };
|
|
84
|
+
}
|
|
85
|
+
const bytes = await rewrittenRootProject(docsDir, wanted);
|
|
86
|
+
if (bytes === null)
|
|
87
|
+
return { ...NO_EXCLUDE, entries: [...current], unreadable: true };
|
|
88
|
+
return {
|
|
89
|
+
updated: true,
|
|
90
|
+
entries: wanted,
|
|
91
|
+
added: wanted.filter((entry) => !current.includes(entry)),
|
|
92
|
+
removed: current.filter((entry) => !wanted.includes(entry)),
|
|
93
|
+
// `planWrite` decides create-vs-overwrite from the filesystem, so the root
|
|
94
|
+
// file — which by definition already exists here — is staged as an
|
|
95
|
+
// OVERWRITE, and `swapStaged` compares it against its pre-image immediately
|
|
96
|
+
// before the rename: a team member editing the same file during the sync
|
|
97
|
+
// stops the commit instead of having their bytes buried.
|
|
98
|
+
write: planWrite(rootProjectPath(docsDir), bytes),
|
|
99
|
+
unreadable: false,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The root project file with its `exclude` replaced and NOTHING else touched —
|
|
104
|
+
* every other key kept, in the order the team wrote them, re-serialised as
|
|
105
|
+
* 2-space JSON with a trailing newline (`core/docs.ts`'s own form, so a
|
|
106
|
+
* scaffolded file round-trips byte for byte).
|
|
107
|
+
*
|
|
108
|
+
* Null when the file stopped being a JSON object between `readRootExclude` and
|
|
109
|
+
* here, which is a concurrent edit rather than a state loam may write over.
|
|
110
|
+
*/
|
|
111
|
+
async function rewrittenRootProject(docsDir, exclude) {
|
|
112
|
+
let text;
|
|
113
|
+
try {
|
|
114
|
+
text = await readFile(rootProjectPath(docsDir), "utf8");
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
// Unreadable is not "excludes nothing": the caller reports it and writes
|
|
118
|
+
// nothing at all.
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
// The SAME parse the grader read the list with — `parseRootProject`, which
|
|
122
|
+
// tolerates the byte-order mark PowerShell's `Out-File` writes. Two parses
|
|
123
|
+
// would mean a run that read an `exclude` here and then declared the file
|
|
124
|
+
// unreadable at the write, which is exactly what a BOM produced before
|
|
125
|
+
// (re-verification 2026-09-04, area C item 3). Re-read rather than carried:
|
|
126
|
+
// the point of this read is that it happens immediately before the swap.
|
|
127
|
+
const parsed = parseRootProject(text);
|
|
128
|
+
if (parsed === null)
|
|
129
|
+
return null;
|
|
130
|
+
return `${JSON.stringify({ ...parsed, exclude: [...exclude] }, null, 2)}\n`;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=exclude.js.map
|