@gate-forge/cli 0.8.0 → 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 +78 -1143
- 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 +7 -0
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +35 -1
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/blocking.d.ts +25 -1
- package/dist/commands/blocking.d.ts.map +1 -1
- package/dist/commands/blocking.js +64 -5
- package/dist/commands/blocking.js.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +60 -2
- 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 +81 -4
- 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 +386 -39
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/next.d.ts.map +1 -1
- package/dist/commands/next.js +103 -5
- package/dist/commands/next.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 +39 -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 +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 +18 -0
- package/dist/git-hooks.d.ts.map +1 -1
- package/dist/git-hooks.js +21 -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/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/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 +78 -20
- package/guides/QUICKSTART.md +55 -10
- package/guides/REFERENCE.md +1710 -0
- package/guides/TEST-ENVIRONMENT.md +8 -5
- package/guides/UPGRADE-0.8-to-0.9.md +104 -0
- package/package.json +10 -10
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,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CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,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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C,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC;QAC5D,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,+BAAwC;QAC/C,UAAU,EAAE,kBAAkB,CAAC,6BAA6B;KAC7D,CAAC,CAAC,CAAC;AACR,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,+BAA+B,CAC7C,SAAmC;IAEnC,OAAO,2BAA2B,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC7D,gBAAgB,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,CACrD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { BlockingEntry, GateforgeConfig } from '@gate-forge/core';
|
|
2
|
+
/** How the owner grades unmatched by-id routes. */
|
|
3
|
+
export type UnmatchedRoutesMode = 'block' | 'warn' | 'unchosen';
|
|
4
|
+
/**
|
|
5
|
+
* The effective mode from a parsed `.gateforge.yml`: `block` only when
|
|
6
|
+
* the owner said so. ABSENT is `unchosen`, which behaves exactly like
|
|
7
|
+
* `warn` and additionally says the owner has not chosen.
|
|
8
|
+
*
|
|
9
|
+
* Args:
|
|
10
|
+
* config: the parsed project config.
|
|
11
|
+
*
|
|
12
|
+
* Returns:
|
|
13
|
+
* UnmatchedRoutesMode: the effective grading mode.
|
|
14
|
+
*/
|
|
15
|
+
export declare function unmatchedRoutesMode(config: GateforgeConfig): UnmatchedRoutesMode;
|
|
16
|
+
/**
|
|
17
|
+
* Whether entries with this code stay blocking under the given mode.
|
|
18
|
+
*
|
|
19
|
+
* Args:
|
|
20
|
+
* mode: the effective grading mode.
|
|
21
|
+
*
|
|
22
|
+
* Returns:
|
|
23
|
+
* boolean: true when the entry blocks the gate.
|
|
24
|
+
*/
|
|
25
|
+
export declare function unmatchedRoutesBlocking(mode: UnmatchedRoutesMode): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Splits blocking entries into the ones this mode keeps blocking and the
|
|
28
|
+
* ones the owner graded as advisory. Entries of any other code are
|
|
29
|
+
* untouched, so a repository with no unmatched route partitions to an
|
|
30
|
+
* empty advisory list and its blocking list unchanged.
|
|
31
|
+
*
|
|
32
|
+
* Args:
|
|
33
|
+
* blocking: the run's blocking entries.
|
|
34
|
+
* mode: the effective grading mode.
|
|
35
|
+
*
|
|
36
|
+
* Returns:
|
|
37
|
+
* blocking/advisories: the two channels, each sorted as it arrived.
|
|
38
|
+
*/
|
|
39
|
+
export declare function partitionUnmatchedRouteEntries(blocking: readonly BlockingEntry[], mode: UnmatchedRoutesMode): {
|
|
40
|
+
blocking: BlockingEntry[];
|
|
41
|
+
advisories: BlockingEntry[];
|
|
42
|
+
};
|
|
43
|
+
/** The advisory entries this module produced, read off a partitioned list. */
|
|
44
|
+
export declare function isUnmatchedRouteEntry(entry: BlockingEntry): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The banner `check` and `next` print near the top: how many entries,
|
|
47
|
+
* the first three with their near matches, and the exact setting line
|
|
48
|
+
* that turns blocking on. Loud by design — a finding that is demoted
|
|
49
|
+
* must still be impossible to miss.
|
|
50
|
+
*
|
|
51
|
+
* Args:
|
|
52
|
+
* advisories: the advisory entries of this code (empty = print nothing).
|
|
53
|
+
* mode: the effective grading mode; `unchosen` adds the sentence
|
|
54
|
+
* telling the owner they have not chosen yet.
|
|
55
|
+
*
|
|
56
|
+
* Returns:
|
|
57
|
+
* string[]: banner lines, empty when there is nothing to say.
|
|
58
|
+
*/
|
|
59
|
+
export declare function unmatchedRouteBannerLines(advisories: readonly BlockingEntry[], mode: UnmatchedRoutesMode): string[];
|
|
60
|
+
//# sourceMappingURL=unmatched-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unmatched-routes.d.ts","sourceRoot":"","sources":["../src/unmatched-routes.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKvE,mDAAmD;AACnD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,mBAAmB,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAE1E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,IAAI,EAAE,mBAAmB,GACxB;IAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;IAAC,UAAU,EAAE,aAAa,EAAE,CAAA;CAAE,CAS5D;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAEnE;AAmBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,SAAS,aAAa,EAAE,EACpC,IAAI,EAAE,mBAAmB,GACxB,MAAM,EAAE,CAiBV"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unmatched by-id routes: `ENDPOINT_RESOURCE_CANDIDATE_UNMATCHED`
|
|
3
|
+
* (0.9.0, owner decision D7).
|
|
4
|
+
*
|
|
5
|
+
* The endpoint compiler emits one typed entry for a by-id route whose
|
|
6
|
+
* path-derived resource name names no discovered business resource. On
|
|
7
|
+
* a large existing repository that can be dozens of entries, and
|
|
8
|
+
* blocking on them all turns an honest finding into a wall of commits
|
|
9
|
+
* the owner never agreed to gate on. The owner decides, through
|
|
10
|
+
* `endpoints.unmatchedRoutes` in `.gateforge.yml`:
|
|
11
|
+
*
|
|
12
|
+
* - ABSENT — an existing repository that upgraded. The entries are
|
|
13
|
+
* ADVISORIES: reported, never blocking, and announced with a banner
|
|
14
|
+
* that names the count, the first examples and the exact key to set.
|
|
15
|
+
* - `warn` — the same non-blocking behavior, once the owner has said
|
|
16
|
+
* so; the banner drops the "you have not chosen" sentence and keeps
|
|
17
|
+
* the count, the examples and the key.
|
|
18
|
+
* - `block` — today's strict behavior: the entry is a blocking entry
|
|
19
|
+
* like every other gate-visible finding.
|
|
20
|
+
*
|
|
21
|
+
* This module owns the PARTITION (blocking vs advisory) and the banner
|
|
22
|
+
* text. It never re-derives the finding: it routes what the compiler
|
|
23
|
+
* already emitted, keyed on the code in the entry detail.
|
|
24
|
+
*/
|
|
25
|
+
import { ENDPOINT_RESOURCE_CANDIDATE_UNMATCHED } from '@gate-forge/http-contract';
|
|
26
|
+
/** The code this module routes, as it appears at the head of an entry detail. */
|
|
27
|
+
const UNMATCHED_ROUTE_PREFIX = `${ENDPOINT_RESOURCE_CANDIDATE_UNMATCHED}:`;
|
|
28
|
+
/**
|
|
29
|
+
* The effective mode from a parsed `.gateforge.yml`: `block` only when
|
|
30
|
+
* the owner said so. ABSENT is `unchosen`, which behaves exactly like
|
|
31
|
+
* `warn` and additionally says the owner has not chosen.
|
|
32
|
+
*
|
|
33
|
+
* Args:
|
|
34
|
+
* config: the parsed project config.
|
|
35
|
+
*
|
|
36
|
+
* Returns:
|
|
37
|
+
* UnmatchedRoutesMode: the effective grading mode.
|
|
38
|
+
*/
|
|
39
|
+
export function unmatchedRoutesMode(config) {
|
|
40
|
+
return config.endpoints?.unmatchedRoutes ?? 'unchosen';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether entries with this code stay blocking under the given mode.
|
|
44
|
+
*
|
|
45
|
+
* Args:
|
|
46
|
+
* mode: the effective grading mode.
|
|
47
|
+
*
|
|
48
|
+
* Returns:
|
|
49
|
+
* boolean: true when the entry blocks the gate.
|
|
50
|
+
*/
|
|
51
|
+
export function unmatchedRoutesBlocking(mode) {
|
|
52
|
+
return mode === 'block';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Splits blocking entries into the ones this mode keeps blocking and the
|
|
56
|
+
* ones the owner graded as advisory. Entries of any other code are
|
|
57
|
+
* untouched, so a repository with no unmatched route partitions to an
|
|
58
|
+
* empty advisory list and its blocking list unchanged.
|
|
59
|
+
*
|
|
60
|
+
* Args:
|
|
61
|
+
* blocking: the run's blocking entries.
|
|
62
|
+
* mode: the effective grading mode.
|
|
63
|
+
*
|
|
64
|
+
* Returns:
|
|
65
|
+
* blocking/advisories: the two channels, each sorted as it arrived.
|
|
66
|
+
*/
|
|
67
|
+
export function partitionUnmatchedRouteEntries(blocking, mode) {
|
|
68
|
+
const advisories = [];
|
|
69
|
+
if (unmatchedRoutesBlocking(mode))
|
|
70
|
+
return { blocking: [...blocking], advisories };
|
|
71
|
+
const kept = [];
|
|
72
|
+
for (const entry of blocking) {
|
|
73
|
+
if (entry.detail.startsWith(UNMATCHED_ROUTE_PREFIX))
|
|
74
|
+
advisories.push(entry);
|
|
75
|
+
else
|
|
76
|
+
kept.push(entry);
|
|
77
|
+
}
|
|
78
|
+
return { blocking: kept, advisories };
|
|
79
|
+
}
|
|
80
|
+
/** The advisory entries this module produced, read off a partitioned list. */
|
|
81
|
+
export function isUnmatchedRouteEntry(entry) {
|
|
82
|
+
return entry.detail.startsWith(UNMATCHED_ROUTE_PREFIX);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* One example line for the banner: the endpoint identity and the names
|
|
86
|
+
* the compiler found near it. The compiler's own sentence carries both,
|
|
87
|
+
* so the banner never re-derives or restates the finding — it shows the
|
|
88
|
+
* owner's own words from the entry.
|
|
89
|
+
*
|
|
90
|
+
* Args:
|
|
91
|
+
* entry: one advisory entry of this code.
|
|
92
|
+
*
|
|
93
|
+
* Returns:
|
|
94
|
+
* string: a single example line, location-qualified when known.
|
|
95
|
+
*/
|
|
96
|
+
function exampleLine(entry) {
|
|
97
|
+
const sentence = entry.detail.slice(UNMATCHED_ROUTE_PREFIX.length).trim();
|
|
98
|
+
return entry.location === null ? ` - ${sentence}` : ` - ${sentence} (${entry.location.file}:${String(entry.location.line)})`;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The banner `check` and `next` print near the top: how many entries,
|
|
102
|
+
* the first three with their near matches, and the exact setting line
|
|
103
|
+
* that turns blocking on. Loud by design — a finding that is demoted
|
|
104
|
+
* must still be impossible to miss.
|
|
105
|
+
*
|
|
106
|
+
* Args:
|
|
107
|
+
* advisories: the advisory entries of this code (empty = print nothing).
|
|
108
|
+
* mode: the effective grading mode; `unchosen` adds the sentence
|
|
109
|
+
* telling the owner they have not chosen yet.
|
|
110
|
+
*
|
|
111
|
+
* Returns:
|
|
112
|
+
* string[]: banner lines, empty when there is nothing to say.
|
|
113
|
+
*/
|
|
114
|
+
export function unmatchedRouteBannerLines(advisories, mode) {
|
|
115
|
+
if (advisories.length === 0)
|
|
116
|
+
return [];
|
|
117
|
+
const noun = advisories.length === 1 ? 'route' : 'routes';
|
|
118
|
+
const lines = [
|
|
119
|
+
`note: ${String(advisories.length)} by-id ${noun} whose name matches no discovered resource ${advisories.length === 1 ? 'is' : 'are'} REPORTED, NOT BLOCKING.`,
|
|
120
|
+
...(mode === 'unchosen'
|
|
121
|
+
? ["note: you have not chosen block or warn for these; an upgraded repository starts here."]
|
|
122
|
+
: []),
|
|
123
|
+
...advisories.slice(0, 3).map(exampleLine),
|
|
124
|
+
`to block commits on them, set in .gateforge.yml:\n endpoints:\n unmatchedRoutes: block`,
|
|
125
|
+
];
|
|
126
|
+
if (advisories.length > 3) {
|
|
127
|
+
lines.push(` ... and ${String(advisories.length - 3)} more — run 'gateforge check' for every entry`);
|
|
128
|
+
}
|
|
129
|
+
return lines;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=unmatched-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unmatched-routes.js","sourceRoot":"","sources":["../src/unmatched-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,qCAA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,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;AACjI,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB,CACvC,UAAoC,EACpC,IAAyB;IAEzB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC1D,MAAM,KAAK,GAAG;QACZ,SAAS,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,IAAI,8CAC9C,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KACnC,0BAA0B;QAC1B,GAAG,CAAC,IAAI,KAAK,UAAU;YACrB,CAAC,CAAC,CAAC,wFAAwF,CAAC;YAC5F,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC;QAC1C,4FAA4F;KAC7F,CAAC;IACF,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,+CAA+C,CAAC,CAAC;IACxG,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -36,7 +36,7 @@ plugins:
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
`version:` is the detector version the pack's own signals carry, and it
|
|
39
|
-
is NOT the pack's npm version (the pack publishes as 0.
|
|
39
|
+
is NOT the pack's npm version (the pack publishes as 0.9.0 while its
|
|
40
40
|
detector declares, say, 0.2.0). Copying a neighbouring entry's value is
|
|
41
41
|
the usual mistake, and it makes every command exit 2: the detector
|
|
42
42
|
refuses to signal under a version the config did not pin. The error names
|
|
@@ -59,12 +59,40 @@ npx gateforge init --blocking
|
|
|
59
59
|
|
|
60
60
|
It writes `.gateforge.yml`, `.gateforge/policies.yml`, the classification
|
|
61
61
|
policy, the `GATEFORGE.md` agent loop, and the adapter/waiver skeleton,
|
|
62
|
-
then wires the pre-commit hook and CI.
|
|
63
|
-
|
|
62
|
+
then wires the pre-commit hook and CI. It also adds Gateforge's own run
|
|
63
|
+
state (`.gateforge/test-gates/`) to your `.gitignore` — that directory is
|
|
64
|
+
regenerated by every run, and without the rule `git add -A` stages it and
|
|
65
|
+
the gate blocks on its own cache. Re-run it any time; it is idempotent and
|
|
66
|
+
never overwrites a file you edited. Anything it appends to a file you own
|
|
67
|
+
(your CI file, your `.pre-commit-config.yaml`, your `.gitignore`) is
|
|
68
|
+
reported as an in-place change with `undo: git restore -- <path>`, separate
|
|
69
|
+
from the `undo: rm -rf` line for files it created.
|
|
70
|
+
|
|
71
|
+
**Your first commit.** Everything `init` and `adopt` write is a Gateforge
|
|
72
|
+
policy input, not product code: the config and policy documents, the
|
|
73
|
+
exclusion declarations, the mapping sidecar, the adapter/waiver/baseline
|
|
74
|
+
records, the generated hook and CI templates, `GATEFORGE.md`, and your CI
|
|
75
|
+
and pre-commit config *while they still carry Gateforge's block*. Committing
|
|
76
|
+
them does not count as an untested behavior change, so the setup commit
|
|
77
|
+
passes `check --changed` in strict mode without `--no-verify`, and it does
|
|
78
|
+
not re-open the E2E debt you adopted. Those files are inside the approved
|
|
79
|
+
policy digest, so approve the digest `init` prints through the protected
|
|
80
|
+
`GATEFORGE_APPROVED_POLICY_DIGEST` setting before you rely on that in a
|
|
81
|
+
strict repository — an unapproved policy revision blocks, exactly as any
|
|
82
|
+
other change to your gate does. Removing the gate job from your CI config is
|
|
83
|
+
not a policy input: it goes back to blocking.
|
|
64
84
|
|
|
65
85
|
Exit code 2 means a configuration problem, not a code problem: the
|
|
66
86
|
message names the file and the key.
|
|
67
87
|
|
|
88
|
+
If the project already has an application, the first commit meets debt the
|
|
89
|
+
gate found before you ran anything. Record that debt once with
|
|
90
|
+
`gateforge adopt` (see `gateforge adopt --help`): it captures today's
|
|
91
|
+
findings as shrink-only forgiven debt and wires the gate. It is never
|
|
92
|
+
needed for a brand-new project, and it does not prove anything — new work
|
|
93
|
+
still blocks, and under `strictE2E` an adopted E2E obligation blocks again
|
|
94
|
+
as soon as a change touches it.
|
|
95
|
+
|
|
68
96
|
## 3. A test environment the gate may trust
|
|
69
97
|
|
|
70
98
|
The witness reads the app you point it at. That app must be **isolated
|
|
@@ -130,14 +158,33 @@ routes the compiler found.
|
|
|
130
158
|
graph proves nothing but the table carries a typical soft-delete
|
|
131
159
|
column, the value is a guess and **needs you** says which column
|
|
132
160
|
raised the question.
|
|
161
|
+
- It writes only from routes the engine **linked** to the resource. A
|
|
162
|
+
path that merely *names* it is listed under **needs you** with the
|
|
163
|
+
candidates, for you to confirm; a route linked to a different
|
|
164
|
+
resource is never used.
|
|
133
165
|
- A per-parent route (`/contracts/{contractId}/invoices`) is never
|
|
134
|
-
taken as the collection, and never as a by-id read of the resource
|
|
135
|
-
|
|
166
|
+
taken as the collection, and never as a by-id read of the resource.
|
|
167
|
+
- A route with a **literal segment between the resource and the id**
|
|
168
|
+
(`/shipments/carrier/{id}` looks a carrier up through a shipment) is
|
|
169
|
+
never taken as a by-id read either — whatever it answers, it is not
|
|
170
|
+
one entity of that resource.
|
|
171
|
+
- When a route comes from a router **no app mounts** (the module is
|
|
172
|
+
never included anywhere), the file still uses it — but marks the
|
|
173
|
+
derived path as a guess and asks you to confirm it: the route exists
|
|
174
|
+
in the source tree, and nothing serves it.
|
|
175
|
+
- When the app serves a complete collection and **no by-id route at
|
|
176
|
+
all**, it writes a **list-only** adapter: the kit reads the member
|
|
177
|
+
out of the collection. The file's header says so, because every read
|
|
178
|
+
then walks the whole collection — slower than a by-id read. Add
|
|
179
|
+
`readPath` as soon as the app serves one.
|
|
136
180
|
- Anything it will not guess is printed under **needs you**, with the
|
|
137
181
|
reason: no read route, a composite key, no collection route (a create
|
|
138
|
-
cannot be witnessed without one), a
|
|
139
|
-
|
|
140
|
-
|
|
182
|
+
cannot be witnessed without one), a route only a name match points
|
|
183
|
+
at, no projectable columns, an unknown target fingerprint, or a route
|
|
184
|
+
that **exists but whose endpoint plane is unanswered**. That last
|
|
185
|
+
case is named with its blocker — `GET /api/v2/accounts/{} exists but
|
|
186
|
+
its plane is unanswered — answer the plane first` — and never
|
|
187
|
+
reported as a missing route.
|
|
141
188
|
|
|
142
189
|
A generated adapter is a **starting point, not proof**. The gate grades
|
|
143
190
|
it exactly like a hand-written one.
|
|
@@ -244,18 +291,29 @@ What the kit guarantees, so you do not have to re-derive it:
|
|
|
244
291
|
credits only the entities it already held when the test session
|
|
245
292
|
opened, read back through the adapter and graded as before. A count
|
|
246
293
|
or total, a metadata-only body, a duplicate id, a row with no id, a
|
|
247
|
-
non-JSON
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
294
|
+
non-JSON body, and a row created after the session opened all REFUSE
|
|
295
|
+
the obligation with a typed note instead of satisfying it. It is
|
|
296
|
+
opt-in: without `collection` a read binds `{id}` from the path
|
|
297
|
+
exactly as before, and a collection may only be declared on a read +
|
|
298
|
+
`GET` whose path carries no `{id}` — anything else is refused when
|
|
299
|
+
the adapter loads. Two resources one test claims may share a route
|
|
300
|
+
only by declaring the SAME shape. When they disagree, neither is read:
|
|
301
|
+
the note names both declarations and no record is issued, because one
|
|
302
|
+
resource's rows can never be read under another resource's
|
|
303
|
+
`rowsKey`/`idKey`. With an identical shape the route is read once and
|
|
304
|
+
that one response credits exactly one claim.
|
|
305
|
+
|
|
306
|
+
**Size: a real list still proves.** A collection read is parsed from
|
|
307
|
+
its OWN bounded copy of the response — up to 1 MiB and up to 10,000
|
|
308
|
+
rows. A list that outgrows the engine's 16 KB response-snapshot cap
|
|
309
|
+
(the tap that feeds the body digest and create attribution, itself
|
|
310
|
+
unchanged) still proves: a real app's data growing must not make a
|
|
311
|
+
passing test unprovable. A body or a page past those bounds is
|
|
312
|
+
refused exactly as a truncated one always was — no ids, a typed note
|
|
313
|
+
naming the bound and the measured size, no record. Both bounds live
|
|
314
|
+
on the WITNESS side, so nothing about your adapter changes; a route
|
|
315
|
+
that serves an unbounded collection should declare paging and a by-id
|
|
316
|
+
read rather than rely on a larger bound.
|
|
259
317
|
|
|
260
318
|
Adapters are read-only by construction. If your app has state only the
|
|
261
319
|
database can answer, the frozen contract has a `probeServer` channel —
|