@gate-forge/cli 0.11.1 → 0.13.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/CHANGELOG.md +198 -0
- package/README.md +10 -1
- package/dist/adopted-baseline.d.ts.map +1 -1
- package/dist/adopted-baseline.js +13 -0
- package/dist/adopted-baseline.js.map +1 -1
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +1 -0
- package/dist/args.js.map +1 -1
- package/dist/business-rules.d.ts +223 -0
- package/dist/business-rules.d.ts.map +1 -0
- package/dist/business-rules.js +383 -0
- package/dist/business-rules.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/adopt.d.ts +5 -3
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +338 -5
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/baseline.d.ts.map +1 -1
- package/dist/commands/baseline.js +60 -24
- package/dist/commands/baseline.js.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +96 -18
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/enforcement.d.ts.map +1 -1
- package/dist/commands/enforcement.js +5 -11
- package/dist/commands/enforcement.js.map +1 -1
- package/dist/commands/explain.d.ts.map +1 -1
- package/dist/commands/explain.js +67 -2
- package/dist/commands/explain.js.map +1 -1
- package/dist/commands/init.d.ts +3 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +96 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/next.d.ts.map +1 -1
- package/dist/commands/next.js +96 -5
- package/dist/commands/next.js.map +1 -1
- package/dist/commands/pre-commit.d.ts.map +1 -1
- package/dist/commands/pre-commit.js +5 -8
- package/dist/commands/pre-commit.js.map +1 -1
- package/dist/commands/test-gates.d.ts.map +1 -1
- package/dist/commands/test-gates.js +245 -12
- 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 +101 -11
- package/dist/commands/tests.js.map +1 -1
- package/dist/detector-trust.d.ts.map +1 -1
- package/dist/detector-trust.js +2 -0
- package/dist/detector-trust.js.map +1 -1
- package/dist/evaluate.d.ts +16 -0
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +26 -2
- package/dist/evaluate.js.map +1 -1
- package/dist/execution.d.ts +6 -5
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +26 -2
- package/dist/execution.js.map +1 -1
- package/dist/input-snapshot.d.ts.map +1 -1
- package/dist/input-snapshot.js +17 -7
- package/dist/input-snapshot.js.map +1 -1
- package/dist/mapping.d.ts +10 -1
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +5 -0
- package/dist/mapping.js.map +1 -1
- package/dist/page-obligations.d.ts +21 -0
- package/dist/page-obligations.d.ts.map +1 -0
- package/dist/page-obligations.js +123 -0
- package/dist/page-obligations.js.map +1 -0
- package/dist/pipeline.d.ts +9 -1
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +10 -0
- package/dist/pipeline.js.map +1 -1
- package/dist/route-plane-proposals.d.ts.map +1 -1
- package/dist/route-plane-proposals.js +1 -0
- package/dist/route-plane-proposals.js.map +1 -1
- package/dist/staged-candidate.d.ts +1 -36
- package/dist/staged-candidate.d.ts.map +1 -1
- package/dist/staged-candidate.js +0 -47
- package/dist/staged-candidate.js.map +1 -1
- package/guides/CONNECT-YOUR-PROJECT.md +38 -0
- package/guides/QUICKSTART.md +46 -7
- package/guides/REFERENCE.md +244 -3
- package/package.json +11 -10
|
@@ -59,7 +59,7 @@ import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync,
|
|
|
59
59
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
60
60
|
import { tmpdir } from 'node:os';
|
|
61
61
|
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
62
|
-
import { AttestationSchema, BEHAVIOR_CASE_KIND, BehaviorCasePayloadSchema, BehaviorCatalogRegistrationSchema, CAUSE_NEXT_ACTIONS, canonicalJson, compareStrings, caseExecutionDigestOf, EMPTY_BEHAVIOR_CATALOG_DIGEST, engineBundleDigestOf, EvidenceRecordSchema, GateReceiptSchema, ExecutionResultSchema, executionBoundaryDigestOf, LOCAL_UNISOLATED_BOUNDARY, humanMessage, isWitnessedRecord, renderRun, requiredCaseSetDigestOf, repositoryDebtOf, runExitCode, sha256Canonical, selectionDigestOf, targetArtifactDigestOf, verifyAttestationMac, executionResultDigestOf, testOutcomesDigestOf, verifyRunRecord, BLOCKING_VERDICTS, decideStrictness, loadQuarantines, QUARANTINE_DIR, resolveStrictnessMode, strictnessSummaryLine, twinDivergenceDetail, twinLinksFor, twinPathDivergence, withoutQuarantinedBindings, } from '@gate-forge/core';
|
|
62
|
+
import { AttestationSchema, BEHAVIOR_CASE_KIND, BehaviorCasePayloadSchema, BehaviorCatalogRegistrationSchema, CAUSE_NEXT_ACTIONS, canonicalJson, compareStrings, caseExecutionDigestOf, EMPTY_BEHAVIOR_CATALOG_DIGEST, engineBundleDigestOf, EvidenceRecordSchema, GateReceiptSchema, ExecutionResultSchema, executionBoundaryDigestOf, evaluateObligation, LOCAL_UNISOLATED_BOUNDARY, humanMessage, isWitnessedRecord, renderRun, requiredCaseSetDigestOf, repositoryDebtOf, runExitCode, sha256Canonical, selectionDigestOf, targetArtifactDigestOf, verifyAttestationMac, executionResultDigestOf, testOutcomesDigestOf, verifyRunRecord, BLOCKING_VERDICTS, decideStrictness, loadQuarantines, QUARANTINE_DIR, resolveStrictnessMode, strictnessSummaryLine, twinDivergenceDetail, twinLinksFor, twinPathDivergence, withoutQuarantinedBindings, } from '@gate-forge/core';
|
|
63
63
|
import { appendFreezeReleaseEvent, armFreezeControl, buildWitnessedPytestChildEnv, canonicalFreezeJson, defaultPlaywrightCommand, diffNativePlaywrightTests, discoverTestCatalog, findPlaywrightConfig, isPlaywrightRunnerInstall, listNativePlaywrightTests, mintFreezeSigningKeyPair, nativeConfigDirOf, playwrightTestModulePath, removeFreezeSpecDir, signFreezeRelease, spoolPathFor, supervisedRunnerChildEnv, writeFreezeRefusal, resolveProjectStorageState, CypressRunnerAdapter, PlaywrightAdapter, PytestRunnerAdapter, readRunnerOutcomes, startSupervisorSpoolDrain, startWitnessProcess, SupervisorClient, TestDiscoveryError, VitestRunnerAdapter, RUN_HEADER, VERIFIER_HEADER, DEFAULT_RUN_TIMEOUT_MS, ENV_CHAOS_MAX_DELAY_MS, ENV_CHAOS_REORDER, ENV_CHAOS_SEED, ENV_PROXY_TARGET, ENV_TWIN_INVENTORY, ENV_TWIN_QUERY_KEYS, ENV_TWIN_SHAPES, } from '@gate-forge/pack-playwright';
|
|
64
64
|
import { parseArgs, repeatableStringFlag, stringFlag } from '../args.js';
|
|
65
65
|
import { resolveAdoptedBaseline } from '../adopted-baseline.js';
|
|
@@ -68,6 +68,8 @@ import { writeLine } from '../io.js';
|
|
|
68
68
|
import { runDiagnosticSuites, runWitnessedPytestSuites } from '../diagnostics.js';
|
|
69
69
|
import { claimInjectionsFor, planScopedExpectedSet, trustedPolicyDigestForConfig, issueGateReceipt, issueRunRecord, parentSha, planExpectedSet, plannedProjectScopes, plannedRowsWithProjectDependencies, sealExecutionResult, supervisionBlocking, SUPERVISED_INVOCATION, } from '../execution.js';
|
|
70
70
|
import { evaluateRun, scopeBlocking, splitBlockingByBaseline } from '../evaluate.js';
|
|
71
|
+
import { businessRuleInventory, businessRuleReportEntries, businessRuleRunFacts, gradeBusinessRules, partitionBusinessRuleEntries, witnessedRunnersOf, } from '../business-rules.js';
|
|
72
|
+
import { bindPageRouteParams, createdEntityIdsFromRecords, pageReportEntries } from '../page-obligations.js';
|
|
71
73
|
import { installedPlaywrightCompatibilityError } from '../package-compatibility.js';
|
|
72
74
|
import { DOCS_EXCLUSIONS_GUARANTEE, loadDocsExclusions } from '../docs-exclusions.js';
|
|
73
75
|
import { CACHE_EXCLUSIONS_GUARANTEE, loadCacheExclusions } from '../cache-exclusions.js';
|
|
@@ -1799,6 +1801,7 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
1799
1801
|
// pair did not both run — a divergence needs two sides observed in
|
|
1800
1802
|
// the SAME run, never shapes carried over from another.
|
|
1801
1803
|
let twinDivergences = [];
|
|
1804
|
+
let pageSweepAdvisories = [];
|
|
1802
1805
|
if (runnerName === 'pytest') {
|
|
1803
1806
|
const configured = (config.diagnostics?.suites ?? []).filter((suite) => suite.runner === 'pytest');
|
|
1804
1807
|
if (configured.length > 1) {
|
|
@@ -2101,11 +2104,17 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
2101
2104
|
// Hoisted: the validated sidecar, the only declaration source the
|
|
2102
2105
|
// witness-side case assignments are built from.
|
|
2103
2106
|
let behaviorSidecar = null;
|
|
2107
|
+
// The one resolver's business-rule claim namespace. Rule findings are
|
|
2108
|
+
// graded AFTER the run seals (they need the run's own facts) but
|
|
2109
|
+
// RESOLVED here, so the sidecar's rule declarations reach the same
|
|
2110
|
+
// staleness, ambiguity and quarantine treatment as obligations.
|
|
2111
|
+
let ruleBindings = [];
|
|
2104
2112
|
if (catalog !== null) {
|
|
2105
2113
|
const mapped = await resolveRepositoryMappings({
|
|
2106
2114
|
cwd: io.cwd,
|
|
2107
2115
|
config,
|
|
2108
2116
|
obligations: pipeline.policy.obligations,
|
|
2117
|
+
businessRules: pipeline.businessRules,
|
|
2109
2118
|
stateDir,
|
|
2110
2119
|
catalog,
|
|
2111
2120
|
nativeClaims,
|
|
@@ -2129,6 +2138,7 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
2129
2138
|
mappedCoverage = mappedCoverageFrom(gradedResolution, pipeline.policy.obligations, pipeline.graph);
|
|
2130
2139
|
serverE2eObligations = serverE2eObligationIds(mapped.resolution);
|
|
2131
2140
|
observeObligations = observeObligationIds(mapped.resolution);
|
|
2141
|
+
ruleBindings = mapped.resolution.ruleBindings;
|
|
2132
2142
|
// Adopted baseline debt (E62): the changed-scope planner must agree
|
|
2133
2143
|
// with this run's own grading, which waives exactly the obligations
|
|
2134
2144
|
// the ADOPTED baseline forgives (`applyBaseline`). Strict E2E
|
|
@@ -3157,11 +3167,12 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
3157
3167
|
GATEFORGE_QUEUE_OBSERVER: config.queueObserver.kind,
|
|
3158
3168
|
GATEFORGE_QUEUE_OBSERVER_CONFIG: JSON.stringify(config.queueObserver),
|
|
3159
3169
|
}),
|
|
3160
|
-
//
|
|
3161
|
-
//
|
|
3162
|
-
// keep their existing proxy-free wiring.
|
|
3170
|
+
// Page observation also requires a session-attributed proxy exchange so
|
|
3171
|
+
// the witness can refuse browser responses the proxy never saw.
|
|
3163
3172
|
...(runnerName === 'pytest' || runnerName === 'vitest' || runnerName === 'cypress' ||
|
|
3164
|
-
(runnerName === 'playwright' &&
|
|
3173
|
+
(runnerName === 'playwright' &&
|
|
3174
|
+
(observeObligations.length > 0 ||
|
|
3175
|
+
(config.pages !== undefined && pipeline.graph.resources.some((resource) => resource.kind === 'ui.page'))))
|
|
3165
3176
|
? appBase !== ''
|
|
3166
3177
|
? { [ENV_PROXY_TARGET]: appBase }
|
|
3167
3178
|
: {}
|
|
@@ -3305,6 +3316,52 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
3305
3316
|
// now on /sessions/open accepts only tests in it, and the execution
|
|
3306
3317
|
// trace groups sessions by these identities.
|
|
3307
3318
|
const plannedIdentities = new Set(plannedRows.map((row) => `${row.planned.project ?? ''}\u0000${row.planned.file}\u0000${row.planned.titlePath.join('>')}`));
|
|
3319
|
+
// Controller-held page-observation context (0.13 authority cutover):
|
|
3320
|
+
// computed ONCE here from engine-owned inputs (derived graph, config,
|
|
3321
|
+
// trusted catalog) and registered with the expected set through the
|
|
3322
|
+
// verifier-authenticated supervisor surface. The suite child receives
|
|
3323
|
+
// only an enablement bit — never the grading configuration.
|
|
3324
|
+
let pageObservation = null;
|
|
3325
|
+
if (runnerName === 'playwright' && io.env['GATEFORGE_APP_BASE_URL'] !== undefined) {
|
|
3326
|
+
const pageAudiences = config.pages?.audiences ?? [];
|
|
3327
|
+
const pages = pipeline.graph.resources.flatMap((resource) => {
|
|
3328
|
+
const path = resource.attributes['path'];
|
|
3329
|
+
const audience = resource.attributes['audience'];
|
|
3330
|
+
if (!(resource.kind === 'ui.page' && resource.id !== null && typeof path === 'string'))
|
|
3331
|
+
return [];
|
|
3332
|
+
const configured = typeof audience === 'string'
|
|
3333
|
+
? pageAudiences.find((entry) => entry.name === audience)
|
|
3334
|
+
: undefined;
|
|
3335
|
+
return [{
|
|
3336
|
+
id: resource.id,
|
|
3337
|
+
path,
|
|
3338
|
+
// An audience whose declaration has no login (`session`) makes its
|
|
3339
|
+
// pages anonymous: an exactly-401 app answer is the expected
|
|
3340
|
+
// not-logged-in answer there. Controller-held, like the route
|
|
3341
|
+
// table; an audience missing from the config fails closed.
|
|
3342
|
+
...(configured !== undefined && configured.session === undefined ? { anonymous: true } : {}),
|
|
3343
|
+
}];
|
|
3344
|
+
});
|
|
3345
|
+
if (pages.length > 0) {
|
|
3346
|
+
pageObservation = {
|
|
3347
|
+
pages,
|
|
3348
|
+
loginRoutes: (config.pages?.audiences ?? []).map((audience) => audience.loginRoute),
|
|
3349
|
+
errorMarkers: config.pages?.errorMarkers ?? [],
|
|
3350
|
+
appOrigins: [new URL(io.env['GATEFORGE_APP_BASE_URL']).origin],
|
|
3351
|
+
tamperRisks: catalog?.entries.flatMap((entry) => {
|
|
3352
|
+
const risk = entry.suppressionSignals.find((signal) => signal.kind === 'mock' && signal.detail.startsWith('PAGE_OBSERVATION_TAMPER_RISK:'));
|
|
3353
|
+
return risk === undefined
|
|
3354
|
+
? []
|
|
3355
|
+
: [{
|
|
3356
|
+
testId: entry.parameterIdentity,
|
|
3357
|
+
file: entry.file,
|
|
3358
|
+
locationFile: risk.location.file,
|
|
3359
|
+
line: risk.location.line,
|
|
3360
|
+
}];
|
|
3361
|
+
}) ?? [],
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3308
3365
|
const registered = await (async () => {
|
|
3309
3366
|
if (runnerName !== 'playwright') {
|
|
3310
3367
|
// The contract enumeration (fixed above, before the policy gate
|
|
@@ -3324,7 +3381,10 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
3324
3381
|
? { observationOnly: true }
|
|
3325
3382
|
: {}),
|
|
3326
3383
|
}));
|
|
3327
|
-
return supervisor.registerExpectedSet({
|
|
3384
|
+
return supervisor.registerExpectedSet({
|
|
3385
|
+
tests,
|
|
3386
|
+
...(pageObservation === null ? {} : { pageObservation }),
|
|
3387
|
+
});
|
|
3328
3388
|
}
|
|
3329
3389
|
const enumeration = await listNativePlaywrightTests({ cwd: io.cwd });
|
|
3330
3390
|
// A named run registers the NAMED tests, for the same reason it
|
|
@@ -3356,6 +3416,7 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
3356
3416
|
? { observationOnly: true }
|
|
3357
3417
|
: {}),
|
|
3358
3418
|
})),
|
|
3419
|
+
...(pageObservation === null ? {} : { pageObservation }),
|
|
3359
3420
|
});
|
|
3360
3421
|
})();
|
|
3361
3422
|
// Progress goes to stderr: with --format json, stdout carries ONLY the
|
|
@@ -3399,6 +3460,23 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
3399
3460
|
if (typeof value === 'string' && value !== '')
|
|
3400
3461
|
suiteEnv[name] = value;
|
|
3401
3462
|
}
|
|
3463
|
+
// Page-observation advisories + enablement (0.13 authority cutover):
|
|
3464
|
+
// the child learns ONLY that observation is enabled — the grading
|
|
3465
|
+
// configuration itself was registered with the expected set above, so
|
|
3466
|
+
// a suite-controlled variable can disable observation but can never
|
|
3467
|
+
// enable false proof.
|
|
3468
|
+
if (pageObservation !== null) {
|
|
3469
|
+
writeLine(io.stderr, 'PAGE_OBSERVATION_FIXTURE_REQUIRED: page records are issued only for tests using the Gateforge Playwright fixture; other tests produce no page-observation records.');
|
|
3470
|
+
const reportedTamperLocations = new Set();
|
|
3471
|
+
for (const risk of pageObservation.tamperRisks) {
|
|
3472
|
+
const key = `${risk.file}\u0000${risk.locationFile}\u0000${risk.line}`;
|
|
3473
|
+
if (reportedTamperLocations.has(key))
|
|
3474
|
+
continue;
|
|
3475
|
+
reportedTamperLocations.add(key);
|
|
3476
|
+
writeLine(io.stderr, `PAGE_OBSERVATION_TAMPER_RISK: page records refused for tests in ${risk.file}; browser API mutation at ${risk.locationFile}:${risk.line}.`);
|
|
3477
|
+
}
|
|
3478
|
+
suiteEnv['GATEFORGE_PAGE_OBSERVATION_ENABLED'] = '1';
|
|
3479
|
+
}
|
|
3402
3480
|
if (declaredRunnerEnvNames !== undefined) {
|
|
3403
3481
|
for (const name of declaredRunnerEnvNames) {
|
|
3404
3482
|
// OWN membership on the ambient environment, for the same reason the
|
|
@@ -3970,6 +4048,104 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
3970
4048
|
catch {
|
|
3971
4049
|
sessionTrace = null; // fail closed: a missing authority never grades success
|
|
3972
4050
|
}
|
|
4051
|
+
if (effectiveWitnessUrl !== undefined && config.pages?.sweep !== false) {
|
|
4052
|
+
const pageResources = pipeline.graph.resources.flatMap((resource) => {
|
|
4053
|
+
const pagePath = resource.attributes['path'];
|
|
4054
|
+
const audience = resource.attributes['audience'];
|
|
4055
|
+
const configured = typeof audience === 'string'
|
|
4056
|
+
? config.pages?.audiences.find((entry) => entry.name === audience)
|
|
4057
|
+
: undefined;
|
|
4058
|
+
return resource.kind === 'ui.page' && resource.id !== null && typeof pagePath === 'string' && typeof audience === 'string'
|
|
4059
|
+
? [{
|
|
4060
|
+
id: resource.id,
|
|
4061
|
+
path: pagePath,
|
|
4062
|
+
audience,
|
|
4063
|
+
// Same controller-held anonymity bit the observed channel
|
|
4064
|
+
// grades: an audience with no configured login makes an
|
|
4065
|
+
// exactly-401 app answer the expected not-logged-in answer.
|
|
4066
|
+
...(configured !== undefined && configured.session === undefined ? { anonymous: true } : {}),
|
|
4067
|
+
}]
|
|
4068
|
+
: [];
|
|
4069
|
+
});
|
|
4070
|
+
const response = await fetch(`${effectiveWitnessUrl}/records`, { headers: { [RUN_HEADER]: runToken } });
|
|
4071
|
+
if (!response.ok)
|
|
4072
|
+
throw new UsageError(`test-gates: page sweep cannot read witness records (HTTP ${String(response.status)})`);
|
|
4073
|
+
const ledger = await response.json();
|
|
4074
|
+
const priorRecords = ledger !== null && typeof ledger === 'object' && 'records' in ledger && Array.isArray(ledger.records)
|
|
4075
|
+
? ledger.records
|
|
4076
|
+
: [];
|
|
4077
|
+
const createdEntityIds = createdEntityIdsFromRecords(priorRecords);
|
|
4078
|
+
const observedPageRecords = priorRecords.filter((raw) => {
|
|
4079
|
+
const parsed = EvidenceRecordSchema.safeParse(raw);
|
|
4080
|
+
if (!parsed.success || parsed.data.kind !== 'page.observed' ||
|
|
4081
|
+
parsed.data.origin !== 'engine-observed' || parsed.data.trust !== 'witnessed')
|
|
4082
|
+
return false;
|
|
4083
|
+
const payload = parsed.data.payload;
|
|
4084
|
+
return payload !== null && typeof payload === 'object' && !Array.isArray(payload) &&
|
|
4085
|
+
'channel' in payload && payload.channel === 'observed';
|
|
4086
|
+
});
|
|
4087
|
+
// Gap selection uses the same latest-observation semantics as final grading.
|
|
4088
|
+
const pageContext = {
|
|
4089
|
+
claims: [], records: observedPageRecords, waivers: [],
|
|
4090
|
+
classification: null, now: pipeline.now,
|
|
4091
|
+
};
|
|
4092
|
+
const cleanPageObligations = new Set();
|
|
4093
|
+
for (const obligation of pipeline.policy.obligations) {
|
|
4094
|
+
if ((obligation.contract === 'page:loads' || obligation.contract === 'page:data-ok') &&
|
|
4095
|
+
evaluateObligation(obligation, pageContext).verdict === 'satisfied') {
|
|
4096
|
+
cleanPageObligations.add(obligation.id);
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
const cleanPageIds = new Set();
|
|
4100
|
+
for (const page of pageResources) {
|
|
4101
|
+
if (cleanPageObligations.has(`${page.id}:page:loads`) &&
|
|
4102
|
+
cleanPageObligations.has(`${page.id}:page:data-ok`))
|
|
4103
|
+
cleanPageIds.add(page.id);
|
|
4104
|
+
}
|
|
4105
|
+
const routesByAudience = new Map();
|
|
4106
|
+
for (const page of pageResources) {
|
|
4107
|
+
if (cleanPageIds.has(page.id) || config.pages?.exclude?.includes(page.path))
|
|
4108
|
+
continue;
|
|
4109
|
+
const resolved = bindPageRouteParams(page.path, page.audience, config.pages?.params?.[page.path], createdEntityIds);
|
|
4110
|
+
if (resolved.path === null) {
|
|
4111
|
+
const detail = `PAGE_PARAM_UNBOUND: ${page.path} needs seeded pages.params values or a unique ` +
|
|
4112
|
+
`engine-observed create id for parameter(s) ${resolved.unbound.join(', ')}; no id is guessed.`;
|
|
4113
|
+
writeLine(io.stderr, detail);
|
|
4114
|
+
pageSweepAdvisories.push({ kind: 'finding', resourceId: page.id, name: page.path, detail, location: null, cause: null, nextAction: null });
|
|
4115
|
+
continue;
|
|
4116
|
+
}
|
|
4117
|
+
const routes = routesByAudience.get(page.audience) ?? [];
|
|
4118
|
+
routes.push({ ...page, path: resolved.path });
|
|
4119
|
+
routesByAudience.set(page.audience, routes);
|
|
4120
|
+
}
|
|
4121
|
+
for (const [audienceName, routes] of routesByAudience) {
|
|
4122
|
+
const audience = config.pages?.audiences.find((entry) => entry.name === audienceName);
|
|
4123
|
+
if (audience === undefined) {
|
|
4124
|
+
const detail = `PAGE_AUDIENCE_UNBOUND: referee cannot select a session for audience '${audienceName}'.`;
|
|
4125
|
+
writeLine(io.stderr, detail);
|
|
4126
|
+
pageSweepAdvisories.push({ kind: 'finding', resourceId: null, name: audienceName, detail, location: null, cause: null, nextAction: null });
|
|
4127
|
+
continue;
|
|
4128
|
+
}
|
|
4129
|
+
let storageState;
|
|
4130
|
+
if (audience.session !== undefined) {
|
|
4131
|
+
const sessionPath = resolve(io.cwd, audience.session);
|
|
4132
|
+
try {
|
|
4133
|
+
storageState = JSON.parse(readFileSync(sessionPath, 'utf8'));
|
|
4134
|
+
}
|
|
4135
|
+
catch (error) {
|
|
4136
|
+
throw new UsageError(`test-gates: page audience '${audienceName}' storage state could not be read at '${audience.session}': ${error.message}`);
|
|
4137
|
+
}
|
|
4138
|
+
}
|
|
4139
|
+
const sweep = await supervisor.sweepPages({
|
|
4140
|
+
audience: audienceName,
|
|
4141
|
+
pages: routes,
|
|
4142
|
+
loginRoutes: [audience.loginRoute],
|
|
4143
|
+
errorMarkers: config.pages?.errorMarkers ?? [],
|
|
4144
|
+
...(storageState !== undefined ? { storageState } : {}),
|
|
4145
|
+
});
|
|
4146
|
+
writeLine(io.stderr, `page sweep visited ${String(sweep.visits.length)} page gap(s) for audience '${audienceName}'.`);
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
3973
4149
|
if (effectiveWitnessUrl !== undefined) {
|
|
3974
4150
|
await writeWitnessLedgerDocument(io, stateDir, effectiveWitnessUrl, runToken);
|
|
3975
4151
|
}
|
|
@@ -4402,13 +4578,56 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
4402
4578
|
},
|
|
4403
4579
|
};
|
|
4404
4580
|
const evaluatedBase = evaluateRun(evaluationInput);
|
|
4581
|
+
// Owner-declared business rules (plan 2026-10-05 D4/D5), graded from
|
|
4582
|
+
// THIS run's own sealed facts. A rule with no mapped test, or a mapped
|
|
4583
|
+
// test that did not run, did not pass, or does not carry the type's
|
|
4584
|
+
// proof, is a finding — a declaration is never proof.
|
|
4585
|
+
//
|
|
4586
|
+
// Graded AFTER `evaluateRun` so it reads the run's AUTHORIZED records
|
|
4587
|
+
// (`evaluatedBase.records`), never a raw `records.json` read: a rule
|
|
4588
|
+
// case must not be attributed to evidence the obligation grader
|
|
4589
|
+
// rejected. Merged into the run's own blocking set for the same reason
|
|
4590
|
+
// twin findings are, so one partition and one exit code decide the
|
|
4591
|
+
// outcome (invariant 8).
|
|
4592
|
+
let rulePartition = {
|
|
4593
|
+
blocking: [],
|
|
4594
|
+
advisories: [],
|
|
4595
|
+
};
|
|
4596
|
+
// Every graded case (satisfied ones included) for the persisted and
|
|
4597
|
+
// stdout json document's `businessRules` section: a satisfied case
|
|
4598
|
+
// names the channel that proved it (invariant 6), and an advisory case
|
|
4599
|
+
// is listed here beside its advisory-channel entry (invariant 7).
|
|
4600
|
+
let ruleCases = [];
|
|
4601
|
+
if (pipeline.businessRules.length > 0 && catalog !== null) {
|
|
4602
|
+
ruleCases = gradeBusinessRules({
|
|
4603
|
+
rules: pipeline.businessRules,
|
|
4604
|
+
ruleBindings,
|
|
4605
|
+
inventory: businessRuleInventory(pipeline.graph),
|
|
4606
|
+
runFacts: businessRuleRunFacts({
|
|
4607
|
+
result: sealed.result,
|
|
4608
|
+
records: evaluatedBase.records,
|
|
4609
|
+
witnessedRunners: witnessedRunnersOf(config),
|
|
4610
|
+
scope: options.scope === 'changed' ? 'changed' : 'full',
|
|
4611
|
+
docsOnly: false,
|
|
4612
|
+
catalog,
|
|
4613
|
+
}),
|
|
4614
|
+
catalog,
|
|
4615
|
+
}).cases;
|
|
4616
|
+
rulePartition = partitionBusinessRuleEntries(pipeline.businessRules, ruleCases);
|
|
4617
|
+
}
|
|
4405
4618
|
// Twin path coverage in `block` mode joins the run's OWN blocking set:
|
|
4406
4619
|
// it appears in `blocking` (not only in `advisories`) and it fails the
|
|
4407
4620
|
// run the way any other blocking finding does. In `advisory` mode this
|
|
4408
|
-
// is the base evaluation, byte-identical.
|
|
4409
|
-
|
|
4621
|
+
// is the base evaluation, byte-identical. Business-rule findings join
|
|
4622
|
+
// the same set, partitioned by the OWNER's `enforcement` declaration.
|
|
4623
|
+
const runBlocking = [...twinBlocking, ...rulePartition.blocking];
|
|
4624
|
+
// Advisory rules ride the report's existing advisory channel (plan D5,
|
|
4625
|
+
// invariant 7): printed and serialized every run, out of `blocking` and
|
|
4626
|
+
// out of the exit code — so a demoted rule never hides.
|
|
4627
|
+
const runAdvisories = [...twinAdvisories, ...rulePartition.advisories, ...pageSweepAdvisories];
|
|
4628
|
+
const evaluated = runBlocking.length === 0
|
|
4410
4629
|
? evaluatedBase
|
|
4411
|
-
: { ...evaluatedBase, blocking: [...evaluatedBase.blocking, ...
|
|
4630
|
+
: { ...evaluatedBase, blocking: [...evaluatedBase.blocking, ...runBlocking] };
|
|
4412
4631
|
// Owner-chosen strictness: the mapping from the strict decision to the
|
|
4413
4632
|
// effective exit code. `changed` reuses the run's own provider diff and
|
|
4414
4633
|
// the evaluator's own attribution rule — an unknown change fails closed.
|
|
@@ -4643,6 +4862,13 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
4643
4862
|
},
|
|
4644
4863
|
}),
|
|
4645
4864
|
};
|
|
4865
|
+
const pageEntries = pageReportEntries(pipeline.graph, evaluated.verdicts, readJsonArray(stateDir, 'records.json'));
|
|
4866
|
+
const pageSectionText = pageEntries.length === 0
|
|
4867
|
+
? ''
|
|
4868
|
+
: `\npages:\n${pageEntries
|
|
4869
|
+
.map((entry) => ` ${entry.path}: channel=${entry.channel ?? 'none'}; test=${entry.test ?? 'none'}; ` +
|
|
4870
|
+
`status=${entry.status}${entry.reason === null ? '' : `; reason=${entry.reason}`}`)
|
|
4871
|
+
.join('\n')}`;
|
|
4646
4872
|
// Report-side strictness + quarantine:
|
|
4647
4873
|
// ADDITIVE only. A repository that never softened its gate and never
|
|
4648
4874
|
// quarantined a test gets exactly the document it got before.
|
|
@@ -4652,7 +4878,7 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
4652
4878
|
// Twin path coverage (E64): reported, never blocking, in advisory
|
|
4653
4879
|
// mode. An empty list adds no report key, so a run without twin
|
|
4654
4880
|
// findings keeps exactly the document it always had.
|
|
4655
|
-
...(
|
|
4881
|
+
...(runAdvisories.length === 0 ? {} : { advisories: runAdvisories }),
|
|
4656
4882
|
waiverCounts: evaluated.waiverCounts,
|
|
4657
4883
|
run: manifest,
|
|
4658
4884
|
toolVersion: VERSION,
|
|
@@ -4678,7 +4904,7 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
4678
4904
|
...JSON.parse(renderRun(evaluated.verdicts, {
|
|
4679
4905
|
format: 'json',
|
|
4680
4906
|
blocking: evaluated.blocking,
|
|
4681
|
-
...(
|
|
4907
|
+
...(runAdvisories.length === 0 ? {} : { advisories: runAdvisories }),
|
|
4682
4908
|
waiverCounts: evaluated.waiverCounts,
|
|
4683
4909
|
run: manifest,
|
|
4684
4910
|
toolVersion: VERSION,
|
|
@@ -4714,9 +4940,16 @@ async function runSupervisedTestGatesInner(io, options, declaredRunnerEnvNames)
|
|
|
4714
4940
|
})),
|
|
4715
4941
|
},
|
|
4716
4942
|
}),
|
|
4943
|
+
// Owner-declared business rules (plan §7.5, invariant 6): every
|
|
4944
|
+
// graded case with its status and proof channel. Additive — no
|
|
4945
|
+
// declared rules, no section, byte-identical document.
|
|
4946
|
+
...(ruleCases.length === 0
|
|
4947
|
+
? {}
|
|
4948
|
+
: { businessRules: businessRuleReportEntries(pipeline.businessRules, ruleCases) }),
|
|
4949
|
+
...(pageEntries.length === 0 ? {} : { pages: pageEntries }),
|
|
4717
4950
|
});
|
|
4718
4951
|
const report = format === 'text'
|
|
4719
|
-
? `${renderedReport}\n${strictnessSummaryLine(strictness)}${quarantines.active.length === 0
|
|
4952
|
+
? `${renderedReport}${pageSectionText}\n${strictnessSummaryLine(strictness)}${quarantines.active.length === 0
|
|
4720
4953
|
? ''
|
|
4721
4954
|
: `\nquarantined: ${String(quarantines.active.length)} (expires ${quarantines.active
|
|
4722
4955
|
.map((entry) => `${entry.quarantine.testKey} @ ${entry.quarantine.expiresAt}`)
|