@beehexa/hexasync-template-validate 2608.7.4
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/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/validate/buildValidationModel.d.ts +31 -0
- package/dist/validate/buildValidationModel.d.ts.map +1 -0
- package/dist/validate/buildValidationModel.js +68 -0
- package/dist/validate/buildValidationModel.js.map +1 -0
- package/dist/validate/context.d.ts +97 -0
- package/dist/validate/context.d.ts.map +1 -0
- package/dist/validate/context.js +90 -0
- package/dist/validate/context.js.map +1 -0
- package/dist/validate/contextFromGraph.d.ts +60 -0
- package/dist/validate/contextFromGraph.d.ts.map +1 -0
- package/dist/validate/contextFromGraph.js +77 -0
- package/dist/validate/contextFromGraph.js.map +1 -0
- package/dist/validate/harvestPullerTaskIds.d.ts +60 -0
- package/dist/validate/harvestPullerTaskIds.d.ts.map +1 -0
- package/dist/validate/harvestPullerTaskIds.js +115 -0
- package/dist/validate/harvestPullerTaskIds.js.map +1 -0
- package/dist/validate/model.d.ts +14 -0
- package/dist/validate/model.d.ts.map +1 -0
- package/dist/validate/model.js +92 -0
- package/dist/validate/model.js.map +1 -0
- package/dist/validate/registry.d.ts +20 -0
- package/dist/validate/registry.d.ts.map +1 -0
- package/dist/validate/registry.js +58 -0
- package/dist/validate/registry.js.map +1 -0
- package/dist/validate/rule.d.ts +18 -0
- package/dist/validate/rule.d.ts.map +1 -0
- package/dist/validate/rule.js +2 -0
- package/dist/validate/rule.js.map +1 -0
- package/dist/validate/ruleCatalog.d.ts +22 -0
- package/dist/validate/ruleCatalog.d.ts.map +1 -0
- package/dist/validate/ruleCatalog.js +263 -0
- package/dist/validate/ruleCatalog.js.map +1 -0
- package/dist/validate/rules/dependencyIntegrity.d.ts +60 -0
- package/dist/validate/rules/dependencyIntegrity.d.ts.map +1 -0
- package/dist/validate/rules/dependencyIntegrity.js +296 -0
- package/dist/validate/rules/dependencyIntegrity.js.map +1 -0
- package/dist/validate/rules/duplicates.d.ts +23 -0
- package/dist/validate/rules/duplicates.d.ts.map +1 -0
- package/dist/validate/rules/duplicates.js +321 -0
- package/dist/validate/rules/duplicates.js.map +1 -0
- package/dist/validate/rules/flow.d.ts +41 -0
- package/dist/validate/rules/flow.d.ts.map +1 -0
- package/dist/validate/rules/flow.js +559 -0
- package/dist/validate/rules/flow.js.map +1 -0
- package/dist/validate/rules/overwriteLoss.d.ts +23 -0
- package/dist/validate/rules/overwriteLoss.d.ts.map +1 -0
- package/dist/validate/rules/overwriteLoss.js +40 -0
- package/dist/validate/rules/overwriteLoss.js.map +1 -0
- package/dist/validate/rules/pullerKind.d.ts +3 -0
- package/dist/validate/rules/pullerKind.d.ts.map +1 -0
- package/dist/validate/rules/pullerKind.js +83 -0
- package/dist/validate/rules/pullerKind.js.map +1 -0
- package/dist/validate/rules/reference.d.ts +44 -0
- package/dist/validate/rules/reference.d.ts.map +1 -0
- package/dist/validate/rules/reference.js +370 -0
- package/dist/validate/rules/reference.js.map +1 -0
- package/dist/validate/rules/referenceKind.d.ts +25 -0
- package/dist/validate/rules/referenceKind.d.ts.map +1 -0
- package/dist/validate/rules/referenceKind.js +230 -0
- package/dist/validate/rules/referenceKind.js.map +1 -0
- package/dist/validate/rules/retiredType.d.ts +142 -0
- package/dist/validate/rules/retiredType.d.ts.map +1 -0
- package/dist/validate/rules/retiredType.js +228 -0
- package/dist/validate/rules/retiredType.js.map +1 -0
- package/dist/validate/rules/tables.d.ts +8 -0
- package/dist/validate/rules/tables.d.ts.map +1 -0
- package/dist/validate/rules/tables.js +116 -0
- package/dist/validate/rules/tables.js.map +1 -0
- package/dist/validate/rules/variableDrift.d.ts +63 -0
- package/dist/validate/rules/variableDrift.d.ts.map +1 -0
- package/dist/validate/rules/variableDrift.js +132 -0
- package/dist/validate/rules/variableDrift.js.map +1 -0
- package/dist/validate/rules/variables.d.ts +12 -0
- package/dist/validate/rules/variables.d.ts.map +1 -0
- package/dist/validate/rules/variables.js +207 -0
- package/dist/validate/rules/variables.js.map +1 -0
- package/dist/validate/sourceLocator.d.ts +32 -0
- package/dist/validate/sourceLocator.d.ts.map +1 -0
- package/dist/validate/sourceLocator.js +166 -0
- package/dist/validate/sourceLocator.js.map +1 -0
- package/package.json +32 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile-quality validation (AD-4, core).
|
|
3
|
+
*
|
|
4
|
+
* Moved here from `apps/cli/src/commands/compose/validate` in Story 1.2. Nothing in it reads a
|
|
5
|
+
* filesystem: `attachSnippets` is handed the already-prefetched source text, so the same rules
|
|
6
|
+
* run in CI, in the CLI and in an editor with unsaved buffers.
|
|
7
|
+
*
|
|
8
|
+
* The individual rules are exported alongside the registry because each is tested directly —
|
|
9
|
+
* a rule is where the profile semantics actually live, and testing only through `runValidation`
|
|
10
|
+
* would make a broken rule look like a broken registry.
|
|
11
|
+
*/
|
|
12
|
+
export * from './validate/context.js';
|
|
13
|
+
export * from './validate/contextFromGraph.js';
|
|
14
|
+
export * from './validate/rule.js';
|
|
15
|
+
export * from './validate/registry.js';
|
|
16
|
+
export * from './validate/model.js';
|
|
17
|
+
export { buildValidationModel } from './validate/buildValidationModel.js';
|
|
18
|
+
export * from './validate/sourceLocator.js';
|
|
19
|
+
export * from './validate/ruleCatalog.js';
|
|
20
|
+
export * from './validate/harvestPullerTaskIds.js';
|
|
21
|
+
export * from './validate/rules/duplicates.js';
|
|
22
|
+
export * from './validate/rules/flow.js';
|
|
23
|
+
export * from './validate/rules/pullerKind.js';
|
|
24
|
+
export * from './validate/rules/reference.js';
|
|
25
|
+
export * from './validate/rules/referenceKind.js';
|
|
26
|
+
export * from './validate/rules/retiredType.js';
|
|
27
|
+
export * from './validate/rules/tables.js';
|
|
28
|
+
export * from './validate/rules/dependencyIntegrity.js';
|
|
29
|
+
export * from './validate/rules/overwriteLoss.js';
|
|
30
|
+
export * from './validate/rules/variableDrift.js';
|
|
31
|
+
export * from './validate/rules/variables.js';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile-quality validation (AD-4, core).
|
|
3
|
+
*
|
|
4
|
+
* Moved here from `apps/cli/src/commands/compose/validate` in Story 1.2. Nothing in it reads a
|
|
5
|
+
* filesystem: `attachSnippets` is handed the already-prefetched source text, so the same rules
|
|
6
|
+
* run in CI, in the CLI and in an editor with unsaved buffers.
|
|
7
|
+
*
|
|
8
|
+
* The individual rules are exported alongside the registry because each is tested directly —
|
|
9
|
+
* a rule is where the profile semantics actually live, and testing only through `runValidation`
|
|
10
|
+
* would make a broken rule look like a broken registry.
|
|
11
|
+
*/
|
|
12
|
+
export * from './validate/context.js';
|
|
13
|
+
export * from './validate/contextFromGraph.js';
|
|
14
|
+
export * from './validate/rule.js';
|
|
15
|
+
export * from './validate/registry.js';
|
|
16
|
+
export * from './validate/model.js';
|
|
17
|
+
export { buildValidationModel } from './validate/buildValidationModel.js';
|
|
18
|
+
export * from './validate/sourceLocator.js';
|
|
19
|
+
export * from './validate/ruleCatalog.js';
|
|
20
|
+
export * from './validate/harvestPullerTaskIds.js';
|
|
21
|
+
export * from './validate/rules/duplicates.js';
|
|
22
|
+
export * from './validate/rules/flow.js';
|
|
23
|
+
export * from './validate/rules/pullerKind.js';
|
|
24
|
+
export * from './validate/rules/reference.js';
|
|
25
|
+
export * from './validate/rules/referenceKind.js';
|
|
26
|
+
export * from './validate/rules/retiredType.js';
|
|
27
|
+
export * from './validate/rules/tables.js';
|
|
28
|
+
export * from './validate/rules/dependencyIntegrity.js';
|
|
29
|
+
export * from './validate/rules/overwriteLoss.js';
|
|
30
|
+
export * from './validate/rules/variableDrift.js';
|
|
31
|
+
export * from './validate/rules/variables.js';
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Tracer } from '@beehexa/hexasync-template-compose';
|
|
2
|
+
import { type LibraryVariables } from './context.js';
|
|
3
|
+
import type { OverwriteRecord } from '@beehexa/hexasync-template-report-model';
|
|
4
|
+
export declare function buildValidationModel(input: {
|
|
5
|
+
projectTitle: string;
|
|
6
|
+
/** Pre-substitution form — rule ids and tracer ids are both token-form. */
|
|
7
|
+
tokenForm: any;
|
|
8
|
+
/** Post-substitution, key-sorted form — what actually ships. */
|
|
9
|
+
output: any;
|
|
10
|
+
variables: Record<string, unknown>;
|
|
11
|
+
raw: boolean;
|
|
12
|
+
projects: {
|
|
13
|
+
project: string;
|
|
14
|
+
generation: number;
|
|
15
|
+
weight: number;
|
|
16
|
+
componentPath: string;
|
|
17
|
+
}[];
|
|
18
|
+
reportDir: string;
|
|
19
|
+
componentPath: string;
|
|
20
|
+
rootMainYml: string;
|
|
21
|
+
tracer: Tracer;
|
|
22
|
+
/** The compose pass's prefetched file text — what snippets are cut from. */
|
|
23
|
+
sources: ReadonlyMap<string, string>;
|
|
24
|
+
/** From the resolver: files whose variables can never substitute (Story 1.9 AC 2). */
|
|
25
|
+
unadmittedVariableFiles?: string[];
|
|
26
|
+
/** Libraries this project borrows files from (Story 1.8). */
|
|
27
|
+
libraryVariables?: readonly LibraryVariables[];
|
|
28
|
+
overwrites?: readonly OverwriteRecord[];
|
|
29
|
+
relative: (from: string, to: string) => string;
|
|
30
|
+
}): import("@beehexa/hexasync-template-report-model").ValidationReportModel;
|
|
31
|
+
//# sourceMappingURL=buildValidationModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildValidationModel.d.ts","sourceRoot":"","sources":["../../src/validate/buildValidationModel.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,MAAM,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAK/E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,SAAS,EAAE,GAAG,CAAC;IACf,gEAAgE;IAChE,MAAM,EAAE,GAAG,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,EAAE,MAAM,CAAC;KACvB,EAAE,CAAC;IACJ,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,sFAAsF;IACtF,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C,UAAU,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACxC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;CAChD,2EAkDA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Produce the validation report MODEL, and render nothing (Story 1.7 AC 2).
|
|
3
|
+
*
|
|
4
|
+
* A caller that wants to show findings in a Problems panel needs the model and nothing else;
|
|
5
|
+
* making it reachable only by way of a Markdown renderer would force an editor to render a
|
|
6
|
+
* document and parse it back. Rendering lives in `@beehexa/hexasync-template-report-render`, which is
|
|
7
|
+
* an adapter precisely because Markdown and HTML are output formats, not domain facts.
|
|
8
|
+
*
|
|
9
|
+
* Everything here is pure: the source text arrives already prefetched by the compose pass, so
|
|
10
|
+
* this reads nothing.
|
|
11
|
+
*/
|
|
12
|
+
import { parse } from 'yaml';
|
|
13
|
+
import { joinUri } from '@beehexa/hexasync-template-model';
|
|
14
|
+
import { DIRECTIVE_KEYS, } from '@beehexa/hexasync-template-compose';
|
|
15
|
+
import { createValidationContext } from './context.js';
|
|
16
|
+
import { runValidation } from './registry.js';
|
|
17
|
+
import { buildValidationReportModel } from './model.js';
|
|
18
|
+
import { attachSnippets } from './sourceLocator.js';
|
|
19
|
+
export function buildValidationModel(input) {
|
|
20
|
+
const rootMainPath = joinUri(input.componentPath, 'main.yaml');
|
|
21
|
+
// Map components authored INLINE in the root main.yaml back to it. They are the merge base,
|
|
22
|
+
// so the tracer never emits an event for them and their snippets would otherwise be lost.
|
|
23
|
+
// Components living in partials are already covered by tracer events.
|
|
24
|
+
const rootSources = new Map();
|
|
25
|
+
try {
|
|
26
|
+
const rc = parse(input.rootMainYml, { keepSourceTokens: true });
|
|
27
|
+
for (const [key, val] of Object.entries(rc ?? {})) {
|
|
28
|
+
if (DIRECTIVE_KEYS.has(key))
|
|
29
|
+
continue;
|
|
30
|
+
if (Array.isArray(val)) {
|
|
31
|
+
for (const item of val) {
|
|
32
|
+
if (!item || typeof item !== 'object')
|
|
33
|
+
continue;
|
|
34
|
+
const raw = 'id' in item ? item.id : 'key' in item ? item.key : undefined;
|
|
35
|
+
if (raw == null)
|
|
36
|
+
continue;
|
|
37
|
+
rootSources.set(JSON.stringify([key, String(raw)]), rootMainPath);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else if (val && typeof val === 'object') {
|
|
41
|
+
// Map collections are keyed by their own map key rather than an id field.
|
|
42
|
+
for (const mk of Object.keys(val))
|
|
43
|
+
rootSources.set(JSON.stringify([key, mk]), rootMainPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Best-effort seeding; its absence only costs inline-main snippets, never a finding.
|
|
49
|
+
}
|
|
50
|
+
const ctx = createValidationContext({
|
|
51
|
+
projectTitle: input.projectTitle,
|
|
52
|
+
tokenForm: input.tokenForm,
|
|
53
|
+
outputForm: input.output,
|
|
54
|
+
variables: input.variables,
|
|
55
|
+
raw: input.raw,
|
|
56
|
+
projects: input.projects,
|
|
57
|
+
reportDir: input.reportDir,
|
|
58
|
+
rootMainPath,
|
|
59
|
+
tracer: input.tracer,
|
|
60
|
+
relative: input.relative,
|
|
61
|
+
extraSources: rootSources,
|
|
62
|
+
unadmittedVariableFiles: input.unadmittedVariableFiles,
|
|
63
|
+
libraryVariables: input.libraryVariables,
|
|
64
|
+
overwrites: input.overwrites,
|
|
65
|
+
});
|
|
66
|
+
return buildValidationReportModel(attachSnippets(runValidation(ctx), ctx, input.sources), ctx);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=buildValidationModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildValidationModel.js","sourceRoot":"","sources":["../../src/validate/buildValidationModel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EACL,cAAc,GAEf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAyB,MAAM,cAAc,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,UAAU,oBAAoB,CAAC,KA0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,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,qFAAqF;IACvF,CAAC;IAED,MAAM,GAAG,GAAG,uBAAuB,CAAC;QAClC,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,UAAU,EAAE,KAAK,CAAC,MAAM;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,YAAY;QACZ,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,YAAY,EAAE,WAAW;QACzB,uBAAuB,EAAE,KAAK,CAAC,uBAAuB;QACtD,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,UAAU,EAAE,KAAK,CAAC,UAAU;KAC7B,CAAC,CAAC;IAEH,OAAO,0BAA0B,CAC/B,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,EACtD,GAAG,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { OverwriteRecord } from '@beehexa/hexasync-template-report-model';
|
|
2
|
+
import { Tracer } from '@beehexa/hexasync-template-compose';
|
|
3
|
+
/** A contributing project (from the resolver), used for orphan/reference context. */
|
|
4
|
+
export interface ValidationProjectInfo {
|
|
5
|
+
project: string;
|
|
6
|
+
generation: number;
|
|
7
|
+
weight: number;
|
|
8
|
+
componentPath: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Everything a validation rule needs to inspect a composed profile, injected so the
|
|
12
|
+
* rules and renderers stay pure and filesystem-free (AR-2/AR-4). `tokenForm` is the
|
|
13
|
+
* pre-variable-substitution merged config (reconcileCnf); `outputForm` is the final
|
|
14
|
+
* output.yaml config (sortedMainCnf). Some rules read one, some the other.
|
|
15
|
+
*/
|
|
16
|
+
/** One component library's own variable declaration, as a rule sees it (Story 1.8). */
|
|
17
|
+
export interface LibraryVariables {
|
|
18
|
+
/** The library folder, named in the finding. */
|
|
19
|
+
readonly library: string;
|
|
20
|
+
readonly sourceFile: string;
|
|
21
|
+
readonly variables: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export interface ValidationContext {
|
|
24
|
+
projectTitle: string;
|
|
25
|
+
tokenForm: any;
|
|
26
|
+
outputForm: any;
|
|
27
|
+
/** The assembled variable pool (keys = declared variable names). */
|
|
28
|
+
variables: Record<string, unknown>;
|
|
29
|
+
/** True when composed with --raw (tokens intentionally NOT substituted). */
|
|
30
|
+
raw: boolean;
|
|
31
|
+
projects: ValidationProjectInfo[];
|
|
32
|
+
/** Libraries this project borrows files from, for the drift rule. Absent means none were found. */
|
|
33
|
+
libraryVariables?: readonly LibraryVariables[];
|
|
34
|
+
/** Wholesale array overwrites that dropped inherited components (Story 1.9). */
|
|
35
|
+
overwrites?: readonly OverwriteRecord[];
|
|
36
|
+
reportDir: string;
|
|
37
|
+
rootMainPath: string;
|
|
38
|
+
relative: (from: string, to: string) => string;
|
|
39
|
+
/** Absolute source file a top-level component came from (root main.yaml fallback). */
|
|
40
|
+
sourceFileFor(parentKey: string, idOrKey: string): string | undefined;
|
|
41
|
+
/** Absolute source file ONLY when a real tracer event maps it (no main.yaml fallback) —
|
|
42
|
+
* used for line snippets so we never read the wrong file for a same-id component. */
|
|
43
|
+
sourceFileForStrict(parentKey: string, idOrKey: string): string | undefined;
|
|
44
|
+
/** `sourceFileFor` rendered relative to the report dir (null when unavailable). */
|
|
45
|
+
sourceLinkFor(parentKey: string, idOrKey: string): string | null;
|
|
46
|
+
/**
|
|
47
|
+
* `variables.yaml` files discovered by the component glob but never admitted to the pool.
|
|
48
|
+
*
|
|
49
|
+
* The composer cannot infer this after the fact: by the time validation sees the output, an
|
|
50
|
+
* unadmitted file is indistinguishable from one that simply defined nothing. Only the resolver
|
|
51
|
+
* knows which files it chose not to admit, so it has to be carried here (Story 1.9 AC 2).
|
|
52
|
+
*/
|
|
53
|
+
unadmittedVariableFiles: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface ValidationContextInput {
|
|
56
|
+
projectTitle: string;
|
|
57
|
+
tokenForm: any;
|
|
58
|
+
outputForm: any;
|
|
59
|
+
variables: Record<string, unknown>;
|
|
60
|
+
raw: boolean;
|
|
61
|
+
projects: ValidationProjectInfo[];
|
|
62
|
+
reportDir: string;
|
|
63
|
+
rootMainPath: string;
|
|
64
|
+
tracer?: Tracer;
|
|
65
|
+
relative: (from: string, to: string) => string;
|
|
66
|
+
/** Extra `JSON([parentKey, idOrKey]) → absolute file` seeds for components the tracer
|
|
67
|
+
* didn't observe — notably components authored inline in the root main.yaml (whose
|
|
68
|
+
* merge-base status means no tracer event). Real tracer events take precedence. */
|
|
69
|
+
extraSources?: Map<string, string>;
|
|
70
|
+
unadmittedVariableFiles?: string[];
|
|
71
|
+
libraryVariables?: readonly LibraryVariables[];
|
|
72
|
+
overwrites?: readonly OverwriteRecord[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Build a ValidationContext. Component→source-file mapping is derived from the tracer's
|
|
76
|
+
* depth-0 events (first write wins); components authored inline in the root main.yaml (or
|
|
77
|
+
* any without an event) fall back to the root main.yaml path.
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Top-level `main.yaml` keys that are COMPOSED but never VALIDATED (Jazz, 2026-08-05).
|
|
81
|
+
*
|
|
82
|
+
* `author` is metadata about who wrote a template — a name, an email, an id. It is not part of the thing
|
|
83
|
+
* being validated, nobody plans to work on it, and it appears in **112 of the corpus's 113** projects, so
|
|
84
|
+
* anything that ever did report on it would report on nearly everything.
|
|
85
|
+
*
|
|
86
|
+
* Removed from the document the RULES see, not from the composed output: `author` still composes, still
|
|
87
|
+
* substitutes its variables, and still reaches `output.yaml`. This is the one seam where "part of the
|
|
88
|
+
* project" and "part of what we check" come apart.
|
|
89
|
+
*
|
|
90
|
+
* Nothing reports on it today — verified across every validation report in the corpus, which contains
|
|
91
|
+
* **zero** author findings, and its variables are referenced from the composed document so `VAR-3` does
|
|
92
|
+
* not fire either. So this is a GUARD rather than a fix: it keeps a future rule that walks the document
|
|
93
|
+
* generically from discovering 112 projects' worth of metadata and calling it a problem.
|
|
94
|
+
*/
|
|
95
|
+
export declare const UNVALIDATED_TOP_LEVEL_KEYS: readonly string[];
|
|
96
|
+
export declare function createValidationContext(input: ValidationContextInput): ValidationContext;
|
|
97
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/validate/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE5D,qFAAqF;AACrF,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,uFAAuF;AACvF,MAAM,WAAW,gBAAgB;IAC/B,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC;IACf,UAAU,EAAE,GAAG,CAAC;IAChB,oEAAoE;IACpE,SAA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IACpF,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,gBAAgB,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C,UAAU,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CACzC;AAED;;;;GAIG;AACH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAAe,CAAC;AAmBxE,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,sBAAsB,GAC5B,iBAAiB,CAiDnB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a ValidationContext. Component→source-file mapping is derived from the tracer's
|
|
3
|
+
* depth-0 events (first write wins); components authored inline in the root main.yaml (or
|
|
4
|
+
* any without an event) fall back to the root main.yaml path.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Top-level `main.yaml` keys that are COMPOSED but never VALIDATED (Jazz, 2026-08-05).
|
|
8
|
+
*
|
|
9
|
+
* `author` is metadata about who wrote a template — a name, an email, an id. It is not part of the thing
|
|
10
|
+
* being validated, nobody plans to work on it, and it appears in **112 of the corpus's 113** projects, so
|
|
11
|
+
* anything that ever did report on it would report on nearly everything.
|
|
12
|
+
*
|
|
13
|
+
* Removed from the document the RULES see, not from the composed output: `author` still composes, still
|
|
14
|
+
* substitutes its variables, and still reaches `output.yaml`. This is the one seam where "part of the
|
|
15
|
+
* project" and "part of what we check" come apart.
|
|
16
|
+
*
|
|
17
|
+
* Nothing reports on it today — verified across every validation report in the corpus, which contains
|
|
18
|
+
* **zero** author findings, and its variables are referenced from the composed document so `VAR-3` does
|
|
19
|
+
* not fire either. So this is a GUARD rather than a fix: it keeps a future rule that walks the document
|
|
20
|
+
* generically from discovering 112 projects' worth of metadata and calling it a problem.
|
|
21
|
+
*/
|
|
22
|
+
export const UNVALIDATED_TOP_LEVEL_KEYS = ['author'];
|
|
23
|
+
/**
|
|
24
|
+
* The document the rules see: the composed one, minus the keys above.
|
|
25
|
+
*
|
|
26
|
+
* A shallow copy. The subtree is dropped by reference rather than cloned away, so this costs nothing on a
|
|
27
|
+
* document that does not carry the key — which is the single project in the corpus without an `author`.
|
|
28
|
+
*/
|
|
29
|
+
function validatable(tokenForm) {
|
|
30
|
+
if (!tokenForm || typeof tokenForm !== 'object' || Array.isArray(tokenForm)) {
|
|
31
|
+
return tokenForm;
|
|
32
|
+
}
|
|
33
|
+
const present = UNVALIDATED_TOP_LEVEL_KEYS.filter((key) => key in tokenForm);
|
|
34
|
+
if (present.length === 0)
|
|
35
|
+
return tokenForm;
|
|
36
|
+
const copy = { ...tokenForm };
|
|
37
|
+
for (const key of present)
|
|
38
|
+
delete copy[key];
|
|
39
|
+
return copy;
|
|
40
|
+
}
|
|
41
|
+
export function createValidationContext(input) {
|
|
42
|
+
const sourceByKey = new Map();
|
|
43
|
+
const events = input.tracer?.events?.() ?? [];
|
|
44
|
+
for (const e of events) {
|
|
45
|
+
if (e.depth !== 0 || !e.sourceFile)
|
|
46
|
+
continue;
|
|
47
|
+
const k = JSON.stringify([e.parentKey, e.idOrKey]);
|
|
48
|
+
if (!sourceByKey.has(k))
|
|
49
|
+
sourceByKey.set(k, e.sourceFile);
|
|
50
|
+
}
|
|
51
|
+
// Fill gaps with root-main (inline) components that produced no merge event; a real
|
|
52
|
+
// tracer event (a partial) always wins over this default.
|
|
53
|
+
if (input.extraSources) {
|
|
54
|
+
for (const [k, file] of input.extraSources) {
|
|
55
|
+
if (!sourceByKey.has(k))
|
|
56
|
+
sourceByKey.set(k, file);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const sourceFileForStrict = (parentKey, idOrKey) => sourceByKey.get(JSON.stringify([parentKey, idOrKey]));
|
|
60
|
+
const sourceFileFor = (parentKey, idOrKey) => sourceFileForStrict(parentKey, idOrKey) ?? input.rootMainPath;
|
|
61
|
+
const sourceLinkFor = (parentKey, idOrKey) => {
|
|
62
|
+
const f = sourceFileFor(parentKey, idOrKey);
|
|
63
|
+
if (!f)
|
|
64
|
+
return null;
|
|
65
|
+
try {
|
|
66
|
+
return input.relative(input.reportDir, f);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
projectTitle: input.projectTitle,
|
|
74
|
+
tokenForm: validatable(input.tokenForm),
|
|
75
|
+
outputForm: input.outputForm,
|
|
76
|
+
variables: input.variables ?? {},
|
|
77
|
+
raw: !!input.raw,
|
|
78
|
+
projects: input.projects,
|
|
79
|
+
libraryVariables: input.libraryVariables ?? [],
|
|
80
|
+
overwrites: input.overwrites ?? [],
|
|
81
|
+
reportDir: input.reportDir,
|
|
82
|
+
rootMainPath: input.rootMainPath,
|
|
83
|
+
relative: input.relative,
|
|
84
|
+
sourceFileFor,
|
|
85
|
+
sourceFileForStrict,
|
|
86
|
+
sourceLinkFor,
|
|
87
|
+
unadmittedVariableFiles: input.unadmittedVariableFiles ?? [],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/validate/context.ts"],"names":[],"mappings":"AA8EA;;;;GAIG;AACH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAsB,CAAC,QAAQ,CAAC,CAAC;AAExE;;;;;GAKG;AACH,SAAS,WAAW,CAAC,SAAc;IACjC,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5E,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,OAAO,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI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+
import { ValidationContext, type LibraryVariables } from './context.js';
|
|
3
|
+
/** A component as the graph knows it — collection, id, and the file it truly lives in. */
|
|
4
|
+
export interface GraphComponentProvenance {
|
|
5
|
+
readonly collection: string;
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/** The file it was declared in. Absent for a component the graph could not attribute. */
|
|
8
|
+
readonly sourceFile?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ContextFromGraphInput {
|
|
11
|
+
readonly projectTitle: string;
|
|
12
|
+
/**
|
|
13
|
+
* The composed document as the graph holds it — its `mergedValue`, PRE-cleanup.
|
|
14
|
+
*
|
|
15
|
+
* Must be the document compose produced, not one rebuilt by regrouping the component list: a
|
|
16
|
+
* re-derived document is a second answer to "what did compose produce", which is the disagreement
|
|
17
|
+
* C3 exists to prevent.
|
|
18
|
+
*
|
|
19
|
+
* It is normalised below rather than used directly, and the reason is subtle enough to have caused
|
|
20
|
+
* a real parity failure. The CLI's `tokenForm` is `parse(stringifyMerged(merged))` — a round trip
|
|
21
|
+
* that applies the `!!_remove_` sweep. Phase 1 removed that round trip from the index for speed
|
|
22
|
+
* (−382 ms), on the recorded grounds that the cleanup "only affects `indexGroups` arrays, never
|
|
23
|
+
* component identity, so the pre-cleanup value is safe to hand to STRUCTURAL consumers". That
|
|
24
|
+
* reasoning is correct and it does not extend here: validation is not a structural consumer. It
|
|
25
|
+
* walks the entire document, so the uncleaned value made the editor find 71 fewer VAR-3 findings
|
|
26
|
+
* than the CLI on one real project — caught by the parity test, not by reading.
|
|
27
|
+
*/
|
|
28
|
+
readonly tokenForm: unknown;
|
|
29
|
+
/**
|
|
30
|
+
* The same document with variables substituted, when the caller has one.
|
|
31
|
+
*
|
|
32
|
+
* Only one rule reads it (VAR-1's leaked-token check) and only when not composing raw. Omitting it
|
|
33
|
+
* is honest for a caller that has not substituted: the rule then behaves as it does under `--raw`,
|
|
34
|
+
* which is a documented mode rather than a silent difference.
|
|
35
|
+
*/
|
|
36
|
+
readonly outputForm?: unknown;
|
|
37
|
+
readonly variables: Record<string, unknown>;
|
|
38
|
+
/** True when tokens are deliberately left unsubstituted. */
|
|
39
|
+
readonly raw?: boolean;
|
|
40
|
+
/** The project's `partials` folder. `main.yaml` under it is the fallback source file. */
|
|
41
|
+
readonly componentPath: string;
|
|
42
|
+
/** Every component the graph holds, with its provenance. */
|
|
43
|
+
readonly components: readonly GraphComponentProvenance[];
|
|
44
|
+
/**
|
|
45
|
+
* Where a report would be written, for `sourceLinkFor`.
|
|
46
|
+
*
|
|
47
|
+
* The editor has no report directory and passes the component path, which makes links relative to
|
|
48
|
+
* the project. Nothing in the editor reads them; they exist so the same context type serves both.
|
|
49
|
+
*/
|
|
50
|
+
readonly reportDir?: string;
|
|
51
|
+
readonly relative?: (from: string, to: string) => string;
|
|
52
|
+
readonly unadmittedVariableFiles?: readonly string[];
|
|
53
|
+
/** Libraries this project borrows files from, carried on the graph (Story 1.8). */
|
|
54
|
+
readonly libraryVariables?: readonly LibraryVariables[];
|
|
55
|
+
/** Wholesale overwrites the graph observed while merging (Story 1.9). */
|
|
56
|
+
readonly overwrites?: readonly OverwriteRecord[];
|
|
57
|
+
readonly projects?: ValidationContext['projects'];
|
|
58
|
+
}
|
|
59
|
+
export declare function validationContextFromGraph(input: ContextFromGraphInput): ValidationContext;
|
|
60
|
+
//# sourceMappingURL=contextFromGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextFromGraph.d.ts","sourceRoot":"","sources":["../../src/validate/contextFromGraph.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,iBAAiB,EAEjB,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AAEtB,0FAA0F;AAC1F,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yFAAyF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from the tracer's depth-0 events;
|
|
5
|
+
* the editor's Tier 2 index has no tracer and carries provenance on the components instead. Both are
|
|
6
|
+
* the same fact recorded two ways, and this is the adapter between them.
|
|
7
|
+
*
|
|
8
|
+
* It lives HERE, beside the rules, for one reason: FR-54 says one rule set and two surfaces, and a
|
|
9
|
+
* construction living in the extension would let a rule be wired into the CLI and forgotten in the
|
|
10
|
+
* editor. Counter-metric C3 — "the editor and CI cannot disagree" — is a property of this file.
|
|
11
|
+
*
|
|
12
|
+
* The input is described STRUCTURALLY rather than as an `EffectiveGraph`, so `template-validate` does
|
|
13
|
+
* not take a dependency on `template-index`. The two packages are siblings; making one import the
|
|
14
|
+
* other to share three fields would be a boundary crossing that buys nothing (AD-3's direction rule).
|
|
15
|
+
*/
|
|
16
|
+
import { parse } from 'yaml';
|
|
17
|
+
import { stringifyMerged, } from '@beehexa/hexasync-template-compose';
|
|
18
|
+
import { createValidationContext, } from './context.js';
|
|
19
|
+
/**
|
|
20
|
+
* URI-safe relative path, for a host that has no `path` module.
|
|
21
|
+
*
|
|
22
|
+
* Deliberately simple: strip a shared prefix, and otherwise return the target unchanged. A wrong
|
|
23
|
+
* relative path costs a less pretty link; inventing `../` arithmetic over URIs with differing
|
|
24
|
+
* schemes would risk a link to somewhere that does not exist.
|
|
25
|
+
*/
|
|
26
|
+
function uriRelative(from, to) {
|
|
27
|
+
const base = from.endsWith('/') ? from : `${from}/`;
|
|
28
|
+
return to.startsWith(base) ? to.slice(base.length) : to;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The document as the COMPOSER defines it, from the graph's uncleaned value.
|
|
32
|
+
*
|
|
33
|
+
* `stringifyMerged` + `parse` is exactly what `composeProject` does, reused rather than reimplemented
|
|
34
|
+
* so the two cannot drift. Paid once per validation rather than once per build, which is why Phase 1
|
|
35
|
+
* was right to take it off the build path and why taking it off this path too would be wrong.
|
|
36
|
+
*/
|
|
37
|
+
function composedDocument(mergedValue) {
|
|
38
|
+
return parse(stringifyMerged(mergedValue), { keepSourceTokens: true });
|
|
39
|
+
}
|
|
40
|
+
export function validationContextFromGraph(input) {
|
|
41
|
+
const rootMainPath = `${input.componentPath}/main.yaml`;
|
|
42
|
+
const tokenForm = composedDocument(input.tokenForm);
|
|
43
|
+
// The same `[parentKey, idOrKey] → file` shape the tracer path produces. `extraSources` is the seam
|
|
44
|
+
// the context already exposed for components the tracer never observed, which is exactly this case
|
|
45
|
+
// — every component here comes from provenance rather than from an event.
|
|
46
|
+
const sources = new Map();
|
|
47
|
+
for (const component of input.components) {
|
|
48
|
+
if (!component.sourceFile)
|
|
49
|
+
continue;
|
|
50
|
+
const key = JSON.stringify([component.collection, component.id]);
|
|
51
|
+
// First wins, matching the tracer path's rule. Two components sharing an identity is a duplicate,
|
|
52
|
+
// which is `duplicatesRule`'s finding to report — not something to resolve silently here.
|
|
53
|
+
if (!sources.has(key))
|
|
54
|
+
sources.set(key, component.sourceFile);
|
|
55
|
+
}
|
|
56
|
+
return createValidationContext({
|
|
57
|
+
projectTitle: input.projectTitle,
|
|
58
|
+
tokenForm,
|
|
59
|
+
// `?? tokenForm` rather than `?? {}`: a rule reading an empty document would conclude the project
|
|
60
|
+
// declares nothing, which is a WRONG answer where "unsubstituted" is merely an incomplete one.
|
|
61
|
+
outputForm: input.outputForm ?? tokenForm,
|
|
62
|
+
variables: input.variables,
|
|
63
|
+
// Raw when no substituted form was supplied, because that is precisely what raw means: the
|
|
64
|
+
// caller is working in token form. Inferring it keeps VAR-1 from comparing a document against
|
|
65
|
+
// itself and reporting every token as leaked.
|
|
66
|
+
raw: input.raw ?? input.outputForm === undefined,
|
|
67
|
+
projects: input.projects ?? [],
|
|
68
|
+
reportDir: input.reportDir ?? input.componentPath,
|
|
69
|
+
rootMainPath,
|
|
70
|
+
relative: input.relative ?? uriRelative,
|
|
71
|
+
extraSources: sources,
|
|
72
|
+
unadmittedVariableFiles: [...(input.unadmittedVariableFiles ?? [])],
|
|
73
|
+
libraryVariables: input.libraryVariables ?? [],
|
|
74
|
+
overwrites: input.overwrites ?? [],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=contextFromGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextFromGraph.js","sourceRoot":"","sources":["../../src/validate/contextFromGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,eAAe,GAEhB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,uBAAuB,GAExB,MAAM,cAAc,CAAC;AA4DtB;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,IAAY,EAAE,EAAU;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;IACpD,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,SAAS,gBAAgB,CAAC,WAAoB;IAC5C,OAAO,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAA4B;IAE5B,MAAM,YAAY,GAAG,GAAG,KAAK,CAAC,aAAa,YAAY,CAAC;IACxD,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEpD,oGAAoG;IACpG,mGAAmG;IACnG,0EAA0E;IAC1E,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,KAAK,MAAM,SAAS,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACzC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DATA_STATUS` steps carrying a `data.taskId` (mirrors core.api's
|
|
6
|
+
* puller-owns-task inversion). Legacy pullers instead have the edge declared the other
|
|
7
|
+
* way — `objectAssociations[taskId].puller.id` (task-declares-puller). This module
|
|
8
|
+
* harvests the new-kind edge so the REF family can UNION it with the legacy edge and
|
|
9
|
+
* see tasks that are only owned by a steps-based puller.
|
|
10
|
+
*
|
|
11
|
+
* Pure over the token-form config; never throws. All findings that consume this are
|
|
12
|
+
* ADVISORY — nothing here can change the compose exit code.
|
|
13
|
+
*/
|
|
14
|
+
/** The step arrays a new-kind puller uses (no legacy before/pull/afterPullSteps). */
|
|
15
|
+
export declare const NEW_KIND_PHASES: readonly ["steps", "onErrorSteps", "finalSteps"];
|
|
16
|
+
/** Step display types that statically declare a task the puller writes into. */
|
|
17
|
+
export declare const TASK_DECL_STEP_TYPES: Set<string>;
|
|
18
|
+
/** Normalized, upper-cased step type from any of the type-bearing fields.
|
|
19
|
+
* NOTE: kept broad (reads `type`, case-insensitive) for the FLOW rules that recognize
|
|
20
|
+
* IF/EXCEPTION guards authored under any field. The HARVEST uses `harvestStepType` instead. */
|
|
21
|
+
export declare function stepType(s: any): string;
|
|
22
|
+
/**
|
|
23
|
+
* A puller is the NEW kind when it carries a non-empty `steps` array. This is the single
|
|
24
|
+
* new-kind detection predicate used across compose (per the design's §7); old-kind pullers
|
|
25
|
+
* (with beforePullSteps/pullSteps/afterPullSteps and no `steps`) return false, so every
|
|
26
|
+
* legacy code path stays byte-identical.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isNewKindPuller(p: any): boolean;
|
|
29
|
+
/** One harvested puller→task edge (a static taskId a SAVE/UPDATE step writes into). */
|
|
30
|
+
export interface HarvestedTaskRef {
|
|
31
|
+
/** Resolved task id (variables substituted). */
|
|
32
|
+
taskId: string;
|
|
33
|
+
/** Original token-form task id (for source-attributed messages). */
|
|
34
|
+
rawTaskId: string;
|
|
35
|
+
/** Owning puller id (when present). */
|
|
36
|
+
pullerId?: string;
|
|
37
|
+
/** The step key that declared it (when present). */
|
|
38
|
+
stepKey?: string;
|
|
39
|
+
/** The phase array it was found in (`steps`/`onErrorSteps`/`finalSteps`). */
|
|
40
|
+
phase: string;
|
|
41
|
+
/** The declaring step type (SAVE_TASK_DATA / UPDATE_TASK_DATA_STATUS). */
|
|
42
|
+
stepType: string;
|
|
43
|
+
}
|
|
44
|
+
export interface PullerTaskHarvest {
|
|
45
|
+
/** Every harvested edge, in document order. */
|
|
46
|
+
refs: HarvestedTaskRef[];
|
|
47
|
+
/** Resolved task ids owned by any new-kind puller. */
|
|
48
|
+
taskIds: Set<string>;
|
|
49
|
+
/** Resolved taskId → set of owning puller ids. */
|
|
50
|
+
ownerByTask: Map<string, Set<string>>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Scan every puller's new-kind phase arrays for static `SAVE_TASK_DATA` /
|
|
54
|
+
* `UPDATE_TASK_DATA_STATUS` steps and collect their `data.taskId`. Dynamic (`{{…}}`),
|
|
55
|
+
* empty, and still-unresolved (`**token**`) task ids are skipped (they are not statically
|
|
56
|
+
* decidable and are owned by other rules). `resolve` maps token-form values to their
|
|
57
|
+
* composed values so a taskId and its object id compare equal across value-aliases.
|
|
58
|
+
*/
|
|
59
|
+
export declare function harvestPullerTaskIds(cnf: any, resolve?: (v: string) => string): PullerTaskHarvest;
|
|
60
|
+
//# sourceMappingURL=harvestPullerTaskIds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harvestPullerTaskIds.d.ts","sourceRoot":"","sources":["../../src/validate/harvestPullerTaskIds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,qFAAqF;AACrF,eAAO,MAAM,eAAe,kDAAmD,CAAC;AAEhF,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,aAG/B,CAAC;AAMH;;+FAE+F;AAC/F,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAEvC;AA0BD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,GAAG,OAAO,CAO/C;AAED,uFAAuF;AACvF,MAAM,WAAW,gBAAgB;IAC/B,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,sDAAsD;IACtD,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,kDAAkD;IAClD,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACvC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAiB,GACxC,iBAAiB,CAwCnB"}
|