@gate-forge/cli 0.8.0 → 0.9.1
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 +85 -1145
- package/dist/adapter-audit.d.ts +54 -0
- package/dist/adapter-audit.d.ts.map +1 -1
- package/dist/adapter-audit.js +48 -0
- package/dist/adapter-audit.js.map +1 -1
- package/dist/adapter-scaffold.d.ts +28 -3
- package/dist/adapter-scaffold.d.ts.map +1 -1
- package/dist/adapter-scaffold.js +145 -24
- package/dist/adapter-scaffold.js.map +1 -1
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +2 -0
- package/dist/args.js.map +1 -1
- package/dist/behavior-setup.d.ts.map +1 -1
- package/dist/behavior-setup.js +18 -5
- package/dist/behavior-setup.js.map +1 -1
- package/dist/commands/adapters.d.ts.map +1 -1
- package/dist/commands/adapters.js +73 -2
- package/dist/commands/adapters.js.map +1 -1
- package/dist/commands/adopt.d.ts +9 -1
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +72 -5
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/blocking.d.ts +45 -2
- package/dist/commands/blocking.d.ts.map +1 -1
- package/dist/commands/blocking.js +165 -11
- package/dist/commands/blocking.js.map +1 -1
- package/dist/commands/check.d.ts +34 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +152 -8
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/classify.d.ts +1 -1
- package/dist/commands/classify.d.ts.map +1 -1
- package/dist/commands/classify.js +63 -18
- package/dist/commands/classify.js.map +1 -1
- package/dist/commands/enforcement.d.ts.map +1 -1
- package/dist/commands/enforcement.js +263 -9
- 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/init-presets.d.ts +7 -0
- package/dist/commands/init-presets.d.ts.map +1 -1
- package/dist/commands/init-presets.js +10 -1
- package/dist/commands/init-presets.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +579 -61
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/next.d.ts.map +1 -1
- package/dist/commands/next.js +109 -6
- package/dist/commands/next.js.map +1 -1
- package/dist/commands/pre-commit.d.ts.map +1 -1
- package/dist/commands/pre-commit.js +62 -19
- package/dist/commands/pre-commit.js.map +1 -1
- package/dist/commands/test-gates.js +1 -1
- package/dist/commands/tests.d.ts.map +1 -1
- package/dist/commands/tests.js +46 -7
- 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 +49 -1
- package/dist/endpoint-compiler.js.map +1 -1
- package/dist/evaluate.d.ts +16 -1
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +12 -2
- package/dist/evaluate.js.map +1 -1
- package/dist/gateforge-owned.d.ts +103 -0
- package/dist/gateforge-owned.d.ts.map +1 -0
- package/dist/gateforge-owned.js +375 -0
- package/dist/gateforge-owned.js.map +1 -0
- package/dist/git-hooks.d.ts +18 -0
- package/dist/git-hooks.d.ts.map +1 -1
- package/dist/git-hooks.js +36 -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/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/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/io.d.ts +18 -5
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +5 -4
- package/dist/io.js.map +1 -1
- package/dist/pipeline.d.ts +16 -1
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +23 -3
- 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/providers.d.ts +54 -0
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +101 -0
- package/dist/providers.js.map +1 -1
- package/dist/repo-scan.d.ts +7 -0
- package/dist/repo-scan.d.ts.map +1 -1
- package/dist/repo-scan.js +109 -8
- package/dist/repo-scan.js.map +1 -1
- 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/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/singleton-guidance.d.ts +15 -6
- package/dist/singleton-guidance.d.ts.map +1 -1
- package/dist/singleton-guidance.js +30 -10
- package/dist/singleton-guidance.js.map +1 -1
- package/dist/staged-candidate.d.ts.map +1 -1
- package/dist/staged-candidate.js +2 -1
- package/dist/staged-candidate.js.map +1 -1
- package/dist/trusted-policy.d.ts.map +1 -1
- package/dist/trusted-policy.js +3 -2
- package/dist/trusted-policy.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/guides/CONNECT-YOUR-PROJECT.md +93 -20
- package/guides/QUICKSTART.md +81 -16
- package/guides/REFERENCE.md +1756 -0
- package/guides/TEST-ENVIRONMENT.md +8 -5
- package/guides/UPGRADE-0.8-to-0.9.md +112 -0
- package/package.json +10 -10
|
@@ -0,0 +1,100 @@
|
|
|
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 { type DetectorOutput } from '@gate-forge/core';
|
|
29
|
+
import { type SqlalchemyPlane } from '@gate-forge/pack-sqlalchemy';
|
|
30
|
+
/** One compiled endpoint, reduced to what a folder question needs. */
|
|
31
|
+
export interface RoutePlaneFact {
|
|
32
|
+
/** Repo-relative source file of the SERVER ROUTE that declares it. */
|
|
33
|
+
readonly source: string;
|
|
34
|
+
/** Plane already resolved for the endpoint, or null when unresolved. */
|
|
35
|
+
readonly plane: SqlalchemyPlane | null;
|
|
36
|
+
/** Business model this endpoint is LINKED to, or null when unlinked. */
|
|
37
|
+
readonly linkedResourceName: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* The linked model's OWN resolved plane, or null when the model has
|
|
40
|
+
* none. This is the ONLY thing that may become a hint.
|
|
41
|
+
*/
|
|
42
|
+
readonly linkedModelPlane: SqlalchemyPlane | null;
|
|
43
|
+
}
|
|
44
|
+
/** One folder's plane question. Never an applied answer. */
|
|
45
|
+
export interface RouteFolderPlaneProposal {
|
|
46
|
+
/** Repo-relative directory the rule would target, e.g. 'backend/api/v1'. */
|
|
47
|
+
readonly folder: string;
|
|
48
|
+
/** How many plane-unresolved endpoints live in that folder. */
|
|
49
|
+
readonly routeCount: number;
|
|
50
|
+
/** HINT ONLY — never applied, never written by this module. */
|
|
51
|
+
readonly hintPlane: SqlalchemyPlane | null;
|
|
52
|
+
/** Linked model names behind the folder's routes (sorted). */
|
|
53
|
+
readonly linkedModels: readonly string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Runs the repository's discovery and reduces it to route-plane facts.
|
|
57
|
+
*
|
|
58
|
+
* Args:
|
|
59
|
+
* cwd: Repository root (the `.gateforge.yml` location).
|
|
60
|
+
*
|
|
61
|
+
* Returns:
|
|
62
|
+
* Promise<RoutePlaneFact[]>: one fact per compiled endpoint, sorted by
|
|
63
|
+
* source path then identity. Empty when no endpoint was compiled.
|
|
64
|
+
*
|
|
65
|
+
* Raises:
|
|
66
|
+
* Error: propagates whatever discovery raises (unreadable config, a
|
|
67
|
+
* failing plugin, a malformed planes document). The caller surfaces
|
|
68
|
+
* it — a proposal pass must never look like "nothing to ask".
|
|
69
|
+
*
|
|
70
|
+
* The DETECTOR-INPUT scope is the SCAN scope (owner decision D5), not
|
|
71
|
+
* the identity walk: a gitignored, untracked tree (a built report
|
|
72
|
+
* bundle, a local cache) holds no route the owner would ever be asked
|
|
73
|
+
* about, and every other detector-input caller in `init` and in the
|
|
74
|
+
* pipeline enumerates the same list. Outside a git work tree the
|
|
75
|
+
* scope reports `known: false` and skips nothing, so behaviour there
|
|
76
|
+
* is unchanged.
|
|
77
|
+
*/
|
|
78
|
+
export declare function collectRoutePlaneFacts(cwd: string): Promise<RoutePlaneFact[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Reduces detector contributions to route-plane facts. Pure over its
|
|
81
|
+
* inputs apart from reading `cwd` for the declarative planes document.
|
|
82
|
+
*
|
|
83
|
+
* @param contributions - Every configured plugin's discovery output.
|
|
84
|
+
* @param cwd - Repository root the planes document is read from.
|
|
85
|
+
* @returns One fact per compiled endpoint, sorted and deduplicated.
|
|
86
|
+
*/
|
|
87
|
+
export declare function routePlaneFactsOf(contributions: readonly DetectorOutput[], cwd: string): RoutePlaneFact[];
|
|
88
|
+
/**
|
|
89
|
+
* Groups plane-unresolved endpoints into one proposal per route folder.
|
|
90
|
+
*
|
|
91
|
+
* Pure: no filesystem, no clock, no writes. The caller owns consent and
|
|
92
|
+
* the write (init asks the owner, then writes one `match: '<folder>/**'`
|
|
93
|
+
* rule per answered folder).
|
|
94
|
+
*
|
|
95
|
+
* @param facts - Route-plane facts from {@link collectRoutePlaneFacts}.
|
|
96
|
+
* @returns One proposal per folder holding unresolved routes, sorted by
|
|
97
|
+
* folder; `[]` when there is nothing to ask.
|
|
98
|
+
*/
|
|
99
|
+
export declare function proposeRouteFolderPlanes(facts: readonly RoutePlaneFact[]): RouteFolderPlaneProposal[];
|
|
100
|
+
//# sourceMappingURL=route-plane-proposals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-plane-proposals.d.ts","sourceRoot":"","sources":["../src/route-plane-proposals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAA8B,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAUrF,sEAAsE;AACtE,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC,wEAAwE;IACxE,QAAQ,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,eAAe,GAAG,IAAI,CAAC;CACnD;AAED,4DAA4D;AAC5D,MAAM,WAAW,wBAAwB;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3C,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AA6BD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAUnF;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,SAAS,cAAc,EAAE,EACxC,GAAG,EAAE,MAAM,GACV,cAAc,EAAE,CAkDlB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,SAAS,cAAc,EAAE,GAC/B,wBAAwB,EAAE,CAoD5B"}
|
|
@@ -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,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D,qEAAqE;AACrE,MAAM,MAAM,GAA+B,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AA6B1E,4DAA4D;AAC5D,SAAS,OAAO,CAAC,UAA6C;IAC5D,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC;AACjE,CAAC;AAED,gFAAgF;AAChF,SAAS,WAAW,CAAC,MAAc;IACjC,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,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M,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,IAAI,IAAI,GAAG,EAAkC,CAAC;QAC1E,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC;QAC/E,oEAAoE;QACpE,qEAAqE;QACrE,kEAAkE;QAClE,MAAM,SAAS,GACb,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;YAC3F,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;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"}
|
package/dist/scope.d.ts
CHANGED
|
@@ -14,6 +14,20 @@ export interface ScopeDecision {
|
|
|
14
14
|
* non-strict mode (the historical contract is unchanged there).
|
|
15
15
|
*/
|
|
16
16
|
unmappedFiles: string[];
|
|
17
|
+
/**
|
|
18
|
+
* 0.9.0 D2: the Gateforge-owned policy inputs in the changed set (see
|
|
19
|
+
* `gateforge-owned.ts`). They are reported here for visibility and are
|
|
20
|
+
* never part of `unmappedFiles`.
|
|
21
|
+
*/
|
|
22
|
+
policyInputs: string[];
|
|
23
|
+
/**
|
|
24
|
+
* 0.9.0 D2: true when the WHOLE changed set is Gateforge-owned policy
|
|
25
|
+
* input. Such a change cannot alter product behavior, so the caller keeps
|
|
26
|
+
* the adopted baseline's forgiveness instead of dragging adopted E2E
|
|
27
|
+
* obligations into a strict re-grade. False as soon as one product, test,
|
|
28
|
+
* runner-config, manifest or ignore-control file is in the set.
|
|
29
|
+
*/
|
|
30
|
+
policyInputsOnly: boolean;
|
|
17
31
|
}
|
|
18
32
|
/**
|
|
19
33
|
* Computes one effective evaluation scope for a `--changed` run.
|
|
@@ -40,6 +54,12 @@ export declare function computeEvaluationScope(input: {
|
|
|
40
54
|
mappingSidecar?: boolean;
|
|
41
55
|
knownSourceFiles?: readonly string[];
|
|
42
56
|
strictE2E?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 0.9.0 D2: the changed paths already classified as Gateforge-owned policy
|
|
59
|
+
* inputs by the caller (it owns the candidate checkout, this module stays
|
|
60
|
+
* pure). They are never unmapped and they never expand the scope.
|
|
61
|
+
*/
|
|
62
|
+
policyInputs?: readonly string[];
|
|
43
63
|
}): ScopeDecision;
|
|
44
64
|
/**
|
|
45
65
|
* Lists files whose staged (index) bytes differ from working-tree bytes.
|
package/dist/scope.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAsCA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAS/E,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;IACxB,0EAA0E;IAC1E,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yEAAyE;IACzE,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB;;;;OAIG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB;;;;;;OAMG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAuED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,MAAM,EAAE,eAAe,CAAC;IACxB,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,GAAG,aAAa,CAyGhB;AA0BD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,MAAM,EAAE,CAOV"}
|
package/dist/scope.js
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
*/
|
|
38
38
|
import { spawnSync } from 'node:child_process';
|
|
39
39
|
import { normalizeChangedFiles } from '@gate-forge/core';
|
|
40
|
+
import { GATEFORGE_TEST_MAP_PATH } from './gateforge-owned.js';
|
|
40
41
|
import { GIT_SCOPE_CONTROL_BASENAMES, MANIFEST_NAMES, normalizeRepoModule, PACK_CONFIGS, } from './input-snapshot.js';
|
|
41
42
|
/**
|
|
42
43
|
* Normalizes a repo-relative config path to posix form.
|
|
@@ -157,12 +158,18 @@ export function computeEvaluationScope(input) {
|
|
|
157
158
|
const strictE2E = input.strictE2E === true;
|
|
158
159
|
const reasons = new Set();
|
|
159
160
|
const unmappedFiles = new Set();
|
|
161
|
+
// 0.9.0 D2: the Gateforge-owned policy inputs of this change set, classified
|
|
162
|
+
// by the caller (it owns the candidate checkout; this module stays pure).
|
|
163
|
+
const policyInputs = new Set((input.policyInputs ?? []).map(normalizeRepoPath));
|
|
164
|
+
const policyInputFiles = new Set();
|
|
160
165
|
// Docs-only exemption candidates: `docs/**.md` files. The exemption
|
|
161
166
|
// applies ONLY when the whole changed set is such files (checked after
|
|
162
167
|
// the loop) — a mixed docs+code change is never docs-only.
|
|
163
168
|
const docsOnlyFiles = new Set();
|
|
164
169
|
const isDocsOnly = (file) => file.startsWith('docs/') && file.endsWith('.md');
|
|
165
170
|
for (const file of changed) {
|
|
171
|
+
if (policyInputs.has(file))
|
|
172
|
+
policyInputFiles.add(file);
|
|
166
173
|
const reason = matchGateDefiningInput(file, gate);
|
|
167
174
|
if (reason !== null) {
|
|
168
175
|
reasons.add(reason);
|
|
@@ -190,6 +197,15 @@ export function computeEvaluationScope(input) {
|
|
|
190
197
|
docsOnlyFiles.add(file);
|
|
191
198
|
continue;
|
|
192
199
|
}
|
|
200
|
+
// 0.9.0 D2: a Gateforge-owned policy input (config, policy documents,
|
|
201
|
+
// adapter/waiver/baseline records, generated gate wiring, the managed
|
|
202
|
+
// block of the owner's CI/pre-commit config) is governed by the
|
|
203
|
+
// owner-approved policy digest, never by a product obligation — so it is
|
|
204
|
+
// neither unmapped nor a scope-expansion reason. Placed after the
|
|
205
|
+
// test-file / test-infra / mapping-sidecar checks, which keep expanding
|
|
206
|
+
// for the files they own.
|
|
207
|
+
if (policyInputs.has(file))
|
|
208
|
+
continue;
|
|
193
209
|
// Unclassified change: nothing can attribute it. Strict E2E mode
|
|
194
210
|
// treats it conservatively (full scope + CHANGE_UNMAPPED); outside
|
|
195
211
|
// strict mode the historical narrowed contract is unchanged.
|
|
@@ -208,13 +224,18 @@ export function computeEvaluationScope(input) {
|
|
|
208
224
|
}
|
|
209
225
|
}
|
|
210
226
|
const expandedBecause = [...reasons].sort();
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
227
|
+
const decision = {
|
|
228
|
+
expandedBecause,
|
|
229
|
+
unmappedFiles: [...unmappedFiles].sort(),
|
|
230
|
+
policyInputs: [...policyInputFiles].sort(),
|
|
231
|
+
policyInputsOnly: changed.length > 0 && policyInputFiles.size === changed.length,
|
|
232
|
+
};
|
|
233
|
+
return expandedBecause.length > 0
|
|
234
|
+
? { mode: 'all', changedFiles: changed, ...decision }
|
|
235
|
+
: { mode: 'changed', changedFiles: changed, ...decision };
|
|
215
236
|
}
|
|
216
237
|
/** The tracked mapping sidecar path (scope-expansion trigger). */
|
|
217
|
-
const TEST_MAP_SIDECAR =
|
|
238
|
+
const TEST_MAP_SIDECAR = GATEFORGE_TEST_MAP_PATH;
|
|
218
239
|
/**
|
|
219
240
|
* Runs one git command for the mismatch check, returning stdout lines.
|
|
220
241
|
*
|
package/dist/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAwB,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EACL,2BAA2B,EAC3B,cAAc,EACd,mBAAmB,EACnB,YAAY,GACb,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAwB,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EACL,2BAA2B,EAC3B,cAAc,EACd,mBAAm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,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AACpG,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,iCAAiC,CAC/C,GAAW,EACX,GAAsB;IAEtB,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAC1E,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IAChE,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-tenant singleton guidance (plan 2026-09-25 Phase 4b item 3).
|
|
3
3
|
*
|
|
4
|
-
* A table whose UNIQUE constraint
|
|
5
|
-
* admits one row per tenant (E9/E10): a create of such a
|
|
6
|
-
* provable ONLY on a brand-new tenant, while the witness's
|
|
7
|
-
* use one process-global login.
|
|
8
|
-
*
|
|
4
|
+
* A table whose UNIQUE constraint is written over the tenancy scope
|
|
5
|
+
* ALONE admits at most one row per tenant (E9/E10): a create of such a
|
|
6
|
+
* resource is provable ONLY on a brand-new tenant, while the witness's
|
|
7
|
+
* adapter reads use one process-global login. A constraint that merely
|
|
8
|
+
* CONTAINS a scope column (`unique (period_id, tenant_id, contract_id)`)
|
|
9
|
+
* does not admit one row per tenant, so no such sentence is ever printed.
|
|
10
|
+
* The sqlalchemy pack emits that as an additive `singletonPerTenant`
|
|
11
|
+
* fact; this module turns it into the ONE
|
|
9
12
|
* plain advisory line the owner reads, plus the same guidance as ready-made
|
|
10
13
|
* lines for `gateforge next` (which calls
|
|
11
14
|
* {@link singletonPerTenantGuidanceLines} rather than re-deriving the rule).
|
|
@@ -19,8 +22,14 @@ import { type BlockingEntry, type GraphResource } from '@gate-forge/core';
|
|
|
19
22
|
export interface SingletonPerTenantFact {
|
|
20
23
|
/** Declared constraint/index name, or null when it is unnamed. */
|
|
21
24
|
constraint: string | null;
|
|
22
|
-
/** The recognized tenant-scope column inside {@link columns}. */
|
|
25
|
+
/** The first recognized tenant-scope column inside {@link columns}. */
|
|
23
26
|
tenantColumn: string;
|
|
27
|
+
/**
|
|
28
|
+
* Every recognized tenancy-scope column of the constraint, written
|
|
29
|
+
* order. Absent on a fact minted by an older pack; then the single
|
|
30
|
+
* {@link tenantColumn} is the whole scope.
|
|
31
|
+
*/
|
|
32
|
+
scopeColumns?: readonly string[];
|
|
24
33
|
/** Every column of the unique constraint/index, written order. */
|
|
25
34
|
columns: readonly string[];
|
|
26
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton-guidance.d.ts","sourceRoot":"","sources":["../src/singleton-guidance.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"singleton-guidance.d.ts","sourceRoot":"","sources":["../src/singleton-guidance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAsB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9F,sEAAsE;AACtE,MAAM,WAAW,sBAAsB;IACrC,kEAAkE;IAClE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,uEAAuE;IACvE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,kEAAkE;IAClE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B;AAED,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAmED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,SAAS,aAAa,EAAE,GAClC,iBAAiB,EAAE,CAQrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,SAAS,aAAa,EAAE,EACnC,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,GACnC,aAAa,EAAE,CAYjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,SAAS,aAAa,EAAE,GAClC,MAAM,EAAE,CAIV"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-tenant singleton guidance (plan 2026-09-25 Phase 4b item 3).
|
|
3
3
|
*
|
|
4
|
-
* A table whose UNIQUE constraint
|
|
5
|
-
* admits one row per tenant (E9/E10): a create of such a
|
|
6
|
-
* provable ONLY on a brand-new tenant, while the witness's
|
|
7
|
-
* use one process-global login.
|
|
8
|
-
*
|
|
4
|
+
* A table whose UNIQUE constraint is written over the tenancy scope
|
|
5
|
+
* ALONE admits at most one row per tenant (E9/E10): a create of such a
|
|
6
|
+
* resource is provable ONLY on a brand-new tenant, while the witness's
|
|
7
|
+
* adapter reads use one process-global login. A constraint that merely
|
|
8
|
+
* CONTAINS a scope column (`unique (period_id, tenant_id, contract_id)`)
|
|
9
|
+
* does not admit one row per tenant, so no such sentence is ever printed.
|
|
10
|
+
* The sqlalchemy pack emits that as an additive `singletonPerTenant`
|
|
11
|
+
* fact; this module turns it into the ONE
|
|
9
12
|
* plain advisory line the owner reads, plus the same guidance as ready-made
|
|
10
13
|
* lines for `gateforge next` (which calls
|
|
11
14
|
* {@link singletonPerTenantGuidanceLines} rather than re-deriving the rule).
|
|
@@ -24,11 +27,13 @@ function guidanceSentence(resourceId, fact) {
|
|
|
24
27
|
const constraint = fact.constraint === null
|
|
25
28
|
? `unique(${fact.columns.join(', ')})`
|
|
26
29
|
: `${String(fact.constraint)} unique(${fact.columns.join(', ')})`;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
'
|
|
30
|
-
'
|
|
31
|
-
'
|
|
30
|
+
const scope = (fact.scopeColumns ?? [fact.tenantColumn]).join(' and ');
|
|
31
|
+
return (`'${resourceId}' is a singleton per tenant: ${constraint} is declared over exactly the ` +
|
|
32
|
+
`tenancy scope ('${scope}') and nothing else, so at most one row exists per tenant. Its ` +
|
|
33
|
+
'create can only be proven on a fresh tenant: create the tenant in the test, then register ' +
|
|
34
|
+
"that tenant's login with the witness for THIS session only (POST /sessions/identity — see " +
|
|
35
|
+
'the test-environment guide) so the adapter reads see the new tenant instead of the ' +
|
|
36
|
+
'process-global seat.');
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* Reads the additive `singletonPerTenant` fact off one graph resource,
|
|
@@ -49,9 +54,24 @@ function singletonFactOf(resource) {
|
|
|
49
54
|
return null;
|
|
50
55
|
columns.push(column);
|
|
51
56
|
}
|
|
57
|
+
const scopeColumns = [];
|
|
58
|
+
if (Array.isArray(fact.scopeColumns)) {
|
|
59
|
+
for (const column of fact.scopeColumns) {
|
|
60
|
+
if (typeof column !== 'string' || column.length === 0)
|
|
61
|
+
return null;
|
|
62
|
+
scopeColumns.push(column);
|
|
63
|
+
}
|
|
64
|
+
// A fact whose scope list contradicts its own columns is malformed,
|
|
65
|
+
// not a partial fact to guess at.
|
|
66
|
+
if (scopeColumns.length === 0 ||
|
|
67
|
+
scopeColumns.some((column) => !columns.includes(column))) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
52
71
|
return {
|
|
53
72
|
constraint: typeof fact.constraint === 'string' && fact.constraint.length > 0 ? fact.constraint : null,
|
|
54
73
|
tenantColumn: fact.tenantColumn,
|
|
74
|
+
...(scopeColumns.length > 0 ? { scopeColumns } : {}),
|
|
55
75
|
columns,
|
|
56
76
|
};
|
|
57
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleton-guidance.js","sourceRoot":"","sources":["../src/singleton-guidance.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"singleton-guidance.js","sourceRoot":"","sources":["../src/singleton-guidance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,kBAAkB,EAA0C,MAAM,kBAAkB,CAAC;AA4B9F;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,UAAkB,EAAE,IAA4B;IACxE,MAAM,UAAU,GACd,IAAI,CAAC,UAAU,KAAK,IAAI;QACtB,CAAC,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;QACtC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACtE,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvE,OAAO,CACL,IAAI,UAAU,gCAAgC,UAAU,gCAAgC;QACxF,mBAAmB,KAAK,iEAAiE;QACzF,4FAA4F;QAC5F,4FAA4F;QAC5F,qFAAqF;QACrF,sBAAsB,CACvB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,QAAuB;IAC9C,MAAM,GAAG,GAAG,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACtD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CA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G,MAAM,CA+B/G;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,MAAM,EAAE,eAAe,GACtB;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA4B9C;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAEpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,IAAI,CAUlF;AAED,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,iCAAiC,CAAC;AAEhE;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,GAAE,SAAS,MAAM,EAAiC,GACzD,MAAM,CAsCR;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA+BtF"}
|
package/dist/staged-candidate.js
CHANGED
|
@@ -300,7 +300,8 @@ export function assertRuntimeReuseOwnerApproval(approvedPaths, requestedPaths) {
|
|
|
300
300
|
const approved = new Set(approvedPaths);
|
|
301
301
|
const added = requestedPaths.filter((path) => !approved.has(path));
|
|
302
302
|
if (added.length > 0) {
|
|
303
|
-
throw new StagedCandidateBlockError('ENFORCEMENT_UNTRUSTED', `the staged runtime requests dependency reuse not approved by the committed base: ${added.join(', ')}`, 'Ask the owner to approve the reuse-root change in a separate trusted revision, then rerun the gate
|
|
303
|
+
throw new StagedCandidateBlockError('ENFORCEMENT_UNTRUSTED', `the staged runtime requests dependency reuse not approved by the committed base: ${added.join(', ')}`, 'Ask the owner to approve the reuse-root change in a separate trusted revision, then rerun the gate ' +
|
|
304
|
+
"— or pin GATEFORGE_APPROVED_POLICY_DIGEST to this candidate's digest (runtime.yml is part of it).");
|
|
304
305
|
}
|
|
305
306
|
}
|
|
306
307
|
/**
|