@aiwg/cli 2026.10.12 → 2026.10.15
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/agentic/code/addons/aiwg-utils/rules/anti-laziness.core.md +13 -0
- package/agentic/code/addons/aiwg-utils/rules/anti-laziness.md +118 -0
- package/agentic/code/providers/pi/aiwg-bridge.ts +44 -1
- package/dist/src/artifacts/corpus-tools/cli.js +32 -0
- package/dist/src/artifacts/corpus-tools/discovery-log.js +1 -1
- package/dist/src/artifacts/corpus-tools/expand-cli.js +89 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +38 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +40 -0
- package/dist/src/artifacts/corpus-tools/expand.js +125 -0
- package/dist/src/artifacts/corpus-tools/resolve-cli.js +91 -0
- package/dist/src/artifacts/corpus-tools/resolve-corpus.js +41 -0
- package/dist/src/artifacts/corpus-tools/resolve.js +105 -0
- package/dist/src/cli/handlers/doctor-args.js +40 -0
- package/dist/src/cli/handlers/doctor-help.js +4 -2
- package/dist/src/cli/handlers/use-bundle-counts.js +32 -6
- package/dist/src/cli/handlers/use-skill-assets.js +207 -0
- package/dist/src/cli/handlers/use.js +30 -193
- package/dist/src/cli/handlers/utilities.js +5 -31
- package/dist/src/config/authorization-cli.js +11 -3
- package/dist/src/config/worker-context.js +33 -4
- package/dist/src/decision/context-pruning-common.js +41 -0
- package/dist/src/decision/context-pruning-evaluation.js +366 -0
- package/dist/src/decision/context-pruning-pilot.js +431 -0
- package/dist/src/decision/context-pruning-types.js +19 -0
- package/dist/src/decision/context-pruning.js +5 -847
- package/dist/src/decision/ensemble/contract.js +4 -24
- package/dist/src/decision/heldout/collector.js +1 -1
- package/dist/src/decision/qualification/release.js +5 -62
- package/dist/src/extensions/manifest.js +8 -1
- package/dist/src/extensions/project-local-doctor.js +78 -2
- package/dist/src/extensions/validation.js +10 -11
- package/dist/src/features/catalog.js +1 -1
- package/dist/src/gates/evaluate.js +5 -15
- package/dist/src/gates/heldout.js +42 -0
- package/dist/src/gates/index.js +2 -1
- package/dist/src/gates/upstream-ceiling.js +111 -0
- package/dist/src/models/provider-models.js +5 -8
- package/dist/src/models/worker-installation-store.mjs +228 -0
- package/dist/src/models/worker-installation.mjs +7 -162
- package/dist/src/models/wrapper-definitions.js +14 -0
- package/dist/src/models/wrapper-deployment.js +48 -25
- package/dist/src/models/wrapper-enforcement.js +72 -0
- package/dist/src/policy/hitl-check.js +80 -0
- package/dist/src/providers/provider-definitions.js +10 -10
- package/dist/src/research/clients/arxiv.js +10 -4
- package/dist/src/research/clients/base.js +5 -4
- package/dist/src/research/clients/crossref.js +9 -1
- package/dist/src/research/clients/semantic-scholar.js +73 -44
- package/dist/src/research/identity.js +85 -0
- package/dist/src/research/index.js +1 -0
- package/dist/src/research/reference-match.js +89 -0
- package/dist/src/rules/activation.d.mts +2 -0
- package/dist/src/rules/activation.mjs +23 -0
- package/dist/src/rules/core-startup.d.mts +2 -0
- package/dist/src/rules/core-startup.mjs +31 -0
- package/dist/src/skills/adapters/local.js +32 -9
- package/dist/src/skills/agent-skills.js +2 -0
- package/dist/src/skills/cli-display.js +33 -0
- package/dist/src/skills/cli.js +2 -26
- package/dist/src/skills/collision-discovery.js +84 -0
- package/dist/src/skills/deployer.js +20 -75
- package/dist/src/skills/deployment-ownership.js +74 -0
- package/dist/src/skills/doctor.js +2 -2
- package/dist/src/skills/importer.js +4 -26
- package/dist/src/skills/registry.js +22 -7
- package/dist/src/smiths/context-pipeline/agents-md.js +34 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +3 -0
- package/dist/src/smiths/context-pipeline/bridge-ownership.js +50 -0
- package/dist/src/smiths/context-pipeline/generator.js +40 -104
- package/dist/src/smiths/context-pipeline/managed-hook.js +10 -0
- package/dist/src/smiths/context-pipeline/parallelism-section.js +7 -3
- package/package.json +6 -2
- package/tools/agents/deploy-agents.mjs +2 -123
- package/tools/agents/providers/antigravity.mjs +4 -6
- package/tools/agents/providers/base.mjs +3 -3
- package/tools/agents/providers/claude.mjs +3 -5
- package/tools/agents/providers/codex.mjs +3 -5
- package/tools/agents/providers/context-write.mjs +12 -0
- package/tools/agents/providers/copilot.mjs +3 -5
- package/tools/agents/providers/cursor.mjs +3 -5
- package/tools/agents/providers/factory.mjs +3 -5
- package/tools/agents/providers/grok-build.mjs +17 -12
- package/tools/agents/providers/hermes-skill-lifecycle.mjs +144 -0
- package/tools/agents/providers/hermes-startup.mjs +209 -0
- package/tools/agents/providers/hermes.mjs +9 -359
- package/tools/agents/providers/model-wrapper.mjs +90 -0
- package/tools/agents/providers/muse.mjs +3 -3
- package/tools/agents/providers/omp.mjs +3 -1
- package/tools/agents/providers/openclaw.mjs +3 -5
- package/tools/agents/providers/opencode.mjs +3 -5
- package/tools/agents/providers/pi.mjs +1 -1
- package/tools/agents/providers/provider-paths-staging.mjs +9 -0
- package/tools/agents/providers/rule-delivery.mjs +26 -228
- package/tools/agents/providers/rule-presentation.mjs +13 -4
- package/tools/agents/providers/rule-projection.mjs +119 -0
- package/tools/agents/providers/rule-startup.mjs +70 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +128 -0
- package/tools/agents/providers/warp.mjs +5 -7
- package/tools/agents/providers/windsurf.mjs +14 -62
- package/tools/plugin/package-plugins.mjs +2 -2
- package/tools/plugin/plugin-links.mjs +3 -0
- package/tools/skills/codex-skill-transform.mjs +232 -0
- package/tools/skills/deploy-skills-codex.mjs +8 -249
- package/tools/warp/warp-content.mjs +548 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { evaluateUpstreamCeiling, integrityProblems } from '../../gates/upstream-ceiling.js';
|
|
2
|
+
import { assertDecisionCeiling, GATE_RANK, GateDecisionUpgradeError } from '../../gates/lattice.js';
|
|
2
3
|
import { createHash } from 'node:crypto';
|
|
3
4
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
5
|
import { dirname, resolve } from 'node:path';
|
|
@@ -297,26 +298,7 @@ export function validateEnsembleAggregate(value) {
|
|
|
297
298
|
}
|
|
298
299
|
/** D17 findings derived from the carried #2037/#2048 integrity fields alone. */
|
|
299
300
|
export function integrityMetadataFindings(integrity, minimumPairs) {
|
|
300
|
-
|
|
301
|
-
if (integrity.integrity_state !== 'verified')
|
|
302
|
-
findings.push('integrity-not-verified');
|
|
303
|
-
if (integrity.integrity_mode === 'standard')
|
|
304
|
-
findings.push('integrity-mode-standard');
|
|
305
|
-
if (integrity.trusted_score_source === 'local-unverified')
|
|
306
|
-
findings.push('untrusted-score-source');
|
|
307
|
-
if (integrity.fresh_workspace_required && !integrity.fresh_workspace_verified)
|
|
308
|
-
findings.push('fresh-workspace-unverified');
|
|
309
|
-
if (integrity.uncertainty === null)
|
|
310
|
-
findings.push('uncertainty-missing');
|
|
311
|
-
if (integrity.paired_baseline === null)
|
|
312
|
-
findings.push('paired-baseline-missing');
|
|
313
|
-
if (integrity.weak_signal_reason !== null)
|
|
314
|
-
findings.push('weak-signal');
|
|
315
|
-
if (integrity.compromise_labels.length > 0)
|
|
316
|
-
findings.push('compromised');
|
|
317
|
-
if (integrity.sample_n < minimumPairs)
|
|
318
|
-
findings.push('insufficient-samples');
|
|
319
|
-
return findings;
|
|
301
|
+
return integrityProblems(integrity, 'ensemble', minimumPairs);
|
|
320
302
|
}
|
|
321
303
|
/** The finding for one paired delta against its preregistered threshold, or null when it passes. */
|
|
322
304
|
export function pairedDeltaFinding(threshold, item) {
|
|
@@ -332,9 +314,7 @@ export function pairedDeltaFinding(threshold, item) {
|
|
|
332
314
|
}
|
|
333
315
|
/** Upstream ROLLBACK or any compromise gives ROLLBACK; upstream HOLD or any finding gives HOLD. */
|
|
334
316
|
export function ensembleIntegrityDecision(integrity, findingCount) {
|
|
335
|
-
|
|
336
|
-
const compromised = integrity.integrity_state === 'compromised' || integrity.compromise_labels.length > 0;
|
|
337
|
-
return ceilingDecision(upstream, compromised ? 'ROLLBACK' : 'PROMOTE', findingCount > 0 ? 'HOLD' : 'PROMOTE');
|
|
317
|
+
return evaluateUpstreamCeiling(integrity, { policy: 'upstream', findings: findingCount }).ceiling;
|
|
338
318
|
}
|
|
339
319
|
/** A D17 report may keep or tighten the upstream #2037/#2048 decision, never loosen it. Every
|
|
340
320
|
* finding, passed flag and the decision are recomputed from the carried integrity fields and the
|
|
@@ -408,7 +408,7 @@ export async function scoreHeldoutStudy(input) {
|
|
|
408
408
|
const approvedCalibration = structuredClone(approval.calibration);
|
|
409
409
|
const calibrated = approvedCalibration.mode === 'uncalibrated-diagnostic'
|
|
410
410
|
|| approvedCalibration.mode === 'staged' && approvedCalibration.phase === 'calibration' ? false : null;
|
|
411
|
-
const diagnostics = await input.module.score({ corpus: { ...corpus, rows }, preregistration, attempts, gold: input.gold,
|
|
411
|
+
const diagnostics = await input.module.score({ frozen, corpus: { ...corpus, rows }, preregistration, attempts, gold: input.gold,
|
|
412
412
|
integrity: structuredClone(input.integrity), approvedCalibration: structuredClone(approvedCalibration), calibrated });
|
|
413
413
|
if (calibrated === false && (!diagnostics || typeof diagnostics !== 'object'
|
|
414
414
|
|| diagnostics.calibrated !== false
|
|
@@ -1,59 +1,7 @@
|
|
|
1
1
|
import { ceilingDecision } from '../../gates/lattice.js';
|
|
2
2
|
import { canonicalSha256, matchEvidenceDigest } from '../../gates/stats/index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Mirrors tools/eval buildIntegrityMetadata: each strict mode maps to exactly one source.
|
|
6
|
-
*/
|
|
7
|
-
export const VERIFIED_QUALIFICATION_INTEGRITY_SOURCES = Object.freeze({
|
|
8
|
-
fresh: 'fresh-workspace',
|
|
9
|
-
locked: 'locked-artifact-snapshot',
|
|
10
|
-
'full-locked': 'full-locked-workspace',
|
|
11
|
-
});
|
|
12
|
-
/**
|
|
13
|
-
* Allowlist check for promotable integrity metadata. Any malformed, unknown or
|
|
14
|
-
* unverified mode/state/score-source is a problem; an empty result is the only
|
|
15
|
-
* state that may PROMOTE. Callers still honour upstream HOLD/ROLLBACK separately.
|
|
16
|
-
*/
|
|
17
|
-
export function qualificationIntegrityAllowlistProblems(integrity) {
|
|
18
|
-
const value = integrity;
|
|
19
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)
|
|
20
|
-
|| !Number.isSafeInteger(value.sample_n) || value.sample_n < 0
|
|
21
|
-
|| typeof value.integrity_mode !== 'string' || typeof value.integrity_state !== 'string'
|
|
22
|
-
|| typeof value.trusted_score_source !== 'string'
|
|
23
|
-
|| typeof value.fresh_workspace_required !== 'boolean' || typeof value.fresh_workspace_verified !== 'boolean'
|
|
24
|
-
|| !Array.isArray(value.compromise_labels) || value.compromise_labels.some(label => typeof label !== 'string')
|
|
25
|
-
|| !(value.weak_signal_reason === null || typeof value.weak_signal_reason === 'string')
|
|
26
|
-
|| !('uncertainty' in value) || !('paired_baseline' in value)
|
|
27
|
-
|| !value.release_gate || typeof value.release_gate !== 'object'
|
|
28
|
-
|| !['PROMOTE', 'HOLD', 'ROLLBACK'].includes(value.release_gate.decision)
|
|
29
|
-
|| !Array.isArray(value.release_gate.reasons)) {
|
|
30
|
-
return ['integrity-invalid'];
|
|
31
|
-
}
|
|
32
|
-
const problems = [];
|
|
33
|
-
const expectedSource = Object.hasOwn(VERIFIED_QUALIFICATION_INTEGRITY_SOURCES, value.integrity_mode)
|
|
34
|
-
? VERIFIED_QUALIFICATION_INTEGRITY_SOURCES[value.integrity_mode] : undefined;
|
|
35
|
-
if (value.integrity_state !== 'verified')
|
|
36
|
-
problems.push('integrity-not-verified');
|
|
37
|
-
if (expectedSource === undefined)
|
|
38
|
-
problems.push('integrity-mode-not-allowlisted');
|
|
39
|
-
else if (value.trusted_score_source !== expectedSource)
|
|
40
|
-
problems.push('untrusted-score-source');
|
|
41
|
-
if (value.fresh_workspace_required && !value.fresh_workspace_verified)
|
|
42
|
-
problems.push('fresh-workspace-unverified');
|
|
43
|
-
if (value.uncertainty === null || value.uncertainty === undefined)
|
|
44
|
-
problems.push('uncertainty-missing');
|
|
45
|
-
if (value.paired_baseline === null || value.paired_baseline === undefined)
|
|
46
|
-
problems.push('paired-baseline-missing');
|
|
47
|
-
if (value.weak_signal_reason !== null)
|
|
48
|
-
problems.push('weak-signal');
|
|
49
|
-
if (value.compromise_labels.length > 0)
|
|
50
|
-
problems.push('compromised');
|
|
51
|
-
if (value.sample_n <= 0)
|
|
52
|
-
problems.push('insufficient-samples');
|
|
53
|
-
if (value.release_gate.decision !== 'PROMOTE')
|
|
54
|
-
problems.push(`upstream-integrity-${value.release_gate.decision.toLowerCase()}`);
|
|
55
|
-
return problems;
|
|
56
|
-
}
|
|
3
|
+
export { VERIFIED_QUALIFICATION_INTEGRITY_SOURCES, qualificationIntegrityAllowlistProblems, } from '../../gates/upstream-ceiling.js';
|
|
4
|
+
import { evaluateUpstreamCeiling } from '../../gates/upstream-ceiling.js';
|
|
57
5
|
/** D30 compile/prefix cache, D03 receipt replay and D15 result cache evidence, each a verified evidence manifest. */
|
|
58
6
|
export const QUALIFICATION_CACHE_LAYERS = ['compilePrefixCache', 'receiptReplay', 'resultCache'];
|
|
59
7
|
const REQUIRED_PINS = [
|
|
@@ -111,15 +59,10 @@ export function buildQualificationReleaseRecord(executed, input) {
|
|
|
111
59
|
const suites = manifest.evidence.map(item => ({
|
|
112
60
|
caseId: item.caseId, outcome: item.outcome, evidenceHash: item.digest, verified: verified.get(item.caseId) === true,
|
|
113
61
|
})).sort((a, b) => a.caseId.localeCompare(b.caseId));
|
|
114
|
-
const
|
|
62
|
+
const integrityGate = evaluateUpstreamCeiling(input.integrity, { policy: 'qualification-release' });
|
|
115
63
|
const withinBudgets = Object.entries(input.budgets).length > 0
|
|
116
64
|
&& Object.keys(input.actuals).length === Object.keys(input.budgets).length
|
|
117
65
|
&& Object.entries(input.budgets).every(([name, limit]) => input.actuals[name] !== undefined && input.actuals[name] <= limit);
|
|
118
|
-
const integrityVerified = input.integrity.integrity_state === 'verified'
|
|
119
|
-
&& input.integrity.integrity_mode !== 'standard'
|
|
120
|
-
&& input.integrity.trusted_score_source !== 'local-unverified'
|
|
121
|
-
&& input.integrity.compromise_labels.length === 0
|
|
122
|
-
&& input.integrity.sample_n > 0 && input.integrity.uncertainty !== null;
|
|
123
66
|
const benchmark = input.benchmark;
|
|
124
67
|
const benchmarkVerified = benchmark !== undefined && benchmark.decision === 'pass'
|
|
125
68
|
&& /^sha256:[0-9a-f]{64}$/.test(benchmark.planDigest)
|
|
@@ -130,11 +73,11 @@ export function buildQualificationReleaseRecord(executed, input) {
|
|
|
130
73
|
const snapshotVerified = snapshot !== undefined && /^sha256:[0-9a-f]{64}$/.test(snapshot.digest)
|
|
131
74
|
&& Number.isSafeInteger(snapshot.artifactCount) && snapshot.artifactCount > 0;
|
|
132
75
|
const metricsRecorded = input.metrics !== undefined && input.metrics.overall.sampleN > 0;
|
|
133
|
-
const complete = withinBudgets &&
|
|
76
|
+
const complete = withinBudgets && benchmarkVerified && snapshotVerified && metricsRecorded && !manifest.dirty && input.reviewer !== null && input.reviewer.trim().length > 0
|
|
134
77
|
&& suites.length === manifest.cases.length && suites.every(item => item.outcome === 'pass' && item.verified)
|
|
135
78
|
&& report.gates.length === 7 && report.gates.every(gate => gate.status === 'pass')
|
|
136
79
|
&& report.decision === 'PROMOTE';
|
|
137
|
-
const decision = ceilingDecision(
|
|
80
|
+
const decision = ceilingDecision(integrityGate.ceiling, report.decision, complete ? 'PROMOTE' : 'HOLD');
|
|
138
81
|
const fields = {
|
|
139
82
|
schemaVersion: 'decision-qualification-release/v2',
|
|
140
83
|
runId: manifest.runId, sourceCommit: manifest.sourceCommit, dirty: manifest.dirty,
|
|
@@ -272,12 +272,19 @@ export function zodErrorToValidationErrors(err, manifestPath, input) {
|
|
|
272
272
|
&& issue.path.length === 3 && issue.path[0] === 'providerConfig'
|
|
273
273
|
&& issue.path[1] === 'capabilities'
|
|
274
274
|
&& ['nativeFeatures', 'emulation'].includes(String(issue.path[2]))) {
|
|
275
|
-
return issue.keys.map(key => ({ ...issue, path: [...issue.path, key] }));
|
|
275
|
+
return issue.keys.map(key => ({ ...issue, path: [...issue.path, key], keys: [key] }));
|
|
276
276
|
}
|
|
277
277
|
return [issue];
|
|
278
278
|
});
|
|
279
279
|
return issues.map((issue) => {
|
|
280
280
|
let actual = 'invalid';
|
|
281
|
+
if (issue.code === 'unrecognized_keys') {
|
|
282
|
+
// Name each rejected key so doctor/use output identifies the culprit
|
|
283
|
+
// (#3724: a typo'd or unknown platform key must not vanish into
|
|
284
|
+
// a bare "invalid").
|
|
285
|
+
const keys = issue.keys.map((key) => `"${String(key)}"`).join(', ');
|
|
286
|
+
actual = `unknown key(s): ${keys}`;
|
|
287
|
+
}
|
|
281
288
|
if (issue.code === 'invalid_type' && hasInput) {
|
|
282
289
|
let value = input;
|
|
283
290
|
for (const segment of issue.path) {
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
* @implements #1037
|
|
14
14
|
*/
|
|
15
15
|
import { join } from 'path';
|
|
16
|
+
import { readFile, readdir } from 'fs/promises';
|
|
16
17
|
import { discoverProjectLocalBundles } from './project-local-discovery.js';
|
|
18
|
+
import { parseRuleFrontmatter, formatRuleFrontmatterError } from '../rules/activation.mjs';
|
|
17
19
|
import { buildUpstreamRegistry } from './upstream-registry.js';
|
|
18
20
|
import { resolveShadows } from './shadow-resolver.js';
|
|
19
21
|
import { checkBundleManifestIgnored } from './project-local-gitignore.js';
|
|
@@ -48,6 +50,56 @@ const TYPE_DIR = {
|
|
|
48
50
|
plugin: 'plugins',
|
|
49
51
|
provider: 'providers',
|
|
50
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Rule files `aiwg use` validates at deploy time via the shared frontmatter
|
|
55
|
+
* contract (`parseRuleFrontmatter` in `src/rules/activation.mjs`, #3728).
|
|
56
|
+
* Mirrors deploy's selection for a bundle source root: top-level `rules/`
|
|
57
|
+
* markdown (minus deploy's excluded/generated names) plus every
|
|
58
|
+
* `BEHAVIOR.md` under `behaviors/`.
|
|
59
|
+
*/
|
|
60
|
+
const RULE_MD_EXCLUDED = new Set([
|
|
61
|
+
'README.md', 'manifest.md', 'agent-template.md', 'openai-compat.md',
|
|
62
|
+
'factory-compat.md', 'windsurf-compat.md', 'DEVELOPMENT_GUIDE.md',
|
|
63
|
+
]);
|
|
64
|
+
async function collectBundleRuleFiles(artifactPath) {
|
|
65
|
+
const files = [];
|
|
66
|
+
try {
|
|
67
|
+
const entries = await readdir(join(artifactPath, 'rules'), { withFileTypes: true });
|
|
68
|
+
for (const entry of entries) {
|
|
69
|
+
if (!entry.isFile() || !entry.name.toLowerCase().endsWith('.md'))
|
|
70
|
+
continue;
|
|
71
|
+
if (RULE_MD_EXCLUDED.has(entry.name))
|
|
72
|
+
continue;
|
|
73
|
+
const lower = entry.name.toLowerCase();
|
|
74
|
+
if (lower.endsWith('.soul.md') || lower.endsWith('.core.md'))
|
|
75
|
+
continue;
|
|
76
|
+
if (/^(RULES-INDEX|RULES-ONDEMAND)\.(md|mdc)$/.test(entry.name))
|
|
77
|
+
continue;
|
|
78
|
+
files.push(join(artifactPath, 'rules', entry.name));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Absent rules dir — nothing to validate.
|
|
83
|
+
}
|
|
84
|
+
const walkBehaviors = async (dir) => {
|
|
85
|
+
let entries;
|
|
86
|
+
try {
|
|
87
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
for (const entry of entries) {
|
|
93
|
+
const full = join(dir, entry.name);
|
|
94
|
+
if (entry.isDirectory())
|
|
95
|
+
await walkBehaviors(full);
|
|
96
|
+
else if (entry.isFile() && entry.name === 'BEHAVIOR.md')
|
|
97
|
+
files.push(full);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
await walkBehaviors(join(artifactPath, 'behaviors'));
|
|
101
|
+
return files;
|
|
102
|
+
}
|
|
51
103
|
export async function buildProjectLocalDoctorSection(opts) {
|
|
52
104
|
const { projectDir, frameworkRoot, config, quiet = false } = opts;
|
|
53
105
|
const discovery = await discoverProjectLocalBundles(projectDir);
|
|
@@ -87,8 +139,27 @@ export async function buildProjectLocalDoctorSection(opts) {
|
|
|
87
139
|
lines.push('');
|
|
88
140
|
}
|
|
89
141
|
}
|
|
142
|
+
// Rule frontmatter validation (#3728): the same validator `aiwg use`
|
|
143
|
+
// applies at deploy time, so a bundle that would fail deployment is
|
|
144
|
+
// flagged here instead of passing with a clean bill of health.
|
|
145
|
+
const ruleErrors = [];
|
|
146
|
+
for (const bundle of discovery.bundles) {
|
|
147
|
+
for (const file of await collectBundleRuleFiles(bundle.artifactPath)) {
|
|
148
|
+
let content;
|
|
149
|
+
try {
|
|
150
|
+
content = await readFile(file, 'utf-8');
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const parsed = parseRuleFrontmatter(content);
|
|
156
|
+
if (!parsed.valid) {
|
|
157
|
+
ruleErrors.push(formatRuleFrontmatterError(projectRelativePathIfInside(projectDir, file) ?? file, parsed.data, parsed.diagnostics));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
90
161
|
// Validation
|
|
91
|
-
const validationErrors = discovery.errors.length + quickrefErrors.length;
|
|
162
|
+
const validationErrors = discovery.errors.length + quickrefErrors.length + ruleErrors.length;
|
|
92
163
|
if (validationErrors === 0) {
|
|
93
164
|
if (!quiet)
|
|
94
165
|
lines.push(` Validation: ✓ all manifests${quickrefAudit.exists ? ' and project quickref source' : ''} valid`);
|
|
@@ -98,7 +169,12 @@ export async function buildProjectLocalDoctorSection(opts) {
|
|
|
98
169
|
for (const e of discovery.errors.slice(0, 10)) {
|
|
99
170
|
lines.push(` ✗ ${e.path}: ${e.field} — ${e.actual}`);
|
|
100
171
|
}
|
|
101
|
-
|
|
172
|
+
const quickrefShown = quickrefErrors.slice(0, Math.max(0, 10 - discovery.errors.length));
|
|
173
|
+
for (const error of quickrefShown) {
|
|
174
|
+
lines.push(` ✗ ${error}`);
|
|
175
|
+
}
|
|
176
|
+
const ruleShown = ruleErrors.slice(0, Math.max(0, 10 - discovery.errors.length - quickrefShown.length));
|
|
177
|
+
for (const error of ruleShown) {
|
|
102
178
|
lines.push(` ✗ ${error}`);
|
|
103
179
|
}
|
|
104
180
|
if (validationErrors > 10) {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { z } from 'zod';
|
|
13
13
|
import { integer, dateTime, url, number } from '../schema/zod-validation.mjs';
|
|
14
|
+
import { PROVIDER_IDS } from '../providers/provider-definitions.js';
|
|
14
15
|
// ============================================
|
|
15
16
|
// Core Enums & Primitives
|
|
16
17
|
// ============================================
|
|
@@ -68,17 +69,15 @@ export const HookEventSchema = z.enum([
|
|
|
68
69
|
// ============================================
|
|
69
70
|
/**
|
|
70
71
|
* Platform compatibility matrix
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
generic: PlatformSupportSchema.optional(),
|
|
81
|
-
}).refine((data) => Object.values(data).some((val) => val !== undefined), { error: 'At least one platform must be specified' });
|
|
72
|
+
*
|
|
73
|
+
* Keys are derived from the provider registry (`PROVIDER_IDS` in
|
|
74
|
+
* `src/providers/provider-definitions.ts`), the single source of truth for
|
|
75
|
+
* provider ids — so every registered provider (pi, hermes, …) is accepted.
|
|
76
|
+
* Strict: an unknown platform key is a validation error, never silently
|
|
77
|
+
* stripped (#3724).
|
|
78
|
+
*/
|
|
79
|
+
const platformCompatibilityShape = Object.fromEntries(PROVIDER_IDS.map((id) => [id, PlatformSupportSchema.optional()]));
|
|
80
|
+
export const PlatformCompatibilitySchema = z.strictObject(platformCompatibilityShape).refine((data) => Object.values(data).some((val) => val !== undefined), { error: 'At least one platform must be specified' });
|
|
82
81
|
/**
|
|
83
82
|
* Deployment configuration
|
|
84
83
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ceilingDecision, maxOutcome } from './lattice.js';
|
|
2
|
-
import {
|
|
2
|
+
import { evaluateUpstreamCeiling } from './upstream-ceiling.js';
|
|
3
3
|
import { artifactDigest } from '../decision/validate.js';
|
|
4
4
|
import { evaluatePredicate } from '../decision/predicates.js';
|
|
5
5
|
import { clopperPearsonInterval } from './stats/clopper-pearson.js';
|
|
@@ -37,8 +37,8 @@ export function sealUpstream(metadata) {
|
|
|
37
37
|
* `frozen.digest === heldoutDigest(frozen.bundle)`): a spread-copied or edited
|
|
38
38
|
* record is refused. The seal is an unkeyed integrity digest, not an
|
|
39
39
|
* authenticity proof, so the holdout inputs are trusted caller inputs built from
|
|
40
|
-
* verified HeldoutFrozen and access records
|
|
41
|
-
*
|
|
40
|
+
* verified HeldoutFrozen and access records via `sealGateHoldoutFromFrozen`
|
|
41
|
+
* in `./heldout.js`. `frozenDigest` is the binding digest pinned by that record.
|
|
42
42
|
*/
|
|
43
43
|
export function sealGateHoldout(input) {
|
|
44
44
|
const payload = { frozenDigest: input.frozenDigest, firstAccessedAt: input.firstAccessedAt };
|
|
@@ -387,13 +387,10 @@ function evaluateObservation(gate, observation, context) {
|
|
|
387
387
|
if (upstream === null)
|
|
388
388
|
return { ...base, status: 'insufficient', reason: 'upstream-missing',
|
|
389
389
|
statistic: { method: 'upstream-integrity' } };
|
|
390
|
-
const problems =
|
|
390
|
+
const { problems, compromised } = evaluateUpstreamCeiling(upstream.metadata);
|
|
391
391
|
if (!problems.length) {
|
|
392
392
|
return { ...base, status: 'pass', reason: 'upstream-clean', statistic: { method: 'upstream-integrity' } };
|
|
393
393
|
}
|
|
394
|
-
const compromised = problems.includes('compromised')
|
|
395
|
-
|| upstream.metadata.release_gate?.decision === 'ROLLBACK'
|
|
396
|
-
|| upstream.metadata.integrity_state === 'compromised';
|
|
397
394
|
return { ...base, status: 'fail', reason: compromised ? 'upstream-compromised' : 'upstream-allowlist',
|
|
398
395
|
statistic: { method: 'upstream-integrity' } };
|
|
399
396
|
}
|
|
@@ -437,14 +434,7 @@ function rerunProviderOrFail(provider, args, providerId) {
|
|
|
437
434
|
}
|
|
438
435
|
}
|
|
439
436
|
function upstreamOutcome(upstream) {
|
|
440
|
-
|
|
441
|
-
return { ceiling: 'HOLD', problems: ['upstream-ceiling-missing'] };
|
|
442
|
-
const problems = qualificationIntegrityAllowlistProblems(upstream.metadata);
|
|
443
|
-
const release = upstream.metadata.release_gate?.decision;
|
|
444
|
-
const compromised = problems.includes('compromised')
|
|
445
|
-
|| release === 'ROLLBACK'
|
|
446
|
-
|| upstream.metadata.integrity_state === 'compromised';
|
|
447
|
-
return { ceiling: ceilingDecision(release ?? 'HOLD', compromised ? 'ROLLBACK' : 'PROMOTE', problems.length ? 'HOLD' : 'PROMOTE'), problems };
|
|
437
|
+
return evaluateUpstreamCeiling(upstream?.metadata ?? null);
|
|
448
438
|
}
|
|
449
439
|
/**
|
|
450
440
|
* Pure, deterministic gate evaluation. The binding is resolved internally
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Verify the frozen bundle, its pinned analysis and the independently anchored first-access record.
|
|
2
|
+
import { heldoutDigest } from '../decision/heldout/contract.js';
|
|
3
|
+
import { artifactDigest } from '../decision/validate.js';
|
|
4
|
+
import { evaluateGates, GateEvaluationError, sealGateHoldout } from './evaluate.js';
|
|
5
|
+
/**
|
|
6
|
+
* Derive gate inputs from HeldoutFrozen without altering its historical bytes.
|
|
7
|
+
* The existing bundle contains only corpus, preregistration and approval, so
|
|
8
|
+
* its studyAnalysisDigest must first verify the supplied analysis containing
|
|
9
|
+
* the binding. The access record pins that same analysis (and hence binding).
|
|
10
|
+
* Its timestamp is covered by the independently trusted access digest.
|
|
11
|
+
* Neither an unkeyed digest nor the access record alone authenticates a clock:
|
|
12
|
+
* D29 access/v1 has no signature or frozen-bundle digest. The host must retain
|
|
13
|
+
* the access anchor independently, just as for the existing D29 scorer.
|
|
14
|
+
*/
|
|
15
|
+
export function sealGateHoldoutFromFrozen(input) {
|
|
16
|
+
const { frozen, analysis, access, trustedAccessDigest } = input;
|
|
17
|
+
if (!frozen?.bundle || frozen.digest !== heldoutDigest(frozen.bundle)) {
|
|
18
|
+
throw new GateEvaluationError('frozen bundle digest does not match its content');
|
|
19
|
+
}
|
|
20
|
+
const analysisDigest = frozen.bundle.preregistration?.studyAnalysisDigest;
|
|
21
|
+
if (!analysis?.gateBinding || heldoutDigest(analysis) !== analysisDigest) {
|
|
22
|
+
throw new GateEvaluationError('analysis digest does not match the frozen record');
|
|
23
|
+
}
|
|
24
|
+
if (!access || typeof trustedAccessDigest !== 'string'
|
|
25
|
+
|| heldoutDigest(access) !== trustedAccessDigest) {
|
|
26
|
+
throw new GateEvaluationError('first-access digest does not match its trusted pin');
|
|
27
|
+
}
|
|
28
|
+
if (access.analysisDigest !== analysisDigest) {
|
|
29
|
+
throw new GateEvaluationError('first-access record does not belong to the frozen analysis and binding');
|
|
30
|
+
}
|
|
31
|
+
if (typeof access.firstTestAccessAt !== 'string' || !Number.isFinite(Date.parse(access.firstTestAccessAt))) {
|
|
32
|
+
throw new GateEvaluationError('first-access timestamp is not a valid date-time');
|
|
33
|
+
}
|
|
34
|
+
const trustedBindingDigest = artifactDigest(analysis.gateBinding);
|
|
35
|
+
return { trustedBindingDigest,
|
|
36
|
+
holdout: sealGateHoldout({ frozenDigest: trustedBindingDigest, firstAccessedAt: access.firstTestAccessAt }) };
|
|
37
|
+
}
|
|
38
|
+
/** Evaluate with a binding pin and holdout seal derived exclusively from the verified records. */
|
|
39
|
+
export function evaluateGatesFromHeldoutFrozen(input) {
|
|
40
|
+
return evaluateGates({ ...input, ...sealGateHoldoutFromFrozen(input) });
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=heldout.js.map
|
package/dist/src/gates/index.js
CHANGED
|
@@ -6,7 +6,8 @@ export { GATES_API_VERSION, qualifyGateParameter } from './types.js';
|
|
|
6
6
|
export { GateSchemaError, validateGateDocument } from './schema.js';
|
|
7
7
|
export { GateRegistryError, GATE_NAMESPACES, splitPackId, validateResolvedPack, resolveThresholdDefault, assertGateTightens, applyGateExtends, composeGatePack, resolveGateBinding, expandFloorPacks, enforceProjectFloors, authoredGatePacksOf, gateProvidersOf, GateRegistry, } from './registry.js';
|
|
8
8
|
export { INTEGRITY_CEILING_FLOOR_PACK_ID, INTEGRITY_CEILING_FLOOR_PACK_VERSION, assertCeilingDefaults, projectCeilingSatisfied, resolveProjectFloors, validateGatesConfig, } from './floors.js';
|
|
9
|
-
export { GateEvaluationError, maxOutcome, gateStatusOutcome, sealUpstream,
|
|
9
|
+
export { GateEvaluationError, maxOutcome, gateStatusOutcome, sealUpstream, evaluateGates, } from './evaluate.js';
|
|
10
|
+
export { sealGateHoldoutFromFrozen, evaluateGatesFromHeldoutFrozen } from './heldout.js';
|
|
10
11
|
export { assertGateReportDecision, validateGateReport } from './report.js';
|
|
11
12
|
export { createCoreProviderRegistry, evidenceProvider, pairedProvider, proportionProvider, scalarProvider, screeningProvider } from './providers/index.js';
|
|
12
13
|
export { MetricProviderRegistry } from './providers/index.js';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Shared upstream-ceiling evaluation with explicit policies for retained report contracts.
|
|
2
|
+
import { ceilingDecision } from './lattice.js';
|
|
3
|
+
/**
|
|
4
|
+
* #2037/#2048 integrity modes whose verified state has a trusted score source.
|
|
5
|
+
* Mirrors tools/eval buildIntegrityMetadata: each strict mode maps to exactly one source.
|
|
6
|
+
*/
|
|
7
|
+
export const VERIFIED_QUALIFICATION_INTEGRITY_SOURCES = Object.freeze({
|
|
8
|
+
fresh: 'fresh-workspace',
|
|
9
|
+
locked: 'locked-artifact-snapshot',
|
|
10
|
+
'full-locked': 'full-locked-workspace',
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Allowlist check for promotable integrity metadata. Any malformed, unknown or
|
|
14
|
+
* unverified mode/state/score-source is a problem; an empty result is the only
|
|
15
|
+
* state that may PROMOTE. Callers still honour upstream HOLD/ROLLBACK separately.
|
|
16
|
+
*/
|
|
17
|
+
export function qualificationIntegrityAllowlistProblems(integrity) {
|
|
18
|
+
const value = integrity;
|
|
19
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)
|
|
20
|
+
|| !Number.isSafeInteger(value.sample_n) || value.sample_n < 0
|
|
21
|
+
|| typeof value.integrity_mode !== 'string' || typeof value.integrity_state !== 'string'
|
|
22
|
+
|| typeof value.trusted_score_source !== 'string'
|
|
23
|
+
|| typeof value.fresh_workspace_required !== 'boolean' || typeof value.fresh_workspace_verified !== 'boolean'
|
|
24
|
+
|| !Array.isArray(value.compromise_labels) || value.compromise_labels.some(label => typeof label !== 'string')
|
|
25
|
+
|| !(value.weak_signal_reason === null || typeof value.weak_signal_reason === 'string')
|
|
26
|
+
|| !('uncertainty' in value) || !('paired_baseline' in value)
|
|
27
|
+
|| !value.release_gate || typeof value.release_gate !== 'object'
|
|
28
|
+
|| !['PROMOTE', 'HOLD', 'ROLLBACK'].includes(value.release_gate.decision)
|
|
29
|
+
|| !Array.isArray(value.release_gate.reasons)) {
|
|
30
|
+
return ['integrity-invalid'];
|
|
31
|
+
}
|
|
32
|
+
const problems = [];
|
|
33
|
+
const expectedSource = Object.hasOwn(VERIFIED_QUALIFICATION_INTEGRITY_SOURCES, value.integrity_mode)
|
|
34
|
+
? VERIFIED_QUALIFICATION_INTEGRITY_SOURCES[value.integrity_mode] : undefined;
|
|
35
|
+
if (value.integrity_state !== 'verified')
|
|
36
|
+
problems.push('integrity-not-verified');
|
|
37
|
+
if (expectedSource === undefined)
|
|
38
|
+
problems.push('integrity-mode-not-allowlisted');
|
|
39
|
+
else if (value.trusted_score_source !== expectedSource)
|
|
40
|
+
problems.push('untrusted-score-source');
|
|
41
|
+
if (value.fresh_workspace_required && !value.fresh_workspace_verified)
|
|
42
|
+
problems.push('fresh-workspace-unverified');
|
|
43
|
+
if (value.uncertainty === null || value.uncertainty === undefined)
|
|
44
|
+
problems.push('uncertainty-missing');
|
|
45
|
+
if (value.paired_baseline === null || value.paired_baseline === undefined)
|
|
46
|
+
problems.push('paired-baseline-missing');
|
|
47
|
+
if (value.weak_signal_reason !== null)
|
|
48
|
+
problems.push('weak-signal');
|
|
49
|
+
if (value.compromise_labels.length > 0)
|
|
50
|
+
problems.push('compromised');
|
|
51
|
+
if (value.sample_n <= 0)
|
|
52
|
+
problems.push('insufficient-samples');
|
|
53
|
+
if (value.release_gate.decision !== 'PROMOTE')
|
|
54
|
+
problems.push(`upstream-integrity-${value.release_gate.decision.toLowerCase()}`);
|
|
55
|
+
return problems;
|
|
56
|
+
}
|
|
57
|
+
export function integrityProblems(integrity, policy = 'allowlist', minimumSamples = 1) {
|
|
58
|
+
if (policy === 'allowlist')
|
|
59
|
+
return qualificationIntegrityAllowlistProblems(integrity);
|
|
60
|
+
if (policy === 'upstream')
|
|
61
|
+
return [];
|
|
62
|
+
const problems = [];
|
|
63
|
+
if (integrity.integrity_state !== 'verified')
|
|
64
|
+
problems.push('integrity-not-verified');
|
|
65
|
+
if (policy === 'context-pruning') {
|
|
66
|
+
if (integrity.release_gate.decision === 'ROLLBACK')
|
|
67
|
+
problems.push('upstream-rollback');
|
|
68
|
+
if (integrity.release_gate.decision === 'HOLD')
|
|
69
|
+
problems.push('upstream-hold');
|
|
70
|
+
return problems;
|
|
71
|
+
}
|
|
72
|
+
if (integrity.integrity_mode === 'standard')
|
|
73
|
+
problems.push('integrity-mode-standard');
|
|
74
|
+
if (integrity.trusted_score_source === 'local-unverified')
|
|
75
|
+
problems.push('untrusted-score-source');
|
|
76
|
+
if (policy === 'ensemble' && integrity.fresh_workspace_required && !integrity.fresh_workspace_verified) {
|
|
77
|
+
problems.push('fresh-workspace-unverified');
|
|
78
|
+
}
|
|
79
|
+
if (integrity.uncertainty === null)
|
|
80
|
+
problems.push('uncertainty-missing');
|
|
81
|
+
if (policy === 'ensemble' && integrity.paired_baseline === null)
|
|
82
|
+
problems.push('paired-baseline-missing');
|
|
83
|
+
if (policy === 'ensemble' && integrity.weak_signal_reason !== null)
|
|
84
|
+
problems.push('weak-signal');
|
|
85
|
+
if (integrity.compromise_labels.length > 0)
|
|
86
|
+
problems.push('compromised');
|
|
87
|
+
if (policy === 'qualification-release' ? !(integrity.sample_n > 0) : integrity.sample_n < minimumSamples) {
|
|
88
|
+
problems.push('insufficient-samples');
|
|
89
|
+
}
|
|
90
|
+
return problems;
|
|
91
|
+
}
|
|
92
|
+
/** Evaluate the same upstream-ceiling primitive used by the integrity-ceiling pack.
|
|
93
|
+
* Callers validate/seal evidence before evaluation. Legacy policies preserve their
|
|
94
|
+
* versioned report semantics, including context pruning's verified-state-only check.
|
|
95
|
+
*/
|
|
96
|
+
export function evaluateUpstreamCeiling(integrity, options = {}) {
|
|
97
|
+
if (integrity === null)
|
|
98
|
+
return { ceiling: 'HOLD', problems: ['upstream-ceiling-missing'], compromised: false };
|
|
99
|
+
const policy = options.policy ?? 'allowlist';
|
|
100
|
+
const problems = integrityProblems(integrity, policy, options.minimumSamples);
|
|
101
|
+
const release = integrity?.release_gate?.decision;
|
|
102
|
+
const hasCompromiseLabels = policy === 'allowlist' ? problems.includes('compromised')
|
|
103
|
+
: (integrity?.compromise_labels?.length ?? 0) > 0;
|
|
104
|
+
const compromised = release === 'ROLLBACK' || (policy !== 'context-pruning'
|
|
105
|
+
&& (integrity?.integrity_state === 'compromised' || hasCompromiseLabels));
|
|
106
|
+
return {
|
|
107
|
+
ceiling: ceilingDecision(release ?? 'HOLD', compromised ? 'ROLLBACK' : 'PROMOTE', problems.length || (options.findings ?? 0) > 0 ? 'HOLD' : 'PROMOTE'),
|
|
108
|
+
problems, compromised,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=upstream-ceiling.js.map
|
|
@@ -2,11 +2,8 @@ import { readAiwgConfig } from '../config/aiwg-config.js';
|
|
|
2
2
|
import { normalizeProviderDefinitionId } from '../providers/provider-definitions.js';
|
|
3
3
|
import { collectProviderInventory } from '../providers/provider-inventory.js';
|
|
4
4
|
import { resolveDynamicModelCatalog } from './model-discovery.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
coding: 'aiwg-model-coding-worker',
|
|
8
|
-
efficiency: 'aiwg-model-efficiency-worker',
|
|
9
|
-
};
|
|
5
|
+
import { MODEL_WRAPPER_DEFINITIONS } from './wrapper-definitions.js';
|
|
6
|
+
export { MODEL_WRAPPERS, MODEL_WRAPPER_DEFINITIONS } from './wrapper-definitions.js';
|
|
10
7
|
async function configuredProviders(cwd) {
|
|
11
8
|
try {
|
|
12
9
|
const config = await readAiwgConfig(cwd);
|
|
@@ -48,14 +45,14 @@ export async function loadProviderModelMetadata(cwd, aiwgRoot) {
|
|
|
48
45
|
const roles = catalog.providers[provider]?.roles;
|
|
49
46
|
if (!roles)
|
|
50
47
|
continue;
|
|
51
|
-
providers[provider] =
|
|
52
|
-
.flatMap(role => {
|
|
48
|
+
providers[provider] = MODEL_WRAPPER_DEFINITIONS
|
|
49
|
+
.flatMap(({ role, name }) => {
|
|
53
50
|
const model = roles[role];
|
|
54
51
|
return model ? [{
|
|
55
52
|
provider,
|
|
56
53
|
role,
|
|
57
54
|
model: model.id,
|
|
58
|
-
wrapper:
|
|
55
|
+
wrapper: name,
|
|
59
56
|
status: model.status ?? 'unknown',
|
|
60
57
|
observed: model.observed ?? false,
|
|
61
58
|
source: catalog.discovery?.providers?.[provider]?.source
|