@topogram/cli 0.3.63 → 0.3.65
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/package.json +1 -1
- package/src/adoption/plan/index.js +703 -0
- package/src/adoption/plan.d.ts +6 -0
- package/src/adoption/plan.js +12 -703
- package/src/adoption/reporting.d.ts +10 -0
- package/src/adoption/review-groups.d.ts +6 -0
- package/src/agent-brief.d.ts +3 -0
- package/src/agent-brief.js +495 -0
- package/src/agent-ops/query-builders/auth.js +375 -0
- package/src/agent-ops/query-builders/change-risk/change-plan.js +123 -0
- package/src/agent-ops/query-builders/change-risk/import-plan.js +49 -0
- package/src/agent-ops/query-builders/change-risk/maintained.js +286 -0
- package/src/agent-ops/query-builders/change-risk/review-packets.js +123 -0
- package/src/agent-ops/query-builders/change-risk/risk.js +189 -0
- package/src/agent-ops/query-builders/change-risk.js +25 -0
- package/src/agent-ops/query-builders/common.js +149 -0
- package/src/agent-ops/query-builders/maintained-risk.js +539 -0
- package/src/agent-ops/query-builders/maintained-shared.js +120 -0
- package/src/agent-ops/query-builders/multi-agent.js +547 -0
- package/src/agent-ops/query-builders/projection-impacts.js +514 -0
- package/src/agent-ops/query-builders/work-packets.js +417 -0
- package/src/agent-ops/query-builders/workflow-context-shared.js +300 -0
- package/src/agent-ops/query-builders/workflow-context.js +398 -0
- package/src/agent-ops/query-builders/workflow-presets-core.js +676 -0
- package/src/agent-ops/query-builders/workflow-presets.js +341 -0
- package/src/agent-ops/query-builders.d.ts +26 -0
- package/src/agent-ops/query-builders.js +42 -5021
- package/src/archive/archive.d.ts +2 -0
- package/src/archive/compact.d.ts +1 -0
- package/src/archive/unarchive.d.ts +1 -0
- package/src/catalog/constants.js +10 -0
- package/src/catalog/copy.js +60 -0
- package/src/catalog/diagnostics.js +15 -0
- package/src/catalog/entries.js +42 -0
- package/src/catalog/files.js +67 -0
- package/src/catalog/provenance.js +122 -0
- package/src/catalog/source.js +150 -0
- package/src/catalog/validation.js +252 -0
- package/src/catalog.d.ts +12 -0
- package/src/catalog.js +18 -750
- package/src/cli/catalog-alias.d.ts +1 -0
- package/src/cli/command-parser.js +38 -0
- package/src/cli/command-parsers/core.js +102 -0
- package/src/cli/command-parsers/generator.js +39 -0
- package/src/cli/command-parsers/import.js +44 -0
- package/src/cli/command-parsers/legacy-workflow.js +21 -0
- package/src/cli/command-parsers/project.js +47 -0
- package/src/cli/command-parsers/sdlc.js +47 -0
- package/src/cli/command-parsers/shared.js +51 -0
- package/src/cli/command-parsers/template.js +48 -0
- package/src/cli/commands/agent.js +47 -0
- package/src/cli/commands/catalog/check.js +31 -0
- package/src/cli/commands/catalog/copy.js +59 -0
- package/src/cli/commands/catalog/doctor.js +248 -0
- package/src/cli/commands/catalog/help.js +21 -0
- package/src/cli/commands/catalog/list.js +52 -0
- package/src/cli/commands/catalog/runner.js +92 -0
- package/src/cli/commands/catalog/shared.js +17 -0
- package/src/cli/commands/catalog/show.js +134 -0
- package/src/cli/commands/catalog.js +32 -0
- package/src/cli/commands/check.js +268 -0
- package/src/cli/commands/doctor.js +268 -0
- package/src/cli/commands/emit.js +149 -0
- package/src/cli/commands/generate.js +96 -0
- package/src/cli/commands/generator-policy/package-info.js +162 -0
- package/src/cli/commands/generator-policy/payloads.js +372 -0
- package/src/cli/commands/generator-policy/printers.js +159 -0
- package/src/cli/commands/generator-policy/runner.js +81 -0
- package/src/cli/commands/generator-policy/shared.js +39 -0
- package/src/cli/commands/generator-policy.js +17 -0
- package/src/cli/commands/generator.js +443 -0
- package/src/cli/commands/import/adopt.js +170 -0
- package/src/cli/commands/import/check.js +91 -0
- package/src/cli/commands/import/diff.js +84 -0
- package/src/cli/commands/import/help.js +47 -0
- package/src/cli/commands/import/paths.js +277 -0
- package/src/cli/commands/import/plan.js +284 -0
- package/src/cli/commands/import/refresh.js +470 -0
- package/src/cli/commands/import/status-history.js +196 -0
- package/src/cli/commands/import/workspace.js +230 -0
- package/src/cli/commands/import-runner.js +157 -0
- package/src/cli/commands/import.js +35 -0
- package/src/cli/commands/inspect.js +55 -0
- package/src/cli/commands/new.js +94 -0
- package/src/cli/commands/package/constants.js +17 -0
- package/src/cli/commands/package/doctor.js +240 -0
- package/src/cli/commands/package/help.js +27 -0
- package/src/cli/commands/package/lockfile.js +135 -0
- package/src/cli/commands/package/npm.js +97 -0
- package/src/cli/commands/package/reporting.js +35 -0
- package/src/cli/commands/package/runner.js +33 -0
- package/src/cli/commands/package/shared.js +9 -0
- package/src/cli/commands/package/update-cli.js +252 -0
- package/src/cli/commands/package/versions.js +35 -0
- package/src/cli/commands/package.js +31 -0
- package/src/cli/commands/query/change-plan.js +68 -0
- package/src/cli/commands/query/definitions.js +202 -0
- package/src/cli/commands/query/import-adopt.js +121 -0
- package/src/cli/commands/query/runner/artifacts.js +102 -0
- package/src/cli/commands/query/runner/boundaries.js +211 -0
- package/src/cli/commands/query/runner/change.js +182 -0
- package/src/cli/commands/query/runner/import-adopt.js +111 -0
- package/src/cli/commands/query/runner/index.js +31 -0
- package/src/cli/commands/query/runner/output.js +12 -0
- package/src/cli/commands/query/runner/workflow.js +241 -0
- package/src/cli/commands/query/runner.js +3 -0
- package/src/cli/commands/query/workflow-context.js +5 -0
- package/src/cli/commands/query/workspace.js +274 -0
- package/src/cli/commands/query.js +11 -0
- package/src/cli/commands/release-rollout.js +257 -0
- package/src/cli/commands/release-shared.js +528 -0
- package/src/cli/commands/release-status.js +429 -0
- package/src/cli/commands/release.js +107 -0
- package/src/cli/commands/sdlc.js +168 -0
- package/src/cli/commands/setup.js +76 -0
- package/src/cli/commands/source.js +291 -0
- package/src/cli/commands/template/baseline.js +100 -0
- package/src/cli/commands/template/check.js +466 -0
- package/src/cli/commands/template/constants.js +8 -0
- package/src/cli/commands/template/diagnostics.js +26 -0
- package/src/cli/commands/template/help.js +28 -0
- package/src/cli/commands/template/lifecycle.js +404 -0
- package/src/cli/commands/template/list-show.js +287 -0
- package/src/cli/commands/template/policy.js +422 -0
- package/src/cli/commands/template/shared.js +127 -0
- package/src/cli/commands/template/updates.js +352 -0
- package/src/cli/commands/template-runner.js +198 -0
- package/src/cli/commands/template.js +43 -0
- package/src/cli/commands/trust.js +219 -0
- package/src/cli/commands/version.js +40 -0
- package/src/cli/commands/widget.js +168 -0
- package/src/cli/commands/workflow.js +63 -0
- package/src/cli/dispatcher.js +392 -0
- package/src/cli/help-dispatch.js +188 -0
- package/src/cli/help.js +296 -0
- package/src/cli/migration-guidance.js +59 -0
- package/src/cli/options.js +96 -0
- package/src/cli/output-safety.js +107 -0
- package/src/cli/path-normalization.js +29 -0
- package/src/cli.js +47 -11711
- package/src/example-implementation.d.ts +2 -0
- package/src/format.d.ts +1 -0
- package/src/generator/api/contracts.js +497 -0
- package/src/generator/api/metadata.js +221 -0
- package/src/generator/api/openapi.js +559 -0
- package/src/generator/api/schema.js +124 -0
- package/src/generator/api/types.d.ts +98 -0
- package/src/generator/api.js +3 -1195
- package/src/generator/check.d.ts +1 -0
- package/src/generator/context/bundle.d.ts +1 -0
- package/src/generator/context/shared/domain-sdlc.js +282 -0
- package/src/generator/context/shared/maintained-boundary.js +665 -0
- package/src/generator/context/shared/metrics.js +85 -0
- package/src/generator/context/shared/primitives.js +64 -0
- package/src/generator/context/shared/relationships.js +453 -0
- package/src/generator/context/shared/summaries.js +263 -0
- package/src/generator/context/shared/types.d.ts +207 -0
- package/src/generator/context/shared.d.ts +44 -0
- package/src/generator/context/shared.js +80 -1390
- package/src/generator/context/slice/core.js +397 -0
- package/src/generator/context/slice/sdlc.js +417 -0
- package/src/generator/context/slice/ui-packets.js +183 -0
- package/src/generator/context/slice.js +2 -859
- package/src/generator/native/parity-bundle.js +2 -1
- package/src/generator/registry/index.js +507 -0
- package/src/generator/registry.js +18 -504
- package/src/generator/runtime/environment/index.js +666 -0
- package/src/generator/runtime/environment.js +4 -666
- package/src/generator/runtime/runtime-check/index.js +554 -0
- package/src/generator/runtime/runtime-check.js +4 -554
- package/src/generator/runtime/shared/index.js +572 -0
- package/src/generator/runtime/shared.js +19 -570
- package/src/generator/shared.d.ts +2 -0
- package/src/generator/surfaces/shared.d.ts +3 -0
- package/src/generator/surfaces/web/html-escape.js +22 -0
- package/src/generator/surfaces/web/react.js +10 -8
- package/src/generator/surfaces/web/sveltekit.js +7 -5
- package/src/generator/surfaces/web/vanilla.js +8 -4
- package/src/generator/widget-conformance/behavior-report.js +258 -0
- package/src/generator/widget-conformance/checks.js +371 -0
- package/src/generator/widget-conformance/projection-context.js +200 -0
- package/src/generator/widget-conformance/report.js +166 -0
- package/src/generator/widget-conformance/types.d.ts +121 -0
- package/src/generator/widget-conformance.js +3 -824
- package/src/generator.d.ts +2 -0
- package/src/github-client.js +520 -0
- package/src/import/core/context.d.ts +3 -0
- package/src/import/core/contracts.d.ts +1 -0
- package/src/import/core/registry.d.ts +4 -0
- package/src/import/core/runner/candidates.js +217 -0
- package/src/import/core/runner/options.js +22 -0
- package/src/import/core/runner/reports.js +50 -0
- package/src/import/core/runner/run.js +79 -0
- package/src/import/core/runner/tracks.js +150 -0
- package/src/import/core/runner/ui-drafts.js +337 -0
- package/src/import/core/runner.js +3 -698
- package/src/import/core/shared/api-routes.js +221 -0
- package/src/import/core/shared/candidates.js +97 -0
- package/src/import/core/shared/files.js +177 -0
- package/src/import/core/shared/next-app.js +389 -0
- package/src/import/core/shared/types.d.ts +51 -0
- package/src/import/core/shared/ui-routes.js +230 -0
- package/src/import/core/shared.js +67 -910
- package/src/import/extractors/api/flutter-dio.js +4 -8
- package/src/import/extractors/api/react-native-repository.js +4 -8
- package/src/import/index.d.ts +4 -0
- package/src/import/provenance.d.ts +4 -0
- package/src/new-project/constants.js +128 -0
- package/src/new-project/create.js +83 -0
- package/src/new-project/json.js +28 -0
- package/src/new-project/metadata.js +96 -0
- package/src/new-project/package-spec.js +161 -0
- package/src/new-project/project-files.js +348 -0
- package/src/new-project/template-policy.js +269 -0
- package/src/new-project/template-resolution.js +368 -0
- package/src/new-project/template-snapshots.js +430 -0
- package/src/new-project/template-updates.js +512 -0
- package/src/new-project/types.d.ts +83 -0
- package/src/new-project.js +6 -2188
- package/src/npm-safety.js +79 -0
- package/src/parser.d.ts +87 -0
- package/src/parser.js +118 -0
- package/src/path-helpers.d.ts +1 -0
- package/src/path-helpers.js +20 -0
- package/src/policy/review-boundaries.d.ts +15 -0
- package/src/project-config/index.js +564 -0
- package/src/project-config.js +19 -560
- package/src/reconcile/docs.d.ts +8 -0
- package/src/reconcile/journeys.d.ts +1 -0
- package/src/resolver/enrich/acceptance-criterion.js +2 -0
- package/src/resolver/enrich/bug.js +2 -0
- package/src/resolver/enrich/pitch.js +2 -0
- package/src/resolver/enrich/requirement.js +2 -0
- package/src/resolver/enrich/task.js +2 -0
- package/src/resolver/index.js +19 -2089
- package/src/resolver/normalize.js +384 -1
- package/src/resolver/plans.js +168 -0
- package/src/resolver/projections-api.js +494 -0
- package/src/resolver/projections-db.js +133 -0
- package/src/resolver/projections-ui.js +317 -0
- package/src/resolver/shapes.js +251 -0
- package/src/resolver/shared.js +278 -0
- package/src/resolver/widgets.js +132 -0
- package/src/resolver.d.ts +1 -0
- package/src/runtime-support.js +29 -0
- package/src/sdlc/adopt.d.ts +1 -0
- package/src/sdlc/check.d.ts +1 -0
- package/src/sdlc/explain.d.ts +1 -0
- package/src/sdlc/release.d.ts +1 -0
- package/src/sdlc/scaffold.d.ts +1 -0
- package/src/sdlc/transition.d.ts +1 -0
- package/src/template-trust/constants.js +62 -0
- package/src/template-trust/content.js +258 -0
- package/src/template-trust/diff.js +92 -0
- package/src/template-trust/policy.js +61 -0
- package/src/template-trust/record.js +90 -0
- package/src/template-trust/status.js +182 -0
- package/src/template-trust.js +24 -687
- package/src/text-helpers.d.ts +7 -0
- package/src/text-helpers.js +245 -0
- package/src/topogram-config.js +306 -0
- package/src/topogram-types.d.ts +69 -0
- package/src/validator/common.js +488 -0
- package/src/validator/data-model.js +237 -0
- package/src/validator/docs.js +167 -0
- package/src/validator/expressions.js +146 -1
- package/src/validator/index.d.ts +23 -0
- package/src/validator/index.js +32 -3585
- package/src/validator/kinds.d.ts +41 -0
- package/src/validator/kinds.js +2 -0
- package/src/validator/model-helpers.js +46 -0
- package/src/validator/per-kind/acceptance-criterion.js +5 -0
- package/src/validator/per-kind/bug.js +6 -0
- package/src/validator/per-kind/domain.js +15 -2
- package/src/validator/per-kind/pitch.js +7 -0
- package/src/validator/per-kind/requirement.js +5 -0
- package/src/validator/per-kind/task.js +7 -0
- package/src/validator/per-kind/widget.js +14 -0
- package/src/validator/projections/api-http-async.js +410 -0
- package/src/validator/projections/api-http-authz.js +88 -0
- package/src/validator/projections/api-http-core.js +205 -0
- package/src/validator/projections/api-http-policies.js +339 -0
- package/src/validator/projections/api-http-responses.js +233 -0
- package/src/validator/projections/api-http.js +44 -0
- package/src/validator/projections/db.js +353 -0
- package/src/validator/projections/generator-defaults.js +45 -0
- package/src/validator/projections/helpers.js +87 -0
- package/src/validator/projections/ui-helpers.js +214 -0
- package/src/validator/projections/ui-navigation.js +344 -0
- package/src/validator/projections/ui-structure.js +364 -0
- package/src/validator/projections/ui-widgets.js +493 -0
- package/src/validator/projections/ui.js +46 -0
- package/src/validator/registry.js +48 -1
- package/src/validator/utils.d.ts +20 -0
- package/src/validator/utils.js +115 -12
- package/src/validator.d.ts +2 -0
- package/src/widget-behavior.d.ts +1 -0
- package/src/workflows/adoption/index.js +26 -0
- package/src/workflows/docs-generate.js +262 -0
- package/src/workflows/docs-scan.js +703 -0
- package/src/workflows/docs.js +15 -0
- package/src/workflows/import-app/api/collect.js +221 -0
- package/src/workflows/import-app/api/openapi.js +257 -0
- package/src/workflows/import-app/api/routes.js +327 -0
- package/src/workflows/import-app/api/sources.js +22 -0
- package/src/workflows/import-app/api.js +4 -0
- package/src/workflows/import-app/db.js +538 -0
- package/src/workflows/import-app/index.js +30 -0
- package/src/workflows/import-app/shared.js +218 -0
- package/src/workflows/import-app/ui.js +443 -0
- package/src/workflows/import-app/workflow.js +159 -0
- package/src/workflows/reconcile/adoption-plan/build.js +208 -0
- package/src/workflows/reconcile/adoption-plan/dependencies.js +75 -0
- package/src/workflows/reconcile/adoption-plan/outputs.js +143 -0
- package/src/workflows/reconcile/adoption-plan/paths.js +58 -0
- package/src/workflows/reconcile/adoption-plan/projection-patches.js +177 -0
- package/src/workflows/reconcile/adoption-plan/reasons.js +107 -0
- package/src/workflows/reconcile/adoption-plan.js +32 -0
- package/src/workflows/reconcile/auth/closures.js +115 -0
- package/src/workflows/reconcile/auth/formatters.js +142 -0
- package/src/workflows/reconcile/auth/inference.js +330 -0
- package/src/workflows/reconcile/auth/roles.js +122 -0
- package/src/workflows/reconcile/auth.js +37 -0
- package/src/workflows/reconcile/bundle-core/index.js +600 -0
- package/src/workflows/reconcile/bundle-core.js +14 -0
- package/src/workflows/reconcile/bundle-shared.js +75 -0
- package/src/workflows/reconcile/candidate-model.js +477 -0
- package/src/workflows/reconcile/canonical-surface.js +264 -0
- package/src/workflows/reconcile/gap-report.js +333 -0
- package/src/workflows/reconcile/ids.js +6 -0
- package/src/workflows/reconcile/impacts/adoption-plan.js +192 -0
- package/src/workflows/reconcile/impacts/indexes.js +101 -0
- package/src/workflows/reconcile/impacts/patches.js +252 -0
- package/src/workflows/reconcile/impacts/reports.js +80 -0
- package/src/workflows/reconcile/impacts.js +16 -0
- package/src/workflows/reconcile/index.js +7 -0
- package/src/workflows/reconcile/renderers.js +461 -0
- package/src/workflows/reconcile/summary.js +90 -0
- package/src/workflows/reconcile/workflow.js +309 -0
- package/src/workflows/shared.js +189 -0
- package/src/workflows/types.d.ts +93 -0
- package/src/workflows.d.ts +1 -0
- package/src/workflows.js +10 -7652
- package/src/workspace-docs.d.ts +29 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { docDirForKind } from "../../docs.js";
|
|
3
|
+
import { dashedTopogramId } from "../ids.js";
|
|
4
|
+
import { shapeFieldSignature } from "./indexes.js";
|
|
5
|
+
|
|
6
|
+
/** @param {CandidateBundle} bundle @param {any} canonicalShapeIndex @returns {any} */
|
|
7
|
+
export function buildBundleAdoptionPlan(bundle, canonicalShapeIndex) {
|
|
8
|
+
/** @type {any[]} */
|
|
9
|
+
const steps = [];
|
|
10
|
+
for (const entry of bundle.actors) {
|
|
11
|
+
steps.push({
|
|
12
|
+
action: "promote_actor",
|
|
13
|
+
item: entry.id_hint,
|
|
14
|
+
target: null,
|
|
15
|
+
confidence: entry.confidence || "low",
|
|
16
|
+
inference_summary: entry.inference_summary || null,
|
|
17
|
+
related_docs: entry.related_docs || [],
|
|
18
|
+
related_capabilities: entry.related_capabilities || [],
|
|
19
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/actors/${entry.id_hint}.tg`,
|
|
20
|
+
canonical_rel_path: `actors/${dashedTopogramId(entry.id_hint)}.tg`
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
for (const entry of bundle.roles) {
|
|
24
|
+
steps.push({
|
|
25
|
+
action: "promote_role",
|
|
26
|
+
item: entry.id_hint,
|
|
27
|
+
target: null,
|
|
28
|
+
confidence: entry.confidence || "low",
|
|
29
|
+
inference_summary: entry.inference_summary || null,
|
|
30
|
+
related_docs: entry.related_docs || [],
|
|
31
|
+
related_capabilities: entry.related_capabilities || [],
|
|
32
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/roles/${entry.id_hint}.tg`,
|
|
33
|
+
canonical_rel_path: `roles/${dashedTopogramId(entry.id_hint)}.tg`
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (bundle.mergeHints?.canonicalEntityTarget) {
|
|
37
|
+
steps.push({
|
|
38
|
+
action: "merge_bundle_into_existing_entity",
|
|
39
|
+
item: bundle.slug,
|
|
40
|
+
target: bundle.mergeHints.canonicalEntityTarget
|
|
41
|
+
});
|
|
42
|
+
} else if (bundle.entities.length > 0) {
|
|
43
|
+
for (const entry of bundle.entities) {
|
|
44
|
+
steps.push({
|
|
45
|
+
action: "promote_entity",
|
|
46
|
+
item: entry.id_hint,
|
|
47
|
+
target: null
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
for (const entry of bundle.enums) {
|
|
52
|
+
steps.push({
|
|
53
|
+
action: "promote_enum",
|
|
54
|
+
item: entry.id_hint,
|
|
55
|
+
target: bundle.mergeHints?.canonicalEntityTarget || null
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
for (const entry of bundle.capabilities) {
|
|
59
|
+
steps.push({
|
|
60
|
+
action: bundle.mergeHints?.canonicalEntityTarget ? "merge_capability_into_existing_entity" : "promote_capability",
|
|
61
|
+
item: entry.id_hint,
|
|
62
|
+
target: bundle.mergeHints?.canonicalEntityTarget || null
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
for (const entry of bundle.shapes) {
|
|
66
|
+
const signature = shapeFieldSignature(entry.fields || []);
|
|
67
|
+
const duplicateTargets = canonicalShapeIndex.get(signature) || [];
|
|
68
|
+
if (duplicateTargets.length > 0) {
|
|
69
|
+
steps.push({
|
|
70
|
+
action: "skip_duplicate_shape",
|
|
71
|
+
item: entry.id,
|
|
72
|
+
target: duplicateTargets[0]
|
|
73
|
+
});
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
steps.push({
|
|
77
|
+
action: "promote_shape",
|
|
78
|
+
item: entry.id,
|
|
79
|
+
target: bundle.mergeHints?.canonicalEntityTarget || null
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
for (const entry of bundle.docs) {
|
|
83
|
+
if (entry.existing_canonical) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
steps.push({
|
|
87
|
+
action: entry.kind === "workflow" ? "promote_workflow_doc" : "promote_doc",
|
|
88
|
+
item: entry.id,
|
|
89
|
+
target: null,
|
|
90
|
+
doc_kind: entry.kind,
|
|
91
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/docs/${docDirForKind(entry.kind)}/${entry.id}.md`,
|
|
92
|
+
canonical_rel_path: `docs/${docDirForKind(entry.kind)}/${entry.id}.md`
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
for (const entry of bundle.workflows) {
|
|
96
|
+
steps.push({
|
|
97
|
+
action: "promote_workflow_decision",
|
|
98
|
+
item: `dec_${entry.id_hint.replace(/^workflow_/, "")}`,
|
|
99
|
+
target: null,
|
|
100
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/decisions/dec_${entry.id_hint.replace(/^workflow_/, "")}.tg`,
|
|
101
|
+
canonical_rel_path: `decisions/decision-${dashedTopogramId(entry.id_hint.replace(/^workflow_/, ""))}.tg`
|
|
102
|
+
});
|
|
103
|
+
steps.push({
|
|
104
|
+
action: "promote_workflow_doc",
|
|
105
|
+
item: entry.id_hint,
|
|
106
|
+
target: null,
|
|
107
|
+
doc_kind: "workflow",
|
|
108
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/docs/workflows/${entry.id_hint}.md`,
|
|
109
|
+
canonical_rel_path: `docs/workflows/${entry.id_hint}.md`
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
for (const entry of bundle.verifications || []) {
|
|
113
|
+
steps.push({
|
|
114
|
+
action: "promote_verification",
|
|
115
|
+
item: entry.id_hint,
|
|
116
|
+
target: null,
|
|
117
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/verifications/${entry.id_hint}.tg`,
|
|
118
|
+
canonical_rel_path: `verifications/${dashedTopogramId(entry.id_hint)}.tg`
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
for (const entry of bundle.widgets || []) {
|
|
122
|
+
steps.push({
|
|
123
|
+
action: "promote_widget",
|
|
124
|
+
item: entry.id_hint,
|
|
125
|
+
target: null,
|
|
126
|
+
confidence: entry.confidence || "low",
|
|
127
|
+
inference_summary: entry.inference_summary || null,
|
|
128
|
+
related_capabilities: [entry.data_source].filter(Boolean),
|
|
129
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/widgets/${entry.id_hint}.tg`,
|
|
130
|
+
canonical_rel_path: `widgets/${dashedTopogramId(entry.id_hint)}.tg`
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
for (const screen of bundle.screens) {
|
|
134
|
+
steps.push({
|
|
135
|
+
action: "promote_ui_report",
|
|
136
|
+
item: `ui_${screen.id_hint}`,
|
|
137
|
+
target: null,
|
|
138
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/docs/reports/ui-${screen.id_hint}.md`,
|
|
139
|
+
canonical_rel_path: `docs/reports/ui-${screen.id_hint}.md`
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
for (const patch of bundle.projectionPatches || []) {
|
|
143
|
+
for (const hint of patch.missing_auth_permissions || []) {
|
|
144
|
+
steps.push({
|
|
145
|
+
action: "apply_projection_permission_patch",
|
|
146
|
+
item: `projection_permission_patch:${patch.projection_id}:${hint.projection_surface}:${hint.permission}`,
|
|
147
|
+
target: patch.projection_id,
|
|
148
|
+
projection_kind: patch.kind,
|
|
149
|
+
projection_surface: hint.projection_surface,
|
|
150
|
+
permission: hint.permission,
|
|
151
|
+
confidence: hint.confidence || "low",
|
|
152
|
+
inference_summary: hint.why_inferred || hint.explanation || null,
|
|
153
|
+
related_capabilities: hint.related_capabilities || [],
|
|
154
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/${patch.patch_rel_path}`,
|
|
155
|
+
canonical_rel_path: `projections/${dashedTopogramId(patch.projection_id)}.tg`
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
for (const hint of patch.missing_auth_claims || []) {
|
|
159
|
+
steps.push({
|
|
160
|
+
action: "apply_projection_auth_patch",
|
|
161
|
+
item: `projection_auth_patch:${patch.projection_id}:${hint.projection_surface}:${hint.claim}`,
|
|
162
|
+
target: patch.projection_id,
|
|
163
|
+
projection_kind: patch.kind,
|
|
164
|
+
projection_surface: hint.projection_surface,
|
|
165
|
+
claim: hint.claim,
|
|
166
|
+
claim_value: hint.claim_value,
|
|
167
|
+
confidence: hint.confidence || "low",
|
|
168
|
+
inference_summary: hint.why_inferred || hint.explanation || null,
|
|
169
|
+
related_capabilities: hint.related_capabilities || [],
|
|
170
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/${patch.patch_rel_path}`,
|
|
171
|
+
canonical_rel_path: `projections/${dashedTopogramId(patch.projection_id)}.tg`
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
for (const hint of patch.missing_auth_ownerships || []) {
|
|
175
|
+
steps.push({
|
|
176
|
+
action: "apply_projection_ownership_patch",
|
|
177
|
+
item: `projection_ownership_patch:${patch.projection_id}:${hint.ownership_field}`,
|
|
178
|
+
target: patch.projection_id,
|
|
179
|
+
projection_kind: patch.kind,
|
|
180
|
+
projection_surface: "authorization",
|
|
181
|
+
ownership: hint.ownership,
|
|
182
|
+
ownership_field: hint.ownership_field,
|
|
183
|
+
confidence: hint.confidence || "low",
|
|
184
|
+
inference_summary: hint.why_inferred || hint.explanation || null,
|
|
185
|
+
related_capabilities: hint.related_capabilities || [],
|
|
186
|
+
source_path: `candidates/reconcile/model/bundles/${bundle.slug}/${patch.patch_rel_path}`,
|
|
187
|
+
canonical_rel_path: `projections/${dashedTopogramId(patch.projection_id)}.tg`
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return steps;
|
|
192
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/** @param {any[]} fields @returns {any} */
|
|
4
|
+
export function shapeFieldSignature(fields) {
|
|
5
|
+
return [...new Set((fields || []).filter(Boolean))].sort().join("|");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** @param {ResolvedGraph} graph @returns {any} */
|
|
9
|
+
export function buildCanonicalShapeIndex(graph) {
|
|
10
|
+
const bySignature = new Map();
|
|
11
|
+
for (const shape of graph?.byKind.shape || []) {
|
|
12
|
+
const fields = (shape.projectedFields || shape.fields || []).map((/** @type {any} */ field) => field.name).filter(Boolean);
|
|
13
|
+
const signature = shapeFieldSignature(fields);
|
|
14
|
+
if (!signature) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (!bySignature.has(signature)) {
|
|
18
|
+
bySignature.set(signature, []);
|
|
19
|
+
}
|
|
20
|
+
bySignature.get(signature).push(shape.id);
|
|
21
|
+
}
|
|
22
|
+
return bySignature;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @param {WorkflowRecord} capability @returns {any} */
|
|
26
|
+
export function capabilityEntityTargets(capability) {
|
|
27
|
+
return [
|
|
28
|
+
...(capability.creates || []),
|
|
29
|
+
...(capability.updates || []),
|
|
30
|
+
...(capability.deletes || []),
|
|
31
|
+
...(capability.reads || [])
|
|
32
|
+
]
|
|
33
|
+
.map((/** @type {any} */ ref) => ref?.id || ref?.target?.id || null)
|
|
34
|
+
.filter((/** @type {any} */ id) => typeof id === "string" && id.startsWith("entity_"));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** @param {WorkflowRecord} projection @returns {any} */
|
|
38
|
+
export function projectionKindForImpact(projection) {
|
|
39
|
+
if ((projection.http || []).length > 0 || projection.type === "api_contract") {
|
|
40
|
+
return "api";
|
|
41
|
+
}
|
|
42
|
+
if (
|
|
43
|
+
(projection.uiRoutes || []).length > 0 ||
|
|
44
|
+
(projection.uiWeb || []).length > 0 ||
|
|
45
|
+
(projection.uiIos || []).length > 0 ||
|
|
46
|
+
projection.type === "web_surface" ||
|
|
47
|
+
projection.type === "ios_surface"
|
|
48
|
+
) {
|
|
49
|
+
return "ui";
|
|
50
|
+
}
|
|
51
|
+
if ((projection.dbTables || []).length > 0) {
|
|
52
|
+
return "db";
|
|
53
|
+
}
|
|
54
|
+
return "other";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @param {ResolvedGraph} graph @returns {any} */
|
|
58
|
+
export function buildProjectionEntityIndex(graph) {
|
|
59
|
+
const projections = graph?.byKind.projection || [];
|
|
60
|
+
const capabilities = new Map((graph?.byKind.capability || []).map((/** @type {any} */ capability) => [capability.id, capability]));
|
|
61
|
+
const projectionsById = new Map(projections.map((/** @type {any} */ projection) => [projection.id, projection]));
|
|
62
|
+
const memo = new Map();
|
|
63
|
+
|
|
64
|
+
/** @param {string} projectionId @param {any} stack @returns {any} */
|
|
65
|
+
function collectEntities(projectionId, stack = new Set()) {
|
|
66
|
+
if (memo.has(projectionId)) {
|
|
67
|
+
return memo.get(projectionId);
|
|
68
|
+
}
|
|
69
|
+
if (stack.has(projectionId)) {
|
|
70
|
+
return new Set();
|
|
71
|
+
}
|
|
72
|
+
stack.add(projectionId);
|
|
73
|
+
const projection = projectionsById.get(projectionId);
|
|
74
|
+
const entities = new Set();
|
|
75
|
+
for (const realized of projection?.realizes || []) {
|
|
76
|
+
const realizedKind = realized?.target?.kind || realized?.kind || null;
|
|
77
|
+
const realizedId = realized?.target?.id || realized?.id || null;
|
|
78
|
+
if (realizedKind === "capability") {
|
|
79
|
+
const capability = capabilities.get(realizedId);
|
|
80
|
+
for (const entityId of capabilityEntityTargets(capability || {})) {
|
|
81
|
+
entities.add(entityId);
|
|
82
|
+
}
|
|
83
|
+
} else if (realizedKind === "projection") {
|
|
84
|
+
for (const entityId of collectEntities(realizedId, stack)) {
|
|
85
|
+
entities.add(entityId);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
memo.set(projectionId, entities);
|
|
90
|
+
stack.delete(projectionId);
|
|
91
|
+
return entities;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return projections.map((/** @type {any} */ projection) => ({
|
|
95
|
+
id: projection.id,
|
|
96
|
+
projection_type: projection.type || null,
|
|
97
|
+
kind: projectionKindForImpact(projection),
|
|
98
|
+
realizes: (projection.realizes || []).map((/** @type {any} */ entry) => entry.id),
|
|
99
|
+
entityIds: [...collectEntities(projection.id)].sort()
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { stableStringify } from "../../../format.js";
|
|
3
|
+
import {
|
|
4
|
+
buildAuthClaimReviewGuidance,
|
|
5
|
+
buildAuthOwnershipReviewGuidance,
|
|
6
|
+
buildAuthPermissionReviewGuidance,
|
|
7
|
+
describeAuthClaimWhyInferred,
|
|
8
|
+
describeAuthOwnershipWhyInferred,
|
|
9
|
+
describeAuthPermissionWhyInferred
|
|
10
|
+
} from "../auth.js";
|
|
11
|
+
|
|
12
|
+
/** @param {CandidateBundle} bundle @returns {any} */
|
|
13
|
+
export function buildProjectionPatchCandidates(bundle) {
|
|
14
|
+
const capabilityById = new Map((bundle.capabilities || []).map((/** @type {any} */ entry) => [entry.id_hint, entry]));
|
|
15
|
+
const routesByScreen = new Map();
|
|
16
|
+
for (const route of bundle.uiRoutes || []) {
|
|
17
|
+
const screenId = route.screen_id || route.id_hint;
|
|
18
|
+
if (!routesByScreen.has(screenId)) {
|
|
19
|
+
routesByScreen.set(screenId, []);
|
|
20
|
+
}
|
|
21
|
+
routesByScreen.get(screenId).push(route);
|
|
22
|
+
}
|
|
23
|
+
const actionsByScreen = new Map();
|
|
24
|
+
for (const action of bundle.uiActions || []) {
|
|
25
|
+
const screenId = action.screen_id || action.id_hint;
|
|
26
|
+
if (!actionsByScreen.has(screenId)) {
|
|
27
|
+
actionsByScreen.set(screenId, []);
|
|
28
|
+
}
|
|
29
|
+
actionsByScreen.get(screenId).push(action);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** @type {any[]} */
|
|
33
|
+
const patches = [];
|
|
34
|
+
for (const impact of bundle.projectionImpacts || []) {
|
|
35
|
+
const missingRealizes = [...(impact.missing_capabilities || [])];
|
|
36
|
+
const missingHttp = impact.kind === "api"
|
|
37
|
+
? missingRealizes
|
|
38
|
+
.map((/** @type {any} */ capabilityId) => capabilityById.get(capabilityId))
|
|
39
|
+
.filter(Boolean)
|
|
40
|
+
.map((/** @type {any} */ entry) => ({
|
|
41
|
+
capability_id: entry.id_hint,
|
|
42
|
+
method: entry.endpoint?.method || "GET",
|
|
43
|
+
path: entry.endpoint?.path || "/"
|
|
44
|
+
}))
|
|
45
|
+
: [];
|
|
46
|
+
patches.push({
|
|
47
|
+
projection_id: impact.projection_id,
|
|
48
|
+
kind: impact.kind,
|
|
49
|
+
projection_type: impact.projection_type,
|
|
50
|
+
reason: impact.reason,
|
|
51
|
+
missing_realizes: missingRealizes,
|
|
52
|
+
missing_http: missingHttp,
|
|
53
|
+
missing_screens: [],
|
|
54
|
+
missing_routes: [],
|
|
55
|
+
missing_actions: []
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (const impact of bundle.uiImpacts || []) {
|
|
60
|
+
const existing = patches.find((/** @type {any} */ patch) => patch.projection_id === impact.projection_id);
|
|
61
|
+
const missingScreens = [...(impact.missing_screens || [])];
|
|
62
|
+
const missingRoutes = missingScreens.flatMap((/** @type {any} */ screenId) => routesByScreen.get(screenId) || []).map((/** @type {any} */ route) => ({
|
|
63
|
+
screen_id: route.screen_id,
|
|
64
|
+
path: route.path
|
|
65
|
+
}));
|
|
66
|
+
const missingActions = missingScreens.flatMap((/** @type {any} */ screenId) => actionsByScreen.get(screenId) || []).map((/** @type {any} */ action) => ({
|
|
67
|
+
screen_id: action.screen_id,
|
|
68
|
+
capability_hint: action.capability_hint
|
|
69
|
+
}));
|
|
70
|
+
if (existing) {
|
|
71
|
+
existing.missing_screens = [...new Set([...(existing.missing_screens || []), ...missingScreens])];
|
|
72
|
+
existing.missing_routes = [...(existing.missing_routes || []), ...missingRoutes];
|
|
73
|
+
existing.missing_actions = [...(existing.missing_actions || []), ...missingActions];
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
patches.push({
|
|
77
|
+
projection_id: impact.projection_id,
|
|
78
|
+
kind: impact.kind,
|
|
79
|
+
projection_type: impact.projection_type,
|
|
80
|
+
reason: impact.reason,
|
|
81
|
+
missing_realizes: [],
|
|
82
|
+
missing_http: [],
|
|
83
|
+
missing_screens: missingScreens,
|
|
84
|
+
missing_routes: missingRoutes,
|
|
85
|
+
missing_actions: missingActions
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
for (const hint of bundle.authClaimHints || []) {
|
|
90
|
+
for (const impact of bundle.projectionImpacts || []) {
|
|
91
|
+
const relatedCapabilities = (impact.missing_capabilities || []).filter((/** @type {any} */ capabilityId) => (hint.related_capabilities || []).includes(capabilityId));
|
|
92
|
+
if (relatedCapabilities.length === 0) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const projectionSurface = impact.kind === "ui" ? "visibility_rules" : "authorization";
|
|
96
|
+
const entry = {
|
|
97
|
+
claim: hint.claim,
|
|
98
|
+
claim_value: hint.claim_value,
|
|
99
|
+
confidence: hint.confidence,
|
|
100
|
+
review_required: true,
|
|
101
|
+
explanation: hint.explanation,
|
|
102
|
+
why_inferred: hint.why_inferred || describeAuthClaimWhyInferred(hint),
|
|
103
|
+
review_guidance: hint.review_guidance || buildAuthClaimReviewGuidance(hint),
|
|
104
|
+
related_capabilities: relatedCapabilities,
|
|
105
|
+
projection_surface: projectionSurface,
|
|
106
|
+
evidence: hint.evidence || {}
|
|
107
|
+
};
|
|
108
|
+
const existing = patches.find((/** @type {any} */ patch) => patch.projection_id === impact.projection_id);
|
|
109
|
+
if (existing) {
|
|
110
|
+
existing.missing_auth_claims = existing.missing_auth_claims || [];
|
|
111
|
+
const duplicate = existing.missing_auth_claims.some((/** @type {any} */ candidate) =>
|
|
112
|
+
candidate.claim === entry.claim &&
|
|
113
|
+
String(candidate.claim_value || "") === String(entry.claim_value || "") &&
|
|
114
|
+
candidate.projection_surface === entry.projection_surface &&
|
|
115
|
+
stableStringify(candidate.related_capabilities || []) === stableStringify(entry.related_capabilities || [])
|
|
116
|
+
);
|
|
117
|
+
if (!duplicate) {
|
|
118
|
+
existing.missing_auth_claims.push(entry);
|
|
119
|
+
}
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
patches.push({
|
|
123
|
+
projection_id: impact.projection_id,
|
|
124
|
+
kind: impact.kind,
|
|
125
|
+
projection_type: impact.projection_type,
|
|
126
|
+
reason: `Projection ${impact.projection_id} likely needs claim-based auth rules for the imported ${bundle.label.toLowerCase()} surface.`,
|
|
127
|
+
missing_realizes: relatedCapabilities,
|
|
128
|
+
missing_http: [],
|
|
129
|
+
missing_screens: [],
|
|
130
|
+
missing_routes: [],
|
|
131
|
+
missing_actions: [],
|
|
132
|
+
missing_auth_claims: [entry]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (const hint of bundle.authPermissionHints || []) {
|
|
138
|
+
for (const impact of bundle.projectionImpacts || []) {
|
|
139
|
+
const relatedCapabilities = (impact.missing_capabilities || []).filter((/** @type {any} */ capabilityId) => (hint.related_capabilities || []).includes(capabilityId));
|
|
140
|
+
if (relatedCapabilities.length === 0) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const projectionSurface = impact.kind === "ui" ? "visibility_rules" : "authorization";
|
|
144
|
+
const entry = {
|
|
145
|
+
permission: hint.permission,
|
|
146
|
+
confidence: hint.confidence,
|
|
147
|
+
review_required: true,
|
|
148
|
+
explanation: hint.explanation,
|
|
149
|
+
why_inferred: hint.why_inferred || describeAuthPermissionWhyInferred(hint),
|
|
150
|
+
review_guidance: hint.review_guidance || buildAuthPermissionReviewGuidance(hint),
|
|
151
|
+
related_capabilities: relatedCapabilities,
|
|
152
|
+
projection_surface: projectionSurface,
|
|
153
|
+
evidence: hint.evidence || {}
|
|
154
|
+
};
|
|
155
|
+
const existing = patches.find((/** @type {any} */ patch) => patch.projection_id === impact.projection_id);
|
|
156
|
+
if (existing) {
|
|
157
|
+
existing.missing_auth_permissions = existing.missing_auth_permissions || [];
|
|
158
|
+
const duplicate = existing.missing_auth_permissions.some((/** @type {any} */ candidate) =>
|
|
159
|
+
candidate.permission === entry.permission &&
|
|
160
|
+
candidate.projection_surface === entry.projection_surface &&
|
|
161
|
+
stableStringify(candidate.related_capabilities || []) === stableStringify(entry.related_capabilities || [])
|
|
162
|
+
);
|
|
163
|
+
if (!duplicate) {
|
|
164
|
+
existing.missing_auth_permissions.push(entry);
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
patches.push({
|
|
169
|
+
projection_id: impact.projection_id,
|
|
170
|
+
kind: impact.kind,
|
|
171
|
+
projection_type: impact.projection_type,
|
|
172
|
+
reason: `Projection ${impact.projection_id} likely needs permission-based auth rules for the imported ${bundle.label.toLowerCase()} surface.`,
|
|
173
|
+
missing_realizes: relatedCapabilities,
|
|
174
|
+
missing_http: [],
|
|
175
|
+
missing_screens: [],
|
|
176
|
+
missing_routes: [],
|
|
177
|
+
missing_actions: [],
|
|
178
|
+
missing_auth_permissions: [entry]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
for (const hint of bundle.authOwnershipHints || []) {
|
|
184
|
+
for (const impact of bundle.projectionImpacts || []) {
|
|
185
|
+
if (impact.kind !== "api") {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
const relatedCapabilities = (impact.missing_capabilities || []).filter((/** @type {any} */ capabilityId) => (hint.related_capabilities || []).includes(capabilityId));
|
|
189
|
+
if (relatedCapabilities.length === 0) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
const entry = {
|
|
193
|
+
ownership: hint.ownership,
|
|
194
|
+
ownership_field: hint.ownership_field,
|
|
195
|
+
confidence: hint.confidence,
|
|
196
|
+
review_required: true,
|
|
197
|
+
explanation: hint.explanation,
|
|
198
|
+
why_inferred: hint.why_inferred || describeAuthOwnershipWhyInferred(hint),
|
|
199
|
+
review_guidance: hint.review_guidance || buildAuthOwnershipReviewGuidance(hint),
|
|
200
|
+
related_capabilities: relatedCapabilities,
|
|
201
|
+
related_entities: hint.related_entities || [],
|
|
202
|
+
evidence: hint.evidence || {}
|
|
203
|
+
};
|
|
204
|
+
const existing = patches.find((/** @type {any} */ patch) => patch.projection_id === impact.projection_id);
|
|
205
|
+
if (existing) {
|
|
206
|
+
existing.missing_auth_ownerships = existing.missing_auth_ownerships || [];
|
|
207
|
+
const duplicate = existing.missing_auth_ownerships.some((/** @type {any} */ candidate) =>
|
|
208
|
+
candidate.ownership === entry.ownership &&
|
|
209
|
+
candidate.ownership_field === entry.ownership_field &&
|
|
210
|
+
stableStringify(candidate.related_capabilities || []) === stableStringify(entry.related_capabilities || [])
|
|
211
|
+
);
|
|
212
|
+
if (!duplicate) {
|
|
213
|
+
existing.missing_auth_ownerships.push(entry);
|
|
214
|
+
}
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
patches.push({
|
|
218
|
+
projection_id: impact.projection_id,
|
|
219
|
+
kind: impact.kind,
|
|
220
|
+
projection_type: impact.projection_type,
|
|
221
|
+
reason: `Projection ${impact.projection_id} likely needs ownership-based auth rules for the imported ${bundle.label.toLowerCase()} surface.`,
|
|
222
|
+
missing_realizes: relatedCapabilities,
|
|
223
|
+
missing_http: [],
|
|
224
|
+
missing_screens: [],
|
|
225
|
+
missing_routes: [],
|
|
226
|
+
missing_actions: [],
|
|
227
|
+
missing_auth_ownerships: [entry]
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return patches
|
|
233
|
+
.map((/** @type {any} */ patch) => ({
|
|
234
|
+
...patch,
|
|
235
|
+
missing_auth_permissions: (patch.missing_auth_permissions || []).sort((/** @type {any} */ a, /** @type {any} */ b) =>
|
|
236
|
+
(a.projection_surface || "").localeCompare(b.projection_surface || "") ||
|
|
237
|
+
(a.permission || "").localeCompare(b.permission || "") ||
|
|
238
|
+
stableStringify(a.related_capabilities || []).localeCompare(stableStringify(b.related_capabilities || []))
|
|
239
|
+
),
|
|
240
|
+
missing_auth_claims: (patch.missing_auth_claims || []).sort((/** @type {any} */ a, /** @type {any} */ b) =>
|
|
241
|
+
(a.projection_surface || "").localeCompare(b.projection_surface || "") ||
|
|
242
|
+
(a.claim || "").localeCompare(b.claim || "") ||
|
|
243
|
+
stableStringify(a.related_capabilities || []).localeCompare(stableStringify(b.related_capabilities || []))
|
|
244
|
+
),
|
|
245
|
+
missing_auth_ownerships: (patch.missing_auth_ownerships || []).sort((/** @type {any} */ a, /** @type {any} */ b) =>
|
|
246
|
+
(a.ownership_field || "").localeCompare(b.ownership_field || "") ||
|
|
247
|
+
stableStringify(a.related_capabilities || []).localeCompare(stableStringify(b.related_capabilities || []))
|
|
248
|
+
),
|
|
249
|
+
patch_rel_path: `projection-patches/${patch.projection_id}.md`
|
|
250
|
+
}))
|
|
251
|
+
.sort((/** @type {any} */ a, /** @type {any} */ b) => a.projection_id.localeCompare(b.projection_id));
|
|
252
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/** @param {CandidateBundle} bundle @param {ProjectionImpact[]} projectionIndex @returns {any} */
|
|
4
|
+
export function buildProjectionImpacts(bundle, projectionIndex) {
|
|
5
|
+
const bundleEntityIds = new Set([
|
|
6
|
+
bundle.mergeHints?.canonicalEntityTarget || null,
|
|
7
|
+
...bundle.entities.map((/** @type {any} */ entry) => entry.id_hint)
|
|
8
|
+
].filter(Boolean));
|
|
9
|
+
if (bundle.capabilities.length === 0 || bundleEntityIds.size === 0) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return projectionIndex
|
|
13
|
+
.filter((/** @type {any} */ projection) => projection.kind === "api" || projection.kind === "ui")
|
|
14
|
+
.filter((/** @type {any} */ projection) => projection.entityIds.some((/** @type {any} */ entityId) => bundleEntityIds.has(entityId)))
|
|
15
|
+
.map((/** @type {any} */ projection) => {
|
|
16
|
+
const missingCapabilities = bundle.capabilities
|
|
17
|
+
.map((/** @type {any} */ entry) => entry.id_hint)
|
|
18
|
+
.filter((/** @type {any} */ id) => !projection.realizes.includes(id));
|
|
19
|
+
if (missingCapabilities.length === 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
projection_id: projection.id,
|
|
24
|
+
projection_type: projection.type,
|
|
25
|
+
kind: projection.kind,
|
|
26
|
+
missing_capabilities: missingCapabilities,
|
|
27
|
+
reason: `Projection ${projection.id} already covers the same entity surface but does not realize these imported capabilities.`
|
|
28
|
+
};
|
|
29
|
+
})
|
|
30
|
+
.filter(Boolean)
|
|
31
|
+
.sort((/** @type {any} */ a, /** @type {any} */ b) => a.projection_id.localeCompare(b.projection_id));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @param {CandidateBundle} bundle @param {ResolvedGraph} graph @returns {any} */
|
|
35
|
+
export function buildUiImpacts(bundle, graph) {
|
|
36
|
+
if ((bundle.screens || []).length === 0) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
const uiProjections = (graph?.byKind.projection || []).filter((/** @type {any} */ projection) => ["ui_contract", "web_surface"].includes(projection.type));
|
|
40
|
+
const bundleScreenIds = bundle.screens.map((/** @type {any} */ screen) => screen.id_hint);
|
|
41
|
+
return uiProjections
|
|
42
|
+
.map((/** @type {any} */ projection) => {
|
|
43
|
+
const projectionScreens = new Set((projection.uiScreens || []).map((/** @type {any} */ screen) => screen.id));
|
|
44
|
+
const missingScreens = bundleScreenIds.filter((/** @type {any} */ screenId) => !projectionScreens.has(screenId));
|
|
45
|
+
if (missingScreens.length === 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
projection_id: projection.id,
|
|
50
|
+
kind: "ui",
|
|
51
|
+
projection_type: projection.type,
|
|
52
|
+
missing_screens: missingScreens,
|
|
53
|
+
reason: `UI projection ${projection.id} does not currently represent these imported screens.`
|
|
54
|
+
};
|
|
55
|
+
})
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.sort((/** @type {any} */ a, /** @type {any} */ b) => a.projection_id.localeCompare(b.projection_id));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @param {CandidateBundle} bundle @param {ResolvedGraph} graph @returns {any} */
|
|
61
|
+
export function buildWorkflowImpacts(bundle, graph) {
|
|
62
|
+
if ((bundle.workflows || []).length === 0) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const canonicalWorkflowDocs = new Set((graph?.docs || []).filter((/** @type {any} */ doc) => doc.kind === "workflow").map((/** @type {any} */ doc) => doc.id));
|
|
66
|
+
const impacted = bundle.workflows
|
|
67
|
+
.map((/** @type {any} */ workflow) => workflow.id_hint)
|
|
68
|
+
.filter((/** @type {any} */ id) => !canonicalWorkflowDocs.has(id));
|
|
69
|
+
if (impacted.length === 0) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
review_group_id: `workflow_review:${bundle.slug}`,
|
|
75
|
+
kind: "workflow",
|
|
76
|
+
items: impacted,
|
|
77
|
+
reason: `Workflow semantics for ${bundle.slug} need canonical review before promotion.`
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
export { buildBundleAdoptionPlan } from "./impacts/adoption-plan.js";
|
|
4
|
+
export {
|
|
5
|
+
buildCanonicalShapeIndex,
|
|
6
|
+
buildProjectionEntityIndex,
|
|
7
|
+
capabilityEntityTargets,
|
|
8
|
+
projectionKindForImpact,
|
|
9
|
+
shapeFieldSignature
|
|
10
|
+
} from "./impacts/indexes.js";
|
|
11
|
+
export { buildProjectionPatchCandidates } from "./impacts/patches.js";
|
|
12
|
+
export {
|
|
13
|
+
buildProjectionImpacts,
|
|
14
|
+
buildUiImpacts,
|
|
15
|
+
buildWorkflowImpacts
|
|
16
|
+
} from "./impacts/reports.js";
|