@agent-teams/engineering-foundation 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile.d.ts +31 -0
  2. package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile.d.ts.map +1 -0
  3. package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile.js +47 -0
  4. package/dist/document-authoring/adapters/node/load-validated-document-authoring-profile.js.map +1 -0
  5. package/dist/document-authoring/adapters/node/node-authoring-profile-reader.d.ts.map +1 -1
  6. package/dist/document-authoring/adapters/node/node-authoring-profile-reader.js +14 -39
  7. package/dist/document-authoring/adapters/node/node-authoring-profile-reader.js.map +1 -1
  8. package/dist/document-authoring/adapters/node/node-document-contract-validator.d.ts +7 -0
  9. package/dist/document-authoring/adapters/node/node-document-contract-validator.d.ts.map +1 -0
  10. package/dist/document-authoring/adapters/node/node-document-contract-validator.js +179 -0
  11. package/dist/document-authoring/adapters/node/node-document-contract-validator.js.map +1 -0
  12. package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.d.ts +10 -0
  13. package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.d.ts.map +1 -0
  14. package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.js +72 -0
  15. package/dist/document-authoring/adapters/node/node-document-planning-profile-reader.js.map +1 -0
  16. package/dist/document-authoring/adapters/node/node-document-planning-state-reader.d.ts +10 -0
  17. package/dist/document-authoring/adapters/node/node-document-planning-state-reader.d.ts.map +1 -0
  18. package/dist/document-authoring/adapters/node/node-document-planning-state-reader.js +164 -0
  19. package/dist/document-authoring/adapters/node/node-document-planning-state-reader.js.map +1 -0
  20. package/dist/document-authoring/adapters/node/node-document-template-reader.d.ts +10 -0
  21. package/dist/document-authoring/adapters/node/node-document-template-reader.d.ts.map +1 -0
  22. package/dist/document-authoring/adapters/node/node-document-template-reader.js +32 -0
  23. package/dist/document-authoring/adapters/node/node-document-template-reader.js.map +1 -0
  24. package/dist/document-authoring/application/model/document-planning.d.ts +171 -0
  25. package/dist/document-authoring/application/model/document-planning.d.ts.map +1 -0
  26. package/dist/document-authoring/application/model/document-planning.js +2 -0
  27. package/dist/document-authoring/application/model/document-planning.js.map +1 -0
  28. package/dist/document-authoring/application/policies/document-logical-preimage.d.ts +14 -0
  29. package/dist/document-authoring/application/policies/document-logical-preimage.d.ts.map +1 -0
  30. package/dist/document-authoring/application/policies/document-logical-preimage.js +61 -0
  31. package/dist/document-authoring/application/policies/document-logical-preimage.js.map +1 -0
  32. package/dist/document-authoring/application/policies/document-planning-policy-error.d.ts +6 -0
  33. package/dist/document-authoring/application/policies/document-planning-policy-error.d.ts.map +1 -0
  34. package/dist/document-authoring/application/policies/document-planning-policy-error.js +9 -0
  35. package/dist/document-authoring/application/policies/document-planning-policy-error.js.map +1 -0
  36. package/dist/document-authoring/application/policies/normalize-document-intent.d.ts +3 -0
  37. package/dist/document-authoring/application/policies/normalize-document-intent.d.ts.map +1 -0
  38. package/dist/document-authoring/application/policies/normalize-document-intent.js +104 -0
  39. package/dist/document-authoring/application/policies/normalize-document-intent.js.map +1 -0
  40. package/dist/document-authoring/application/policies/resolve-document-authoring.d.ts +13 -0
  41. package/dist/document-authoring/application/policies/resolve-document-authoring.d.ts.map +1 -0
  42. package/dist/document-authoring/application/policies/resolve-document-authoring.js +154 -0
  43. package/dist/document-authoring/application/policies/resolve-document-authoring.js.map +1 -0
  44. package/dist/document-authoring/application/ports/document-contract-validator.d.ts +6 -0
  45. package/dist/document-authoring/application/ports/document-contract-validator.d.ts.map +1 -0
  46. package/dist/document-authoring/application/ports/document-contract-validator.js +2 -0
  47. package/dist/document-authoring/application/ports/document-contract-validator.js.map +1 -0
  48. package/dist/document-authoring/application/ports/document-planning-profile-reader.d.ts +9 -0
  49. package/dist/document-authoring/application/ports/document-planning-profile-reader.d.ts.map +1 -0
  50. package/dist/document-authoring/application/ports/document-planning-profile-reader.js +2 -0
  51. package/dist/document-authoring/application/ports/document-planning-profile-reader.js.map +1 -0
  52. package/dist/document-authoring/application/ports/document-planning-state-reader.d.ts +9 -0
  53. package/dist/document-authoring/application/ports/document-planning-state-reader.d.ts.map +1 -0
  54. package/dist/document-authoring/application/ports/document-planning-state-reader.js +2 -0
  55. package/dist/document-authoring/application/ports/document-planning-state-reader.js.map +1 -0
  56. package/dist/document-authoring/application/ports/document-template-reader.d.ts +9 -0
  57. package/dist/document-authoring/application/ports/document-template-reader.d.ts.map +1 -0
  58. package/dist/document-authoring/application/ports/document-template-reader.js +2 -0
  59. package/dist/document-authoring/application/ports/document-template-reader.js.map +1 -0
  60. package/dist/document-authoring/application/ports/documentation-catalog-reader.d.ts +11 -0
  61. package/dist/document-authoring/application/ports/documentation-catalog-reader.d.ts.map +1 -0
  62. package/dist/document-authoring/application/ports/documentation-catalog-reader.js +2 -0
  63. package/dist/document-authoring/application/ports/documentation-catalog-reader.js.map +1 -0
  64. package/dist/document-authoring/application/use-cases/build-documentation-catalog.d.ts +2 -1
  65. package/dist/document-authoring/application/use-cases/build-documentation-catalog.d.ts.map +1 -1
  66. package/dist/document-authoring/application/use-cases/build-documentation-catalog.js.map +1 -1
  67. package/dist/document-authoring/application/use-cases/compile-document-plan.d.ts +6 -0
  68. package/dist/document-authoring/application/use-cases/compile-document-plan.d.ts.map +1 -0
  69. package/dist/document-authoring/application/use-cases/compile-document-plan.js +156 -0
  70. package/dist/document-authoring/application/use-cases/compile-document-plan.js.map +1 -0
  71. package/dist/document-authoring/application/use-cases/plan-documentation-document.d.ts +66 -0
  72. package/dist/document-authoring/application/use-cases/plan-documentation-document.d.ts.map +1 -0
  73. package/dist/document-authoring/application/use-cases/plan-documentation-document.js +276 -0
  74. package/dist/document-authoring/application/use-cases/plan-documentation-document.js.map +1 -0
  75. package/dist/document-authoring/document-planning-error.d.ts +6 -0
  76. package/dist/document-authoring/document-planning-error.d.ts.map +1 -0
  77. package/dist/document-authoring/document-planning-error.js +9 -0
  78. package/dist/document-authoring/document-planning-error.js.map +1 -0
  79. package/dist/document-authoring/index.d.ts +10 -0
  80. package/dist/document-authoring/index.d.ts.map +1 -1
  81. package/dist/document-authoring/index.js +72 -0
  82. package/dist/document-authoring/index.js.map +1 -1
  83. package/package.json +1 -1
@@ -0,0 +1,156 @@
1
+ import { sha256Bytes } from "../../../canonical-json.js";
2
+ import { assertDocumentPlanDigests, documentIdentityProjectionDigest, documentIntentDigest, documentOwnerMembershipDigest, documentPlanDigest, documentReferencedDocumentDigest } from "../policies/document-contract-digests.js";
3
+ import { documentRepositoryParentPath } from "../policies/document-repository-path.js";
4
+ import { projectReferencedDocuments } from "../projections/document-catalog-projections.js";
5
+ import { DocumentPlanningError } from "../../document-planning-error.js";
6
+ const MAXIMUM_OUTPUT_BYTES = 1_048_576;
7
+ const BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
8
+ function sameEvidence(left, right) {
9
+ return (left.path === right.path &&
10
+ left.digest === right.digest &&
11
+ left.size === right.size);
12
+ }
13
+ function fail(code, message) {
14
+ throw new DocumentPlanningError(code, message);
15
+ }
16
+ function assertCompilationAuthority(input) {
17
+ if (input.catalog.status !== "complete") {
18
+ fail("DOCUMENT_PLANNING_CATALOG_PARTIAL", "Document planning requires a complete rebuilt catalog.");
19
+ }
20
+ if (input.catalog.projectId !== input.profile.projectId) {
21
+ fail("DOCUMENT_PLANNING_AUTHORITY_CHANGED", "Document profile and rebuilt catalog disagree on project identity.");
22
+ }
23
+ if (!sameEvidence(input.profile.evidence, input.catalog.authority.profile) ||
24
+ !sameEvidence(input.metadataSchema, input.catalog.authority.metadataSchema) ||
25
+ !sameEvidence(input.ownerCatalog, input.catalog.authority.ownerCatalog)) {
26
+ fail("DOCUMENT_PLANNING_AUTHORITY_CHANGED", "Document planning authority does not match the rebuilt catalog evidence.");
27
+ }
28
+ if (!input.catalog.ownerIds.includes(input.intent.owner)) {
29
+ fail("DOCUMENT_PLANNING_INPUT_INVALID", `Document owner ${input.intent.owner} is not present in the owner catalog.`);
30
+ }
31
+ }
32
+ function assertCanonicalOutput(output) {
33
+ const bytes = new TextEncoder().encode(output);
34
+ if (bytes.byteLength === 0 ||
35
+ bytes.byteLength > MAXIMUM_OUTPUT_BYTES ||
36
+ output.startsWith("\uFEFF") ||
37
+ output.includes("\u0000") ||
38
+ output.includes("\r") ||
39
+ !output.endsWith("\n") ||
40
+ output.endsWith("\n\n")) {
41
+ fail("DOCUMENT_PLANNING_OUTPUT_INVALID", "Rendered document violates the bounded canonical UTF-8/LF output contract.");
42
+ }
43
+ return bytes;
44
+ }
45
+ function equalBytes(left, right) {
46
+ return (left.byteLength === right.byteLength &&
47
+ left.every((value, index) => value === right[index]));
48
+ }
49
+ function encodeBase64(bytes) {
50
+ let result = "";
51
+ for (let index = 0; index < bytes.length; index += 3) {
52
+ const first = bytes[index] ?? 0;
53
+ const second = bytes[index + 1] ?? 0;
54
+ const third = bytes[index + 2] ?? 0;
55
+ const bits = (first << 16) | (second << 8) | third;
56
+ result += BASE64_ALPHABET[(bits >> 18) & 63];
57
+ result += BASE64_ALPHABET[(bits >> 12) & 63];
58
+ result += index + 1 < bytes.length ? BASE64_ALPHABET[(bits >> 6) & 63] : "=";
59
+ result += index + 2 < bytes.length ? BASE64_ALPHABET[bits & 63] : "=";
60
+ }
61
+ return result;
62
+ }
63
+ function assertDestinationState(input, outputBytes) {
64
+ if (input.state.expectedParent.path !==
65
+ documentRepositoryParentPath(input.destination)) {
66
+ fail("DOCUMENT_PLANNING_PARENT_UNAVAILABLE", "Observed parent does not match the planned document destination.");
67
+ }
68
+ if (input.state.destination.state === "conflict") {
69
+ fail("DOCUMENT_PLANNING_CONFLICT", `Document destination is a ${input.state.destination.kind}.`);
70
+ }
71
+ if (input.state.destination.state === "regular-file" &&
72
+ !equalBytes(input.state.destination.bytes, outputBytes)) {
73
+ fail("DOCUMENT_PLANNING_CONFLICT", "Document destination already contains different bytes.");
74
+ }
75
+ }
76
+ function assertSortedIdentityProjection(entries) {
77
+ const projection = entries.map(({ id, repositoryPath }) => Object.freeze({ id, repositoryPath }));
78
+ const sorted = projection.toSorted((left, right) => (left.id < right.id ? -1 : left.id > right.id ? 1 : 0) ||
79
+ (left.repositoryPath < right.repositoryPath
80
+ ? -1
81
+ : left.repositoryPath > right.repositoryPath
82
+ ? 1
83
+ : 0));
84
+ if (sorted.some((entry, index) => entry.id !== projection[index].id ||
85
+ entry.repositoryPath !== projection[index].repositoryPath)) {
86
+ fail("DOCUMENT_PLANNING_OUTPUT_INVALID", "Document identity projection is not in canonical binary order.");
87
+ }
88
+ return Object.freeze(projection);
89
+ }
90
+ /** Pure assembly of a validated, fully observed document planning snapshot. */
91
+ export function compileDocumentPlan(input) {
92
+ assertCompilationAuthority(input);
93
+ const outputBytes = assertCanonicalOutput(input.output);
94
+ assertDestinationState(input, outputBytes);
95
+ const identityProjection = assertSortedIdentityProjection(input.identityProjection);
96
+ if (identityProjection.length > 100_000) {
97
+ fail("DOCUMENT_PLANNING_OUTPUT_INVALID", "Document identity projection exceeds the v1 entry budget.");
98
+ }
99
+ const references = projectReferencedDocuments(input.catalog, input.intent.related ?? []);
100
+ if (references.missingIds.length > 0 || references.unresolvedIds.length > 0) {
101
+ fail("DOCUMENT_PLANNING_INPUT_INVALID", "Document Intent references missing or ambiguous catalog identities.");
102
+ }
103
+ const referencedDocuments = Object.freeze(references.documents.map((reference) => Object.freeze({
104
+ ...reference,
105
+ projectionDigest: documentReferencedDocumentDigest(reference)
106
+ })));
107
+ const output = Object.freeze({
108
+ digest: sha256Bytes(outputBytes),
109
+ size: outputBytes.byteLength,
110
+ mode: "0644",
111
+ mediaType: "text/markdown; charset=utf-8",
112
+ contentBase64: encodeBase64(outputBytes)
113
+ });
114
+ const planWithoutDigest = {
115
+ schemaVersion: 1,
116
+ protocolVersion: 1,
117
+ compiler: input.compiler,
118
+ projectId: input.profile.projectId,
119
+ intent: input.intent,
120
+ intentDigest: documentIntentDigest(input.intent),
121
+ authority: Object.freeze({
122
+ profile: input.profile.evidence,
123
+ metadataSchema: input.metadataSchema,
124
+ ownerCatalog: input.ownerCatalog,
125
+ template: input.template.evidence
126
+ }),
127
+ selectedOwner: Object.freeze({
128
+ id: input.intent.owner,
129
+ membershipDigest: documentOwnerMembershipDigest(input.ownerCatalog.digest, input.intent.owner)
130
+ }),
131
+ identityProjection: Object.freeze({
132
+ entryCount: identityProjection.length,
133
+ digest: documentIdentityProjectionDigest(identityProjection)
134
+ }),
135
+ referencedDocuments,
136
+ destination: input.destination,
137
+ expectedParent: input.state.expectedParent,
138
+ destinationPrecondition: Object.freeze({ state: "absent" }),
139
+ output,
140
+ requiredAdapterCapabilities: Object.freeze([
141
+ "create-file-no-replace/v1"
142
+ ]),
143
+ diagnostics: Object.freeze([])
144
+ };
145
+ const digestInput = planWithoutDigest;
146
+ const plan = Object.freeze({
147
+ ...digestInput,
148
+ planDigest: documentPlanDigest({
149
+ ...digestInput,
150
+ planDigest: "sha256:0000000000000000000000000000000000000000000000000000000000000000"
151
+ })
152
+ });
153
+ assertDocumentPlanDigests(plan);
154
+ return plan;
155
+ }
156
+ //# sourceMappingURL=compile-document-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-document-plan.js","sourceRoot":"","sources":["../../../../src/document-authoring/application/use-cases/compile-document-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AASzD,OAAO,EACL,yBAAyB,EACzB,gCAAgC,EAChC,oBAAoB,EACpB,6BAA6B,EAC7B,kBAAkB,EAClB,gCAAgC,EACjC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,MAAM,oBAAoB,GAAG,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AI,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { DocumentIdentityProjectionEntry, DocumentationCatalogSnapshot } from "../model/document-catalog.js";
2
+ import type { DocumentArtifactType, DocumentIntent, DocumentPlan, DocumentPlanningProfileSnapshot } from "../model/document-planning.js";
3
+ import type { CanonicalDocumentRenderer } from "../ports/canonical-document-renderer.js";
4
+ import type { DocumentContractValidator } from "../ports/document-contract-validator.js";
5
+ import type { DocumentPlanningProfileReader } from "../ports/document-planning-profile-reader.js";
6
+ import type { DocumentPlanningStateReader } from "../ports/document-planning-state-reader.js";
7
+ import type { DocumentTemplateReader } from "../ports/document-template-reader.js";
8
+ import type { DocumentationCatalogReader } from "../ports/documentation-catalog-reader.js";
9
+ import type { MetadataInstanceValidator } from "../ports/metadata-instance-validator.js";
10
+ import type { OwnerMembershipReader } from "../ports/owner-membership-reader.js";
11
+ interface ResolvedDocumentAuthoring {
12
+ readonly artifact: DocumentArtifactType;
13
+ readonly slug?: string;
14
+ readonly destination: string;
15
+ readonly heading: string;
16
+ }
17
+ interface DocumentLogicalPreimage {
18
+ readonly identityProjection: readonly DocumentIdentityProjectionEntry[];
19
+ readonly isExactSelf: boolean;
20
+ }
21
+ /**
22
+ * Closed pure policy surface consumed by the read-only orchestration use case.
23
+ * Implementations live in the policy layer; consumer code cannot supply it from
24
+ * the public composition root.
25
+ */
26
+ interface DocumentPlanningPolicies {
27
+ normalizeDocumentIntent(input: DocumentIntent): DocumentIntent;
28
+ selectDocumentArtifact(profile: DocumentPlanningProfileSnapshot, type: string): DocumentArtifactType;
29
+ resolveDocumentAuthoring(input: {
30
+ readonly artifact: DocumentArtifactType;
31
+ readonly intent: DocumentIntent;
32
+ }): ResolvedDocumentAuthoring;
33
+ isDestinationCoveredByCatalog(destination: string, collections: DocumentPlanningProfileSnapshot["collections"], excludedPrefixes: readonly string[]): boolean;
34
+ classifyDocumentLogicalPreimage(input: {
35
+ readonly catalog: DocumentationCatalogSnapshot;
36
+ readonly id: string;
37
+ readonly destination: string;
38
+ readonly observedBytes?: Uint8Array;
39
+ readonly expectedBytes: Uint8Array;
40
+ }): DocumentLogicalPreimage;
41
+ }
42
+ export interface PlanDocumentationDocumentRequest {
43
+ readonly consumerRoot: string;
44
+ readonly profilePath: string;
45
+ readonly intent: unknown;
46
+ readonly signal?: AbortSignal;
47
+ }
48
+ interface Dependencies {
49
+ readonly catalog: DocumentationCatalogReader;
50
+ readonly compiler: DocumentPlan["compiler"];
51
+ readonly contracts: DocumentContractValidator;
52
+ readonly metadata: MetadataInstanceValidator;
53
+ readonly owners: OwnerMembershipReader;
54
+ readonly policies: DocumentPlanningPolicies;
55
+ readonly profile: DocumentPlanningProfileReader;
56
+ readonly renderer: CanonicalDocumentRenderer;
57
+ readonly state: DocumentPlanningStateReader;
58
+ readonly templates: DocumentTemplateReader;
59
+ }
60
+ export declare class PlanDocumentationDocument {
61
+ #private;
62
+ constructor(dependencies: Dependencies);
63
+ execute(request: PlanDocumentationDocumentRequest): Promise<DocumentPlan>;
64
+ }
65
+ export {};
66
+ //# sourceMappingURL=plan-documentation-document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-documentation-document.d.ts","sourceRoot":"","sources":["../../../../src/document-authoring/application/use-cases/plan-documentation-document.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,+BAA+B,EAC/B,4BAA4B,EAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,+BAA+B,EAEhC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAClG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4CAA4C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AAQ,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC;QACpC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;KACpC,GAAG,uBAAuB,CAAC;CAC7B;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,UAAU,YAAY;IACpB,QAAQ,CAAC,OAAO,EAAE,0BAA0B,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,yBAAyB,CAAC;IAC9C,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,6BAA6B,CAAC;IAChD,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,2BAA2B,CAAC;IAC5C,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;CAC5C;AA0RD,qBAAa,yBAAyB;;IAGpC,YAAY,YAAY,EAAE,YAAY,EAErC;IAEK,OAAO,CACX,OAAO,EAAE,gCAAgC,GACxC,OAAO,CAAC,YAAY,CAAC,CA4IvB;CACF"}
@@ -0,0 +1,276 @@
1
+ import { assertNotCancelled } from "../../../cancellation.js";
2
+ import { assertDocumentPlanDigests } from "../policies/document-contract-digests.js";
3
+ import { DocumentPlanningError } from "../../document-planning-error.js";
4
+ import { compileDocumentPlan } from "./compile-document-plan.js";
5
+ function signalOption(signal) {
6
+ return signal === undefined ? {} : { signal };
7
+ }
8
+ function sameEvidence(left, right) {
9
+ return (left.path === right.path &&
10
+ left.digest === right.digest &&
11
+ left.size === right.size);
12
+ }
13
+ function assertStableEvidence(name, before, after) {
14
+ if (!sameEvidence(before, after)) {
15
+ throw new DocumentPlanningError("DOCUMENT_PLANNING_AUTHORITY_CHANGED", `${name} changed while the document Plan was compiled.`);
16
+ }
17
+ }
18
+ function outputBytes(output) {
19
+ return new TextEncoder().encode(output);
20
+ }
21
+ function sameBytes(left, right) {
22
+ return left.length === right.length &&
23
+ left.every((value, index) => value === right[index]);
24
+ }
25
+ function samePlanningState(left, right) {
26
+ if (left.expectedParent.path !== right.expectedParent.path ||
27
+ left.destination.state !== right.destination.state) {
28
+ return false;
29
+ }
30
+ if (left.destination.state === "absent" || right.destination.state === "absent") {
31
+ return left.destination.state === right.destination.state;
32
+ }
33
+ if (left.destination.state === "conflict" || right.destination.state === "conflict") {
34
+ return left.destination.state === "conflict" &&
35
+ right.destination.state === "conflict" &&
36
+ left.destination.kind === right.destination.kind;
37
+ }
38
+ return sameBytes(left.destination.bytes, right.destination.bytes);
39
+ }
40
+ function assertStablePlanningState(before, after) {
41
+ if (!samePlanningState(before, after)) {
42
+ throw new DocumentPlanningError("DOCUMENT_PLANNING_AUTHORITY_CHANGED", "Document destination or parent changed while the Plan was compiled.");
43
+ }
44
+ }
45
+ function assertStableCatalog(before, after) {
46
+ if (!sameCatalogSnapshot(before, after)) {
47
+ throw new DocumentPlanningError("DOCUMENT_PLANNING_AUTHORITY_CHANGED", "Document catalog changed while the Plan was compiled.");
48
+ }
49
+ }
50
+ function sameEvidenceList(left, right) {
51
+ return left.length === right.length &&
52
+ left.every((entry, index) => sameEvidence(entry, right[index]));
53
+ }
54
+ function sameCatalogSnapshot(left, right) {
55
+ const leftAuthority = [
56
+ left.authority.profile,
57
+ left.authority.metadataSchema,
58
+ left.authority.ownerCatalog
59
+ ];
60
+ const rightAuthority = [
61
+ right.authority.profile,
62
+ right.authority.metadataSchema,
63
+ right.authority.ownerCatalog
64
+ ];
65
+ return left.status === right.status &&
66
+ left.projectId === right.projectId &&
67
+ sameEvidenceList(leftAuthority, rightAuthority) &&
68
+ JSON.stringify(left.diagnostics) === JSON.stringify(right.diagnostics) &&
69
+ JSON.stringify(left.documents) === JSON.stringify(right.documents) &&
70
+ JSON.stringify(left.identityProjection) === JSON.stringify(right.identityProjection) &&
71
+ JSON.stringify(left.ownerIds) === JSON.stringify(right.ownerIds);
72
+ }
73
+ async function loadPlanningAuthority(dependencies, request, profile, templatePath) {
74
+ const options = signalOption(request.signal);
75
+ const [catalog, metadata, owners, template] = await Promise.all([
76
+ dependencies.catalog.execute({
77
+ consumerRoot: request.consumerRoot,
78
+ profilePath: request.profilePath,
79
+ ...options
80
+ }),
81
+ dependencies.metadata.load({
82
+ consumerRoot: request.consumerRoot,
83
+ path: profile.metadataSchemaPath,
84
+ ...options
85
+ }),
86
+ dependencies.owners.read({
87
+ consumerRoot: request.consumerRoot,
88
+ contract: profile.ownerCatalog.contract,
89
+ path: profile.ownerCatalog.path,
90
+ ...options
91
+ }),
92
+ dependencies.templates.read({
93
+ consumerRoot: request.consumerRoot,
94
+ path: templatePath,
95
+ ...options
96
+ })
97
+ ]);
98
+ return { catalog, metadata, owners, template };
99
+ }
100
+ function assertCatalogAuthority(profile, intent, authority) {
101
+ if (authority.catalog.status !== "complete") {
102
+ throw new DocumentPlanningError("DOCUMENT_PLANNING_CATALOG_PARTIAL", "Document planning requires a complete rebuilt catalog.");
103
+ }
104
+ assertStableEvidence("Document profile", profile.evidence, authority.catalog.authority.profile);
105
+ assertStableEvidence("Document metadata schema", authority.metadata.evidence, authority.catalog.authority.metadataSchema);
106
+ assertStableEvidence("Document owner catalog", authority.owners.evidence, authority.catalog.authority.ownerCatalog);
107
+ if (!authority.owners.ids.includes(intent.owner)) {
108
+ throw new DocumentPlanningError("DOCUMENT_PLANNING_INPUT_INVALID", `Document owner ${intent.owner} is not present in the owner catalog.`);
109
+ }
110
+ }
111
+ async function recaptureAuthority(input) {
112
+ const { authority, dependencies, destination, profile, request, state, templatePath } = input;
113
+ const options = signalOption(request.signal);
114
+ const [profileAfter, metadataAfter, ownersAfter, templateAfter] = await Promise.all([
115
+ dependencies.profile.read({
116
+ consumerRoot: request.consumerRoot,
117
+ path: request.profilePath,
118
+ ...options
119
+ }),
120
+ dependencies.metadata.load({
121
+ consumerRoot: request.consumerRoot,
122
+ path: profile.metadataSchemaPath,
123
+ ...options
124
+ }),
125
+ dependencies.owners.read({
126
+ consumerRoot: request.consumerRoot,
127
+ contract: profile.ownerCatalog.contract,
128
+ path: profile.ownerCatalog.path,
129
+ ...options
130
+ }),
131
+ dependencies.templates.read({
132
+ consumerRoot: request.consumerRoot,
133
+ path: templatePath,
134
+ ...options
135
+ })
136
+ ]);
137
+ assertStableEvidence("Document profile", profile.evidence, profileAfter.evidence);
138
+ assertStableEvidence("Document metadata schema", authority.metadata.evidence, metadataAfter.evidence);
139
+ assertStableEvidence("Document owner catalog", authority.owners.evidence, ownersAfter.evidence);
140
+ assertStableEvidence("Document template", authority.template.evidence, templateAfter.evidence);
141
+ const stateBeforeCatalog = await dependencies.state.observe({
142
+ consumerRoot: request.consumerRoot,
143
+ destination,
144
+ ...options
145
+ });
146
+ assertStablePlanningState(state, stateBeforeCatalog);
147
+ const catalogAfter = await dependencies.catalog.execute({
148
+ consumerRoot: request.consumerRoot,
149
+ profilePath: request.profilePath,
150
+ ...options
151
+ });
152
+ assertStableCatalog(authority.catalog, catalogAfter);
153
+ const [stateAfterCatalog, templateAfterCatalog] = await Promise.all([
154
+ dependencies.state.observe({
155
+ consumerRoot: request.consumerRoot,
156
+ destination,
157
+ ...options
158
+ }),
159
+ dependencies.templates.read({
160
+ consumerRoot: request.consumerRoot,
161
+ path: templatePath,
162
+ ...options
163
+ })
164
+ ]);
165
+ assertStablePlanningState(state, stateAfterCatalog);
166
+ assertStableEvidence("Document template", authority.template.evidence, templateAfterCatalog.evidence);
167
+ }
168
+ export class PlanDocumentationDocument {
169
+ #dependencies;
170
+ constructor(dependencies) {
171
+ this.#dependencies = dependencies;
172
+ }
173
+ async execute(request) {
174
+ assertNotCancelled(request.signal);
175
+ const options = signalOption(request.signal);
176
+ const validatedIntent = await this.#dependencies.contracts.validateIntent(request.intent);
177
+ assertNotCancelled(request.signal);
178
+ const intent = this.#dependencies.policies.normalizeDocumentIntent(validatedIntent);
179
+ const profile = await this.#dependencies.profile.read({
180
+ consumerRoot: request.consumerRoot,
181
+ path: request.profilePath,
182
+ ...options
183
+ });
184
+ const artifact = this.#dependencies.policies.selectDocumentArtifact(profile, intent.type);
185
+ const resolved = this.#dependencies.policies.resolveDocumentAuthoring({
186
+ artifact,
187
+ intent
188
+ });
189
+ if (!this.#dependencies.policies.isDestinationCoveredByCatalog(resolved.destination, profile.collections, profile.excludedPrefixes)) {
190
+ throw new DocumentPlanningError("DOCUMENT_PLANNING_INPUT_INVALID", "Planned destination is outside the complete documentation catalog.");
191
+ }
192
+ const authority = await loadPlanningAuthority(this.#dependencies, request, profile, resolved.artifact.template.path);
193
+ assertCatalogAuthority(profile, intent, authority);
194
+ if (authority.template.evidence.path !== resolved.artifact.template.path) {
195
+ throw new DocumentPlanningError("DOCUMENT_PLANNING_AUTHORITY_CHANGED", "Document template evidence does not match the selected artifact authority.");
196
+ }
197
+ const skeleton = this.#dependencies.renderer.parseTemplate(authority.template.source);
198
+ const frontmatter = Object.freeze({
199
+ id: intent.id,
200
+ type: intent.type,
201
+ status: resolved.artifact.initialStatus,
202
+ owner: intent.owner,
203
+ summary: intent.summary,
204
+ ...(intent.related === undefined ? {} : { related: intent.related }),
205
+ ...(intent.additionalMetadata === undefined
206
+ ? {}
207
+ : { additionalMetadata: intent.additionalMetadata })
208
+ });
209
+ const validation = authority.metadata.validate({
210
+ id: frontmatter.id,
211
+ type: frontmatter.type,
212
+ status: frontmatter.status,
213
+ owner: frontmatter.owner,
214
+ summary: frontmatter.summary,
215
+ ...(frontmatter.related === undefined ? {} : { related: frontmatter.related }),
216
+ ...(frontmatter.additionalMetadata === undefined
217
+ ? {}
218
+ : frontmatter.additionalMetadata)
219
+ });
220
+ if (!validation.valid) {
221
+ throw new DocumentPlanningError("DOCUMENT_PLANNING_OUTPUT_INVALID", `Compiled document metadata is invalid: ${validation.messages.join("; ")}`);
222
+ }
223
+ const output = this.#dependencies.renderer.render({
224
+ frontmatter,
225
+ heading: resolved.heading,
226
+ template: skeleton
227
+ });
228
+ const expectedBytes = outputBytes(output);
229
+ const state = await this.#dependencies.state.observe({
230
+ consumerRoot: request.consumerRoot,
231
+ destination: resolved.destination,
232
+ ...options
233
+ });
234
+ const logicalPreimage = this.#dependencies.policies.classifyDocumentLogicalPreimage({
235
+ catalog: authority.catalog,
236
+ id: intent.id,
237
+ destination: resolved.destination,
238
+ ...(state.destination.state === "regular-file"
239
+ ? { observedBytes: state.destination.bytes }
240
+ : {}),
241
+ expectedBytes
242
+ });
243
+ if ((state.destination.state === "regular-file") !==
244
+ logicalPreimage.isExactSelf) {
245
+ throw new DocumentPlanningError("DOCUMENT_PLANNING_CONFLICT", "Existing destination is not the exact logical document self.");
246
+ }
247
+ await recaptureAuthority({
248
+ authority,
249
+ dependencies: this.#dependencies,
250
+ destination: resolved.destination,
251
+ profile,
252
+ request,
253
+ state,
254
+ templatePath: resolved.artifact.template.path
255
+ });
256
+ assertNotCancelled(request.signal);
257
+ const plan = compileDocumentPlan({
258
+ catalog: authority.catalog,
259
+ compiler: this.#dependencies.compiler,
260
+ destination: resolved.destination,
261
+ identityProjection: logicalPreimage.identityProjection,
262
+ intent,
263
+ metadataSchema: authority.metadata.evidence,
264
+ ownerCatalog: authority.owners.evidence,
265
+ output,
266
+ profile,
267
+ state,
268
+ template: authority.template
269
+ });
270
+ const validatedPlan = await this.#dependencies.contracts.validatePlan(plan);
271
+ assertDocumentPlanDigests(validatedPlan);
272
+ assertNotCancelled(request.signal);
273
+ return validatedPlan;
274
+ }
275
+ }
276
+ //# sourceMappingURL=plan-documentation-document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-documentation-document.js","sourceRoot":"","sources":["../../../../src/document-authoring/application/use-cases/plan-documentation-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAqB9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAsEjE,SAAS,YAAY,CAAC,MAA+B;IAGnD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,YAAY,CACnB,IAA+B,EAC/B,KAAgC;IAEhC,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI;QACxB,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAC5B,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CACzB,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,IAAY,EACZ,MAAiC,EACjC,KAAgC;IAEhC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,qBAAqB,CAC7B,qCAAqC,EACrC,GAAG,IAAI,gDAAgD,CACxD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,MAAc;IACjC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,SAAS,CAAC,IAAgB,EAAE,KAAiB;IACpD,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QACjC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,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,MAAM,CAAC,QAAQ;YACvC,MAAM;YACN,OAAO;YACP,KAAK;YACL,QAAQ,EAAE,SAAS,CAAC,QAAQ;SAC7B,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC5E,yBAAyB,CAAC,aAAa,CAAC,CAAC;QACzC,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export type DocumentPlanningErrorCode = "DOCUMENT_PLANNING_AUTHORITY_CHANGED" | "DOCUMENT_PLANNING_AUTHORITY_UNAVAILABLE" | "DOCUMENT_PLANNING_CATALOG_PARTIAL" | "DOCUMENT_PLANNING_CONFLICT" | "DOCUMENT_PLANNING_INPUT_INVALID" | "DOCUMENT_PLANNING_OUTPUT_INVALID" | "DOCUMENT_PLANNING_PARENT_UNAVAILABLE";
2
+ export declare class DocumentPlanningError extends Error {
3
+ readonly code: DocumentPlanningErrorCode;
4
+ constructor(code: DocumentPlanningErrorCode, message: string, options?: ErrorOptions);
5
+ }
6
+ //# sourceMappingURL=document-planning-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-planning-error.d.ts","sourceRoot":"","sources":["../../src/document-authoring/document-planning-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GACjC,qCAAqC,GACrC,yCAAyC,GACzC,mCAAmC,GACnC,4BAA4B,GAC5B,iCAAiC,GACjC,kCAAkC,GAClC,sCAAsC,CAAC;AAE3C,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IAEzC,YACE,IAAI,EAAE,yBAAyB,EAC/B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,EAKvB;CACF"}
@@ -0,0 +1,9 @@
1
+ export class DocumentPlanningError extends Error {
2
+ code;
3
+ constructor(code, message, options) {
4
+ super(message, options);
5
+ this.name = "DocumentPlanningError";
6
+ this.code = code;
7
+ }
8
+ }
9
+ //# sourceMappingURL=document-planning-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-planning-error.js","sourceRoot":"","sources":["../../src/document-authoring/document-planning-error.ts"],"names":[],"mappings":"AASA,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,IAAI,CAA4B;IAEzC,YACE,IAA+B,EAC/B,OAAe,EACf,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
@@ -1,12 +1,22 @@
1
1
  import { type BuildDocumentationCatalogRequest } from "./application/use-cases/build-documentation-catalog.js";
2
2
  import { type FindDocumentsRequest } from "./application/use-cases/find-documents.js";
3
+ import { type PlanDocumentationDocumentRequest } from "./application/use-cases/plan-documentation-document.js";
3
4
  export type { DocumentAuthorityDigest, DocumentAuthorityEvidence, DocumentDescriptor, DocumentIdentityProjectionEntry, DocumentationCatalogAuthority, DocumentationCatalogDiagnostic, DocumentationCatalogSnapshot, ReferencedDocumentProjection, ReferencedDocumentProjectionResult } from "./application/model/document-catalog.js";
4
5
  export type { DocumentFindFilters, DocumentFindQuery, DocumentFindResult } from "./application/model/document-find.js";
6
+ export type { DocumentCompilerIdentity, DocumentIntent, DocumentJsonObject, DocumentJsonPrimitive, DocumentJsonValue, DocumentPlan, DocumentPlanDiagnostic } from "./application/model/document-planning.js";
5
7
  export type { BuildDocumentationCatalogRequest } from "./application/use-cases/build-documentation-catalog.js";
6
8
  export type { FindDocumentsRequest } from "./application/use-cases/find-documents.js";
9
+ export type { PlanDocumentationDocumentRequest } from "./application/use-cases/plan-documentation-document.js";
7
10
  export { projectReferencedDocuments } from "./application/projections/document-catalog-projections.js";
8
11
  export { DocumentCatalogError } from "./document-catalog-error.js";
9
12
  export type { DocumentCatalogErrorCode } from "./document-catalog-error.js";
13
+ export { DocumentPlanningError } from "./document-planning-error.js";
14
+ export type { DocumentPlanningErrorCode } from "./document-planning-error.js";
10
15
  export declare function buildDocumentationCatalog(request: BuildDocumentationCatalogRequest): Promise<import("./application/model/document-catalog.js").DocumentationCatalogSnapshot>;
11
16
  export declare function findDocumentationDocuments(request: FindDocumentsRequest): Promise<import("./application/model/document-find.js").DocumentFindResult>;
17
+ /**
18
+ * Compiles a deterministic Document Plan without reserving an identity or
19
+ * mutating the consumer repository.
20
+ */
21
+ export declare function planDocumentationDocument(request: PlanDocumentationDocumentRequest): Promise<import("./application/model/document-planning.js").DocumentPlan>;
12
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/document-authoring/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,2CAA2C,CAAC;AAEnD,YAAY,EACV,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,+BAA+B,EAC/B,6BAA6B,EAC7B,8BAA8B,EAC9B,4BAA4B,EAC5B,4BAA4B,EAC5B,kCAAkC,EACnC,MAAM,yCAAyC,CAAC;AACjD,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EAAE,gCAAgC,EAAE,MAAM,wDAAwD,CAAC;AAC/G,YAAY,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2DAA2D,CAAC;AACvG,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE5E,wBAAsB,yBA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