@gate-forge/cli 0.7.1 → 0.9.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.
- package/README.md +91 -704
- package/dist/adapter-audit.d.ts +208 -0
- package/dist/adapter-audit.d.ts.map +1 -0
- package/dist/adapter-audit.js +579 -0
- package/dist/adapter-audit.js.map +1 -0
- package/dist/adapter-scaffold.d.ts +91 -0
- package/dist/adapter-scaffold.d.ts.map +1 -0
- package/dist/adapter-scaffold.js +474 -0
- package/dist/adapter-scaffold.js.map +1 -0
- package/dist/adopted-baseline.d.ts +10 -0
- package/dist/adopted-baseline.d.ts.map +1 -1
- package/dist/adopted-baseline.js +18 -1
- package/dist/adopted-baseline.js.map +1 -1
- package/dist/args.d.ts +15 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +61 -2
- package/dist/args.js.map +1 -1
- package/dist/behavior-setup.d.ts +239 -0
- package/dist/behavior-setup.d.ts.map +1 -0
- package/dist/behavior-setup.js +751 -0
- package/dist/behavior-setup.js.map +1 -0
- package/dist/broker.d.ts.map +1 -1
- package/dist/broker.js +28 -2
- package/dist/broker.js.map +1 -1
- package/dist/cache-exclusions.d.ts +45 -0
- package/dist/cache-exclusions.d.ts.map +1 -0
- package/dist/cache-exclusions.js +205 -0
- package/dist/cache-exclusions.js.map +1 -0
- package/dist/candidate-tree.d.ts +86 -14
- package/dist/candidate-tree.d.ts.map +1 -1
- package/dist/candidate-tree.js +236 -62
- package/dist/candidate-tree.js.map +1 -1
- package/dist/ci-witnessed-template.d.ts +43 -0
- package/dist/ci-witnessed-template.d.ts.map +1 -0
- package/dist/ci-witnessed-template.js +283 -0
- package/dist/ci-witnessed-template.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +31 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/adapters.d.ts +15 -0
- package/dist/commands/adapters.d.ts.map +1 -0
- package/dist/commands/adapters.js +355 -0
- package/dist/commands/adapters.js.map +1 -0
- package/dist/commands/adopt.d.ts +7 -0
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +44 -2
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/baseline.d.ts.map +1 -1
- package/dist/commands/baseline.js +42 -1
- package/dist/commands/baseline.js.map +1 -1
- package/dist/commands/blocking.d.ts +105 -2
- package/dist/commands/blocking.d.ts.map +1 -1
- package/dist/commands/blocking.js +395 -53
- package/dist/commands/blocking.js.map +1 -1
- package/dist/commands/check.d.ts +36 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +1068 -64
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/classify.d.ts +2 -1
- package/dist/commands/classify.d.ts.map +1 -1
- package/dist/commands/classify.js +188 -5
- package/dist/commands/classify.js.map +1 -1
- package/dist/commands/enforce.d.ts +4 -4
- package/dist/commands/enforce.d.ts.map +1 -1
- package/dist/commands/enforce.js +41 -9
- package/dist/commands/enforce.js.map +1 -1
- package/dist/commands/enforcement.d.ts +13 -1
- package/dist/commands/enforcement.d.ts.map +1 -1
- package/dist/commands/enforcement.js +880 -33
- package/dist/commands/enforcement.js.map +1 -1
- package/dist/commands/explain.d.ts +1 -1
- package/dist/commands/explain.d.ts.map +1 -1
- package/dist/commands/explain.js +162 -3
- package/dist/commands/explain.js.map +1 -1
- package/dist/commands/history.d.ts +12 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +45 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/init-presets.d.ts +155 -0
- package/dist/commands/init-presets.d.ts.map +1 -0
- package/dist/commands/init-presets.js +203 -0
- package/dist/commands/init-presets.js.map +1 -0
- package/dist/commands/init.d.ts +7 -12
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +987 -99
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +29 -13
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/next.d.ts.map +1 -1
- package/dist/commands/next.js +846 -19
- package/dist/commands/next.js.map +1 -1
- package/dist/commands/pre-commit.d.ts +25 -0
- package/dist/commands/pre-commit.d.ts.map +1 -1
- package/dist/commands/pre-commit.js +91 -6
- package/dist/commands/pre-commit.js.map +1 -1
- package/dist/commands/quarantine.d.ts +16 -0
- package/dist/commands/quarantine.d.ts.map +1 -0
- package/dist/commands/quarantine.js +213 -0
- package/dist/commands/quarantine.js.map +1 -0
- package/dist/commands/run.d.ts +39 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +196 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/test-gates.d.ts +284 -2
- package/dist/commands/test-gates.d.ts.map +1 -1
- package/dist/commands/test-gates.js +3620 -187
- package/dist/commands/test-gates.js.map +1 -1
- package/dist/commands/tests.d.ts +1 -1
- package/dist/commands/tests.d.ts.map +1 -1
- package/dist/commands/tests.js +264 -29
- package/dist/commands/tests.js.map +1 -1
- package/dist/docs-exclusions.d.ts.map +1 -1
- package/dist/docs-exclusions.js +18 -3
- package/dist/docs-exclusions.js.map +1 -1
- package/dist/endpoint-compiler.d.ts.map +1 -1
- package/dist/endpoint-compiler.js +78 -9
- package/dist/endpoint-compiler.js.map +1 -1
- package/dist/engine-browser.d.ts +183 -0
- package/dist/engine-browser.d.ts.map +1 -0
- package/dist/engine-browser.js +381 -0
- package/dist/engine-browser.js.map +1 -0
- package/dist/engine-identity.d.ts +100 -0
- package/dist/engine-identity.d.ts.map +1 -0
- package/dist/engine-identity.js +182 -0
- package/dist/engine-identity.js.map +1 -0
- package/dist/evaluate.d.ts +105 -1
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +149 -18
- package/dist/evaluate.js.map +1 -1
- package/dist/execution.d.ts +253 -9
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +309 -12
- package/dist/execution.js.map +1 -1
- package/dist/gateforge-owned.d.ts +78 -0
- package/dist/gateforge-owned.d.ts.map +1 -0
- package/dist/gateforge-owned.js +254 -0
- package/dist/gateforge-owned.js.map +1 -0
- package/dist/git-hooks.d.ts +35 -0
- package/dist/git-hooks.d.ts.map +1 -1
- package/dist/git-hooks.js +140 -1
- package/dist/git-hooks.js.map +1 -1
- package/dist/git-ignored.d.ts +27 -0
- package/dist/git-ignored.d.ts.map +1 -0
- package/dist/git-ignored.js +102 -0
- package/dist/git-ignored.js.map +1 -0
- package/dist/git-objects.d.ts +60 -0
- package/dist/git-objects.d.ts.map +1 -0
- package/dist/git-objects.js +152 -0
- package/dist/git-objects.js.map +1 -0
- package/dist/glob.d.ts +33 -14
- package/dist/glob.d.ts.map +1 -1
- package/dist/glob.js +96 -5
- package/dist/glob.js.map +1 -1
- package/dist/history.d.ts +52 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +116 -0
- package/dist/history.js.map +1 -0
- package/dist/host-load.d.ts +49 -0
- package/dist/host-load.d.ts.map +1 -0
- package/dist/host-load.js +78 -0
- package/dist/host-load.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/input-snapshot.d.ts +63 -9
- package/dist/input-snapshot.d.ts.map +1 -1
- package/dist/input-snapshot.js +195 -17
- package/dist/input-snapshot.js.map +1 -1
- package/dist/io.d.ts +49 -0
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +22 -0
- package/dist/io.js.map +1 -1
- package/dist/mapping.d.ts +84 -1
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +276 -5
- package/dist/mapping.js.map +1 -1
- package/dist/native-freeze.d.ts +217 -0
- package/dist/native-freeze.d.ts.map +1 -0
- package/dist/native-freeze.js +332 -0
- package/dist/native-freeze.js.map +1 -0
- package/dist/pipeline.d.ts +67 -1
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +164 -6
- package/dist/pipeline.js.map +1 -1
- package/dist/planes-inference.d.ts +12 -5
- package/dist/planes-inference.d.ts.map +1 -1
- package/dist/planes-inference.js +13 -15
- package/dist/planes-inference.js.map +1 -1
- package/dist/playwright-browsers.d.ts +210 -0
- package/dist/playwright-browsers.d.ts.map +1 -0
- package/dist/playwright-browsers.js +364 -0
- package/dist/playwright-browsers.js.map +1 -0
- package/dist/plugins.d.ts +15 -5
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +59 -9
- package/dist/plugins.js.map +1 -1
- package/dist/progress.d.ts +148 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +263 -0
- package/dist/progress.js.map +1 -0
- package/dist/providers.d.ts +26 -1
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +39 -0
- package/dist/providers.js.map +1 -1
- package/dist/receipts.d.ts +1 -0
- package/dist/receipts.d.ts.map +1 -1
- package/dist/receipts.js +35 -7
- package/dist/receipts.js.map +1 -1
- package/dist/repo-scan.d.ts +15 -1
- package/dist/repo-scan.d.ts.map +1 -1
- package/dist/repo-scan.js +329 -34
- package/dist/repo-scan.js.map +1 -1
- package/dist/reseal-chain.d.ts +184 -0
- package/dist/reseal-chain.d.ts.map +1 -0
- package/dist/reseal-chain.js +735 -0
- package/dist/reseal-chain.js.map +1 -0
- package/dist/reseal-evidence.d.ts +241 -0
- package/dist/reseal-evidence.d.ts.map +1 -0
- package/dist/reseal-evidence.js +319 -0
- package/dist/reseal-evidence.js.map +1 -0
- package/dist/reseal.d.ts +181 -0
- package/dist/reseal.d.ts.map +1 -0
- package/dist/reseal.js +1620 -0
- package/dist/reseal.js.map +1 -0
- package/dist/response-field-guidance.d.ts +82 -0
- package/dist/response-field-guidance.d.ts.map +1 -0
- package/dist/response-field-guidance.js +184 -0
- package/dist/response-field-guidance.js.map +1 -0
- package/dist/route-plane-proposals.d.ts +100 -0
- package/dist/route-plane-proposals.d.ts.map +1 -0
- package/dist/route-plane-proposals.js +213 -0
- package/dist/route-plane-proposals.js.map +1 -0
- package/dist/run-cache.d.ts +260 -0
- package/dist/run-cache.d.ts.map +1 -0
- package/dist/run-cache.js +771 -0
- package/dist/run-cache.js.map +1 -0
- package/dist/run-preflight.d.ts +77 -0
- package/dist/run-preflight.d.ts.map +1 -0
- package/dist/run-preflight.js +774 -0
- package/dist/run-preflight.js.map +1 -0
- package/dist/run-recipe.d.ts +107 -0
- package/dist/run-recipe.d.ts.map +1 -0
- package/dist/run-recipe.js +295 -0
- package/dist/run-recipe.js.map +1 -0
- package/dist/run-reliability.d.ts +126 -0
- package/dist/run-reliability.d.ts.map +1 -0
- package/dist/run-reliability.js +221 -0
- package/dist/run-reliability.js.map +1 -0
- package/dist/runtime.d.ts +15 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +11 -1
- package/dist/runtime.js.map +1 -1
- package/dist/scope.d.ts +20 -0
- package/dist/scope.d.ts.map +1 -1
- package/dist/scope.js +26 -5
- package/dist/scope.js.map +1 -1
- package/dist/secret-guard.d.ts +36 -0
- package/dist/secret-guard.d.ts.map +1 -0
- package/dist/secret-guard.js +63 -0
- package/dist/secret-guard.js.map +1 -0
- package/dist/singleton-guidance.d.ts +82 -0
- package/dist/singleton-guidance.d.ts.map +1 -0
- package/dist/singleton-guidance.js +138 -0
- package/dist/singleton-guidance.js.map +1 -0
- package/dist/staged-candidate.d.ts +17 -0
- package/dist/staged-candidate.d.ts.map +1 -1
- package/dist/staged-candidate.js +50 -0
- package/dist/staged-candidate.js.map +1 -1
- package/dist/state-artifacts.d.ts +70 -0
- package/dist/state-artifacts.d.ts.map +1 -0
- package/dist/state-artifacts.js +215 -0
- package/dist/state-artifacts.js.map +1 -0
- package/dist/state.d.ts +170 -2
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +248 -8
- package/dist/state.js.map +1 -1
- package/dist/unmatched-routes.d.ts +60 -0
- package/dist/unmatched-routes.d.ts.map +1 -0
- package/dist/unmatched-routes.js +131 -0
- package/dist/unmatched-routes.js.map +1 -0
- package/dist/verifier-keys.d.ts +33 -2
- package/dist/verifier-keys.d.ts.map +1 -1
- package/dist/verifier-keys.js +95 -9
- package/dist/verifier-keys.js.map +1 -1
- package/guides/CONNECT-YOUR-PROJECT.md +425 -0
- package/guides/QUICKSTART.md +306 -26
- package/guides/REFERENCE.md +1710 -0
- package/guides/RUNNER-NEUTRAL-EVIDENCE.md +199 -0
- package/guides/TEST-ENVIRONMENT.md +1044 -6
- package/guides/UPGRADE-0.6-to-0.7.md +3 -3
- package/guides/UPGRADE-0.7-to-0.8.md +114 -0
- package/guides/UPGRADE-0.8-to-0.9.md +104 -0
- package/package.json +10 -9
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route-folder plane PROPOSALS for `gateforge init` (problem 13, owner
|
|
3
|
+
* decision D1 = ask, never infer).
|
|
4
|
+
*
|
|
5
|
+
* A fresh init on an existing repository leaves every discovered endpoint
|
|
6
|
+
* without a plane, and one owner answer per ROUTE FOLDER is the smallest
|
|
7
|
+
* honest answer — an `accounts` route can serve master data even when the
|
|
8
|
+
* `accounts` model is tenant-scoped, so a route folder is never classified
|
|
9
|
+
* from the model it happens to link to.
|
|
10
|
+
*
|
|
11
|
+
* What this module does:
|
|
12
|
+
* - `collectRoutePlaneFacts` runs the repository's own discovery (the
|
|
13
|
+
* configured plugins plus the endpoint compiler) and reduces every
|
|
14
|
+
* compiled endpoint to the four facts a folder question needs. It
|
|
15
|
+
* THROWS when discovery fails — the caller decides how to warn; a
|
|
16
|
+
* silent empty list would read as "nothing to ask" and hide the run.
|
|
17
|
+
* - `proposeRouteFolderPlanes` groups the plane-unresolved endpoints by the
|
|
18
|
+
* directory of their SERVER ROUTE file and returns one proposal per
|
|
19
|
+
* folder. It is PURE: it writes nothing, applies nothing, and the hint
|
|
20
|
+
* it carries is display-only evidence, never an answer.
|
|
21
|
+
*
|
|
22
|
+
* The hint is deliberately narrow: it is the plane of the linked models,
|
|
23
|
+
* and it is withheld unless every linked model behind that folder's routes
|
|
24
|
+
* has the SAME resolved plane. A route linked to an unresolved model, or
|
|
25
|
+
* to two models on different planes, gets `hintPlane: null` — an owner
|
|
26
|
+
* question with no hint is still answerable, and a wrong hint is not.
|
|
27
|
+
*/
|
|
28
|
+
import { compareStrings, loadConfig } from '@gate-forge/core';
|
|
29
|
+
import { isTestSourcePath } from '@gate-forge/pack-sqlalchemy';
|
|
30
|
+
import { compileEndpointContribution } from './endpoint-compiler.js';
|
|
31
|
+
import { expandScanPaths } from './glob.js';
|
|
32
|
+
import { runPlugins } from './plugins.js';
|
|
33
|
+
import { gitIgnoredPaths } from './git-ignored.js';
|
|
34
|
+
import { HTTP_ENDPOINT_RESOURCE_KIND } from '@gate-forge/core';
|
|
35
|
+
/** The plane values a fact can carry (never inferred, only read). */
|
|
36
|
+
const PLANES = ['tenant', 'master', 'global'];
|
|
37
|
+
/** The plane of a resource's `plane` attribute, or null. */
|
|
38
|
+
function planeOf(attributes) {
|
|
39
|
+
const plane = attributes['plane'];
|
|
40
|
+
return PLANES.find((candidate) => candidate === plane) ?? null;
|
|
41
|
+
}
|
|
42
|
+
/** The directory of a repo-relative source path ('' at the repository root). */
|
|
43
|
+
function directoryOf(source) {
|
|
44
|
+
const index = source.lastIndexOf('/');
|
|
45
|
+
return index === -1 ? '' : source.slice(0, index);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The single plane every named business resource agrees on, or null when
|
|
49
|
+
* they disagree, are missing, or resolve to nothing. Endpoint resources are
|
|
50
|
+
* never consulted — a route never inherits a plane from another route.
|
|
51
|
+
*/
|
|
52
|
+
function agreedBusinessPlane(name, business) {
|
|
53
|
+
const planes = business.get(name);
|
|
54
|
+
if (planes === undefined || planes.size !== 1)
|
|
55
|
+
return null;
|
|
56
|
+
const [only] = [...planes];
|
|
57
|
+
return only ?? null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Runs the repository's discovery and reduces it to route-plane facts.
|
|
61
|
+
*
|
|
62
|
+
* Args:
|
|
63
|
+
* cwd: Repository root (the `.gateforge.yml` location).
|
|
64
|
+
*
|
|
65
|
+
* Returns:
|
|
66
|
+
* Promise<RoutePlaneFact[]>: one fact per compiled endpoint, sorted by
|
|
67
|
+
* source path then identity. Empty when no endpoint was compiled.
|
|
68
|
+
*
|
|
69
|
+
* Raises:
|
|
70
|
+
* Error: propagates whatever discovery raises (unreadable config, a
|
|
71
|
+
* failing plugin, a malformed planes document). The caller surfaces
|
|
72
|
+
* it — a proposal pass must never look like "nothing to ask".
|
|
73
|
+
*
|
|
74
|
+
* The DETECTOR-INPUT scope is the SCAN scope (owner decision D5), not
|
|
75
|
+
* the identity walk: a gitignored, untracked tree (a built report
|
|
76
|
+
* bundle, a local cache) holds no route the owner would ever be asked
|
|
77
|
+
* about, and every other detector-input caller in `init` and in the
|
|
78
|
+
* pipeline enumerates the same list. Outside a git work tree the
|
|
79
|
+
* scope reports `known: false` and skips nothing, so behaviour there
|
|
80
|
+
* is unchanged.
|
|
81
|
+
*/
|
|
82
|
+
export async function collectRoutePlaneFacts(cwd) {
|
|
83
|
+
const config = loadConfig(`${cwd}/.gateforge.yml`);
|
|
84
|
+
const paths = expandScanPaths(config.project.paths.include, config.project.paths.exclude, cwd, gitIgnoredPaths(cwd));
|
|
85
|
+
const { contributions } = await runPlugins(config.plugins, paths, cwd);
|
|
86
|
+
return routePlaneFactsOf(contributions, cwd);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Reduces detector contributions to route-plane facts. Pure over its
|
|
90
|
+
* inputs apart from reading `cwd` for the declarative planes document.
|
|
91
|
+
*
|
|
92
|
+
* @param contributions - Every configured plugin's discovery output.
|
|
93
|
+
* @param cwd - Repository root the planes document is read from.
|
|
94
|
+
* @returns One fact per compiled endpoint, sorted and deduplicated.
|
|
95
|
+
*/
|
|
96
|
+
export function routePlaneFactsOf(contributions, cwd) {
|
|
97
|
+
// Plane evidence per BUSINESS resource name (endpoints excluded): the
|
|
98
|
+
// same view the endpoint compiler and the classifier both read.
|
|
99
|
+
const business = new Map();
|
|
100
|
+
for (const contribution of contributions) {
|
|
101
|
+
for (const resource of contribution.resources) {
|
|
102
|
+
if (resource.kind === HTTP_ENDPOINT_RESOURCE_KIND)
|
|
103
|
+
continue;
|
|
104
|
+
const name = resource.attributes['resourceName'];
|
|
105
|
+
if (typeof name !== 'string' || name.length === 0)
|
|
106
|
+
continue;
|
|
107
|
+
const plane = planeOf(resource.attributes);
|
|
108
|
+
if (plane === null)
|
|
109
|
+
continue;
|
|
110
|
+
const planes = business.get(name);
|
|
111
|
+
if (planes === undefined)
|
|
112
|
+
business.set(name, new Set([plane]));
|
|
113
|
+
else
|
|
114
|
+
planes.add(plane);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const compiled = compileEndpointContribution(contributions, { cwd });
|
|
118
|
+
// Every plane assertion the compiler minted, keyed by endpoint name. A
|
|
119
|
+
// name with disagreeing assertions resolves to nothing.
|
|
120
|
+
const asserted = new Map();
|
|
121
|
+
for (const signal of compiled.contribution.classificationSignals) {
|
|
122
|
+
if (signal.dimension !== 'plane')
|
|
123
|
+
continue;
|
|
124
|
+
const name = signal.target.resourceName;
|
|
125
|
+
if (name === undefined)
|
|
126
|
+
continue;
|
|
127
|
+
if (typeof signal.assertion !== 'string')
|
|
128
|
+
continue;
|
|
129
|
+
const plane = PLANES.find((candidate) => candidate === signal.assertion);
|
|
130
|
+
if (plane === undefined)
|
|
131
|
+
continue;
|
|
132
|
+
const planes = asserted.get(name);
|
|
133
|
+
if (planes === undefined)
|
|
134
|
+
asserted.set(name, new Set([plane]));
|
|
135
|
+
else
|
|
136
|
+
planes.add(plane);
|
|
137
|
+
}
|
|
138
|
+
const facts = [];
|
|
139
|
+
for (const endpoint of compiled.inventory.endpoints) {
|
|
140
|
+
const source = endpoint.routes[0]?.source.file ?? '';
|
|
141
|
+
if (source.length === 0 || source === '<unknown>' || isTestSourcePath(source))
|
|
142
|
+
continue;
|
|
143
|
+
const planes = asserted.get(endpoint.resourceName);
|
|
144
|
+
const linked = endpoint.linkedResourceName;
|
|
145
|
+
facts.push({
|
|
146
|
+
source,
|
|
147
|
+
plane: planes !== undefined && planes.size === 1 ? ([...planes][0] ?? null) : null,
|
|
148
|
+
linkedResourceName: linked,
|
|
149
|
+
linkedModelPlane: linked === null ? null : agreedBusinessPlane(linked, business),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
facts.sort((left, right) => compareStrings(left.source, right.source) || compareStrings(left.plane ?? '', right.plane ?? ''));
|
|
153
|
+
return facts;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Groups plane-unresolved endpoints into one proposal per route folder.
|
|
157
|
+
*
|
|
158
|
+
* Pure: no filesystem, no clock, no writes. The caller owns consent and
|
|
159
|
+
* the write (init asks the owner, then writes one `match: '<folder>/**'`
|
|
160
|
+
* rule per answered folder).
|
|
161
|
+
*
|
|
162
|
+
* @param facts - Route-plane facts from {@link collectRoutePlaneFacts}.
|
|
163
|
+
* @returns One proposal per folder holding unresolved routes, sorted by
|
|
164
|
+
* folder; `[]` when there is nothing to ask.
|
|
165
|
+
*/
|
|
166
|
+
export function proposeRouteFolderPlanes(facts) {
|
|
167
|
+
const folders = new Map();
|
|
168
|
+
for (const fact of facts) {
|
|
169
|
+
// An endpoint that already HAS a plane is answered; never re-ask.
|
|
170
|
+
if (fact.plane !== null)
|
|
171
|
+
continue;
|
|
172
|
+
const folder = directoryOf(fact.source);
|
|
173
|
+
// A route declared at the repository root has no folder to target, and
|
|
174
|
+
// a folder rule would sweep in unrelated files. It stays a per-file
|
|
175
|
+
// `classify plane <file>` answer.
|
|
176
|
+
if (folder.length === 0)
|
|
177
|
+
continue;
|
|
178
|
+
const entry = folders.get(folder);
|
|
179
|
+
if (entry === undefined) {
|
|
180
|
+
folders.set(folder, {
|
|
181
|
+
count: 1,
|
|
182
|
+
models: new Map(fact.linkedResourceName === null
|
|
183
|
+
? []
|
|
184
|
+
: [[fact.linkedResourceName, fact.linkedModelPlane]]),
|
|
185
|
+
});
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
entry.count += 1;
|
|
189
|
+
if (fact.linkedResourceName !== null) {
|
|
190
|
+
entry.models.set(fact.linkedResourceName, fact.linkedModelPlane);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return [...folders.keys()]
|
|
194
|
+
.sort(compareStrings)
|
|
195
|
+
.map((folder) => {
|
|
196
|
+
const entry = folders.get(folder);
|
|
197
|
+
const models = entry?.models ?? new Map();
|
|
198
|
+
const planes = new Set([...models.values()].filter((plane) => plane !== null));
|
|
199
|
+
// The hint is shown only when every linked model behind this folder
|
|
200
|
+
// agrees on ONE resolved plane. No links, an unresolved link, or two
|
|
201
|
+
// planes mean no hint at all — the owner answers from the routes.
|
|
202
|
+
const hintPlane = models.size > 0 && planes.size === 1 && [...models.values()].every((plane) => plane !== null)
|
|
203
|
+
? ([...planes][0] ?? null)
|
|
204
|
+
: null;
|
|
205
|
+
return {
|
|
206
|
+
folder,
|
|
207
|
+
routeCount: entry?.count ?? 0,
|
|
208
|
+
hintPlane,
|
|
209
|
+
linkedModels: [...models.keys()].sort(compareStrings),
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=route-plane-proposals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-plane-proposals.js","sourceRoot":"","sources":["../src/route-plane-proposals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAuB,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAwB,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OA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;YAC1B,CAAC,CAAC,IAAI,CAAC;QACX,OAAO;YACL,MAAM;YACN,UAAU,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;YAC7B,SAAS;YACT,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC;SACtD,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { type DetectorOutput } from '@gate-forge/core';
|
|
2
|
+
/** Cache entry format version; a mismatch is a miss (never a parse of foreign bytes). */
|
|
3
|
+
export declare const PLUGIN_CACHE_FORMAT_VERSION = 1;
|
|
4
|
+
/** Domain tag keeping plugin-cache keys separate from every other digest. */
|
|
5
|
+
export declare const PLUGIN_CACHE_DOMAIN = "gateforge.plugin-cache.v1";
|
|
6
|
+
/** Directory under the run-state dir holding plugin cache entries. */
|
|
7
|
+
export declare const PLUGIN_CACHE_DIR = "cache/plugin";
|
|
8
|
+
/** Directory under the run-state dir holding pytest collection entries. */
|
|
9
|
+
export declare const PYTEST_CACHE_DIR = "cache/pytest";
|
|
10
|
+
/** Where the cache lives and whether it may be used at all. */
|
|
11
|
+
export interface CacheControl {
|
|
12
|
+
/** Absolute run-state directory (excluded from the input snapshot). */
|
|
13
|
+
stateDir: string;
|
|
14
|
+
/** True forces a full scan: no cache reads and no cache writes. */
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Hit/miss accounting for one run's cache use (additive report key). */
|
|
18
|
+
export interface CacheCounts {
|
|
19
|
+
hits: number;
|
|
20
|
+
misses: number;
|
|
21
|
+
}
|
|
22
|
+
/** Identity of the interpreter a plugin's result depends on. */
|
|
23
|
+
export interface InterpreterIdentity {
|
|
24
|
+
/** Absolute interpreter path as resolved for this run. */
|
|
25
|
+
path: string;
|
|
26
|
+
/** Interpreter version string (python `sys.version`). */
|
|
27
|
+
version: string;
|
|
28
|
+
/** Digest over the sorted site-packages entries (name, mtime, size). */
|
|
29
|
+
packagesDigest: string;
|
|
30
|
+
/** Digest of the entry script bytes when argv[0] is a python entry script (e.g. a venv `pytest`). */
|
|
31
|
+
entryScriptDigest?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Everything one plugin's cached result depends on. */
|
|
34
|
+
export interface PluginCacheIdentity {
|
|
35
|
+
/** Plugin id/version/config and Gateforge engine version. */
|
|
36
|
+
plugin: {
|
|
37
|
+
id: string;
|
|
38
|
+
version: string;
|
|
39
|
+
transport: string;
|
|
40
|
+
command?: readonly string[];
|
|
41
|
+
module?: string;
|
|
42
|
+
};
|
|
43
|
+
/** Gateforge engine version, invalidating cache on engine upgrades. */
|
|
44
|
+
engineVersion: string;
|
|
45
|
+
/** Import-resolution environment inherited by Python children. */
|
|
46
|
+
pythonEnvironment: Pick<NodeJS.ProcessEnv, 'PYTHONPATH' | 'PYTHONHOME' | 'VIRTUAL_ENV'>;
|
|
47
|
+
/** Digest of plugin source bytes (file or package tree); null = uncacheable. */
|
|
48
|
+
moduleBytesDigest: string | null;
|
|
49
|
+
/** Digest over the sorted scanned input bytes; null = uncacheable. */
|
|
50
|
+
inputsDigest: string | null;
|
|
51
|
+
/**
|
|
52
|
+
* Interpreter identity; null = uncacheable (probe failed). Subprocess
|
|
53
|
+
* plugins carry their own interpreter; in-process plugins carry the
|
|
54
|
+
* running Node plus the machine's python3 (`'absent'` is itself stable
|
|
55
|
+
* key material — python appearing later changes the key).
|
|
56
|
+
*/
|
|
57
|
+
interpreter: InterpreterIdentity | {
|
|
58
|
+
node: InterpreterIdentity;
|
|
59
|
+
python: InterpreterIdentity | 'absent';
|
|
60
|
+
} | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Resolves the cache control for one gate run.
|
|
64
|
+
*
|
|
65
|
+
* Args:
|
|
66
|
+
* env: process environment (kill switches and CI detection).
|
|
67
|
+
* stateDir: absolute run-state directory for cache storage.
|
|
68
|
+
* noCacheFlag: `--no-cache` presence.
|
|
69
|
+
*
|
|
70
|
+
* Returns:
|
|
71
|
+
* CacheControl: disabled when `--no-cache`, `GATEFORGE_NO_CACHE` is set,
|
|
72
|
+
* or a recognized CI-provider marker is present.
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveCacheControl(env: NodeJS.ProcessEnv, stateDir: string, noCacheFlag: boolean): CacheControl;
|
|
75
|
+
/**
|
|
76
|
+
* Probes one python-style interpreter for cache identity: absolute path,
|
|
77
|
+
* `sys.version`, and a site-packages (purelib) digest. Any failure returns
|
|
78
|
+
* null — the caller must then run the work uncached (fail closed).
|
|
79
|
+
*
|
|
80
|
+
* Args:
|
|
81
|
+
* interpreter: the configured interpreter command (e.g. `python3`).
|
|
82
|
+
* env: process environment for PATH resolution and the probe child.
|
|
83
|
+
*
|
|
84
|
+
* Returns:
|
|
85
|
+
* InterpreterIdentity | null: identity, or null when the interpreter
|
|
86
|
+
* cannot be probed as python.
|
|
87
|
+
*/
|
|
88
|
+
export declare function interpreterIdentity(interpreter: string, env: NodeJS.ProcessEnv): InterpreterIdentity | null;
|
|
89
|
+
/**
|
|
90
|
+
* Digests the plugin input bytes: every expanded scan path with its
|
|
91
|
+
* content, sorted by path (order-insensitive like the detectors' view).
|
|
92
|
+
*
|
|
93
|
+
* Args:
|
|
94
|
+
* cwd: repo root the relative paths resolve against.
|
|
95
|
+
* paths: repo-relative scanned paths handed to every plugin.
|
|
96
|
+
*
|
|
97
|
+
* Returns:
|
|
98
|
+
* string | null: hex digest, or null when any input is unreadable.
|
|
99
|
+
*/
|
|
100
|
+
export declare function digestPathListInputs(cwd: string, paths: readonly string[]): string | null;
|
|
101
|
+
/**
|
|
102
|
+
* Builds the full cache identity for one plugin run, or null when ANY
|
|
103
|
+
* component cannot be established (then the plugin must run fresh).
|
|
104
|
+
*
|
|
105
|
+
* Args:
|
|
106
|
+
* plugin: the configured plugin (id/version/transport/command/module).
|
|
107
|
+
* inputsDigest: precomputed digest of the expanded scan path bytes.
|
|
108
|
+
* cwd: repo root (module resolution).
|
|
109
|
+
* env: process environment for interpreter resolution.
|
|
110
|
+
*
|
|
111
|
+
* Returns:
|
|
112
|
+
* PluginCacheIdentity | null: identity, or null when uncacheable.
|
|
113
|
+
*/
|
|
114
|
+
export declare function pluginCacheIdentity(plugin: {
|
|
115
|
+
id: string;
|
|
116
|
+
version: string;
|
|
117
|
+
transport: string;
|
|
118
|
+
command?: readonly string[];
|
|
119
|
+
module?: string;
|
|
120
|
+
}, inputsDigest: string, cwd: string, env: NodeJS.ProcessEnv, engineVersion?: string): PluginCacheIdentity | null;
|
|
121
|
+
/**
|
|
122
|
+
* Looks up one plugin's cached discovery result. Null means "run fresh"
|
|
123
|
+
* — either the identity is uncacheable or any validation step doubted.
|
|
124
|
+
*
|
|
125
|
+
* Args:
|
|
126
|
+
* stateDir: absolute run-state directory.
|
|
127
|
+
* plugin: the configured plugin.
|
|
128
|
+
* inputsDigest: digest of the expanded scan path bytes.
|
|
129
|
+
* cwd: repo root.
|
|
130
|
+
* env: process environment for interpreter resolution.
|
|
131
|
+
*
|
|
132
|
+
* Returns:
|
|
133
|
+
* DetectorOutput | null: the cached validated output, or null.
|
|
134
|
+
*/
|
|
135
|
+
export declare function lookupPluginCache(stateDir: string, plugin: {
|
|
136
|
+
id: string;
|
|
137
|
+
version: string;
|
|
138
|
+
transport: string;
|
|
139
|
+
command?: readonly string[];
|
|
140
|
+
module?: string;
|
|
141
|
+
}, inputsDigest: string, cwd: string, env: NodeJS.ProcessEnv): DetectorOutput | null;
|
|
142
|
+
/**
|
|
143
|
+
* Stores one fresh plugin result under its content key. Uncacheable
|
|
144
|
+
* identities skip silently — the result was already computed, and
|
|
145
|
+
* skipping storage only costs a future miss.
|
|
146
|
+
*
|
|
147
|
+
* Args:
|
|
148
|
+
* stateDir: absolute run-state directory.
|
|
149
|
+
* plugin: the configured plugin.
|
|
150
|
+
* inputsDigest: digest of the expanded scan path bytes.
|
|
151
|
+
* cwd: repo root.
|
|
152
|
+
* env: process environment for interpreter resolution.
|
|
153
|
+
* result: the validated discovery output.
|
|
154
|
+
*
|
|
155
|
+
* Returns:
|
|
156
|
+
* void.
|
|
157
|
+
*/
|
|
158
|
+
export declare function storePluginResult(stateDir: string, plugin: {
|
|
159
|
+
id: string;
|
|
160
|
+
version: string;
|
|
161
|
+
transport: string;
|
|
162
|
+
command?: readonly string[];
|
|
163
|
+
module?: string;
|
|
164
|
+
}, inputsDigest: string, cwd: string, env: NodeJS.ProcessEnv, result: DetectorOutput): void;
|
|
165
|
+
/**
|
|
166
|
+
* Computes the cache key for one plugin identity (domain-separated,
|
|
167
|
+
* canonical JSON so key order never matters).
|
|
168
|
+
*
|
|
169
|
+
* Args:
|
|
170
|
+
* identity: the plugin cache identity.
|
|
171
|
+
*
|
|
172
|
+
* Returns:
|
|
173
|
+
* string: 64-char lowercase hex cache key.
|
|
174
|
+
*/
|
|
175
|
+
export declare function pluginCacheKey(identity: PluginCacheIdentity): string;
|
|
176
|
+
/**
|
|
177
|
+
* Reads one plugin cache entry, validating format, key, and the pinned
|
|
178
|
+
* discovery shape. ANY doubt (missing file, corrupt JSON, foreign key,
|
|
179
|
+
* schema drift) is a miss — never a guess.
|
|
180
|
+
*
|
|
181
|
+
* Args:
|
|
182
|
+
* stateDir: absolute run-state directory.
|
|
183
|
+
* key: the computed cache key.
|
|
184
|
+
*
|
|
185
|
+
* Returns:
|
|
186
|
+
* DetectorOutput | null: the cached validated output, or null on any doubt.
|
|
187
|
+
*/
|
|
188
|
+
export declare function readPluginCache(stateDir: string, key: string): DetectorOutput | null;
|
|
189
|
+
/**
|
|
190
|
+
* Persists one validated plugin result under its key (atomic tmp+rename,
|
|
191
|
+
* so a concurrent reader never sees a partial document).
|
|
192
|
+
*
|
|
193
|
+
* Args:
|
|
194
|
+
* stateDir: absolute run-state directory (cache lives inside, excluded).
|
|
195
|
+
* key: the computed cache key.
|
|
196
|
+
* result: the validated discovery output to store.
|
|
197
|
+
*
|
|
198
|
+
* Returns:
|
|
199
|
+
* void.
|
|
200
|
+
*/
|
|
201
|
+
export declare function writePluginCache(stateDir: string, key: string, result: DetectorOutput): void;
|
|
202
|
+
/**
|
|
203
|
+
* Computes the pytest collection cache key for one suite (Phase 3 domain).
|
|
204
|
+
*
|
|
205
|
+
* Args:
|
|
206
|
+
* suite: configured suite and the exact collector argv.
|
|
207
|
+
* pythonFilesDigest: digest over all Python and pytest configuration bytes.
|
|
208
|
+
* interpreter: collector interpreter identity (null = uncacheable).
|
|
209
|
+
* environmentDigest: digest over the collector's effective environment.
|
|
210
|
+
*
|
|
211
|
+
* Returns:
|
|
212
|
+
* string: 64-character lowercase hexadecimal cache key.
|
|
213
|
+
*/
|
|
214
|
+
export declare function pytestCacheKey(suite: {
|
|
215
|
+
name: string;
|
|
216
|
+
cwd: string;
|
|
217
|
+
argv: readonly string[];
|
|
218
|
+
collectorArgv: readonly string[];
|
|
219
|
+
testPaths: readonly string[];
|
|
220
|
+
timeoutMs: number;
|
|
221
|
+
}, pythonFilesDigest: string, interpreter: InterpreterIdentity, environmentDigest: string, engineVersion?: string): string;
|
|
222
|
+
/** Absolute pytest cache entry path for one key. */
|
|
223
|
+
export declare function pytestCachePath(stateDir: string, key: string): string;
|
|
224
|
+
/**
|
|
225
|
+
* Reads a persisted pytest collection document (nodes + summary pieces).
|
|
226
|
+
* Validates the domain envelope; any doubt is a miss.
|
|
227
|
+
*
|
|
228
|
+
* Args:
|
|
229
|
+
* stateDir: absolute run-state directory.
|
|
230
|
+
* key: the computed pytest cache key.
|
|
231
|
+
*
|
|
232
|
+
* Returns:
|
|
233
|
+
* unknown | null: the stored document, or null on any doubt.
|
|
234
|
+
*/
|
|
235
|
+
export declare function readPytestCache(stateDir: string, key: string): unknown | null;
|
|
236
|
+
/**
|
|
237
|
+
* Persists one pytest collection document under its key (atomic rename).
|
|
238
|
+
*
|
|
239
|
+
* Args:
|
|
240
|
+
* stateDir: absolute run-state directory.
|
|
241
|
+
* key: the computed pytest cache key.
|
|
242
|
+
* result: the collection document to store.
|
|
243
|
+
*
|
|
244
|
+
* Returns:
|
|
245
|
+
* void.
|
|
246
|
+
*/
|
|
247
|
+
export declare function writePytestCache(stateDir: string, key: string, result: unknown): void;
|
|
248
|
+
/**
|
|
249
|
+
* Digests Python and pytest-config files from Git's tracked and nonignored
|
|
250
|
+
* untracked inventory, excluding run-state directories.
|
|
251
|
+
*
|
|
252
|
+
* Args:
|
|
253
|
+
* cwd: absolute repository root.
|
|
254
|
+
* stateDirs: absolute run-state directories to exclude.
|
|
255
|
+
*
|
|
256
|
+
* Returns:
|
|
257
|
+
* string | null: digest, or null when inventory or an input is unreadable.
|
|
258
|
+
*/
|
|
259
|
+
export declare function digestPytestInputs(cwd: string, ...stateDirs: string[]): string | null;
|
|
260
|
+
//# sourceMappingURL=run-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-cache.d.ts","sourceRoot":"","sources":["../src/run-cache.ts"],"names":[],"mappings":"AAkCA,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,kBAAkB,CAAC;AAG1B,yFAAyF;AACzF,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAE/D,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAgB/C,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IAC3B,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,yEAAyE;AACzE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,gEAAgE;AAChE,MAAM,WAAW,mBAAmB;IAClC,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,OA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