@aiwg/cli 2026.11.0 → 2026.11.2
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-hooks/canonical/aiwg-prompt-discovery.yaml +9 -0
- package/agentic/code/addons/aiwg-hooks/hooks/aiwg-prompt-discovery.cjs +136 -0
- package/agentic/code/providers/flue/README.md +2 -1
- package/agentic/code/providers/model-capabilities.v1.json +27 -23
- package/agentic/code/providers/model-catalog.v1.json +3 -3
- package/dist/src/artifacts/cli.js +13 -13
- package/dist/src/artifacts/discover-cli-help.js +25 -0
- package/dist/src/artifacts/discover-facets.js +2 -0
- package/dist/src/artifacts/discover-session-facets.js +15 -0
- package/dist/src/artifacts/fortemi-core-prebuilt-freshness.js +28 -0
- package/dist/src/artifacts/fortemi-core-query-adapter.js +4 -4
- package/dist/src/artifacts/fortemi-core-sync.js +3 -0
- package/dist/src/artifacts/framework-capabilities.js +11 -3
- package/dist/src/artifacts/framework-source-digest.js +1 -1
- package/dist/src/artifacts/index-builder.js +12 -13
- package/dist/src/artifacts/index-dependencies.js +72 -0
- package/dist/src/artifacts/query-engine-discover-output.js +13 -5
- package/dist/src/artifacts/query-engine-discover.js +103 -28
- package/dist/src/artifacts/query-engine-entries.js +107 -10
- package/dist/src/artifacts/query-engine-installation.js +27 -0
- package/dist/src/artifacts/query-engine-options.js +14 -1
- package/dist/src/artifacts/query-engine-rules.js +1 -2
- package/dist/src/artifacts/query-engine-scoring.js +38 -32
- package/dist/src/artifacts/query-engine-show-card.js +8 -2
- package/dist/src/artifacts/query-engine-show-load.js +1 -1
- package/dist/src/artifacts/query-engine-show.js +5 -3
- package/dist/src/artifacts/query-engine-templates.js +33 -0
- package/dist/src/artifacts/query-engine-verbose.js +25 -0
- package/dist/src/artifacts/relations-builder.js +49 -4
- package/dist/src/artifacts/relations.js +26 -10
- package/dist/src/artifacts/template-references.js +42 -0
- package/dist/src/artifacts/types.js +1 -1
- package/dist/src/cli/handlers/bundle-reconciliation.js +7 -3
- package/dist/src/cli/handlers/checkpoint-handoff.js +48 -0
- package/dist/src/cli/handlers/checkpoint-record.js +20 -0
- package/dist/src/cli/handlers/checkpoint.js +176 -0
- package/dist/src/cli/handlers/decision.js +1 -1
- package/dist/src/cli/handlers/doctor-args.js +3 -1
- package/dist/src/cli/handlers/doctor-help.js +2 -1
- package/dist/src/cli/handlers/help.js +1 -0
- package/dist/src/cli/handlers/index.js +4 -2
- package/dist/src/cli/handlers/models-resource-sample.js +7 -3
- package/dist/src/cli/handlers/ralph-launcher.js +1 -1
- package/dist/src/cli/handlers/refresh-bundles.js +2 -1
- package/dist/src/cli/handlers/refresh-managed-deployment.js +196 -0
- package/dist/src/cli/handlers/refresh.js +10 -2
- package/dist/src/cli/handlers/script-runner.js +2 -1
- package/dist/src/cli/handlers/steward-signing.js +44 -0
- package/dist/src/cli/handlers/steward.js +5 -0
- package/dist/src/cli/handlers/subcommands-discovery.js +8 -1
- package/dist/src/cli/handlers/use-provider-results.js +17 -0
- package/dist/src/cli/handlers/use.js +19 -18
- package/dist/src/cli/router.js +12 -2
- package/dist/src/cli/services/deployment-verification.js +11 -7
- package/dist/src/cli/user-scope-mirror.js +3 -1
- package/dist/src/config/aiwg-config.js +5 -1
- package/dist/src/config/cli.js +1 -0
- package/dist/src/config/delivery-validation.js +21 -0
- package/dist/src/config/host-resource-report.d.mts +1 -1
- package/dist/src/config/host-resource-report.mjs +23 -4
- package/dist/src/config/host-resource-runtime.d.mts +8 -0
- package/dist/src/config/host-resource-runtime.mjs +67 -24
- package/dist/src/config/index-graph-overrides.js +4 -0
- package/dist/src/config/worker-attribution.d.mts +7 -0
- package/dist/src/config/worker-attribution.mjs +44 -0
- package/dist/src/config/worker-write.js +4 -10
- package/dist/src/decision/ledger.js +15 -15
- package/dist/src/decision/offload.js +6 -7
- package/dist/src/delivery/git.js +62 -0
- package/dist/src/delivery/pr.js +151 -0
- package/dist/src/delivery/template-sections.js +56 -0
- package/dist/src/delivery/tracker.js +33 -0
- package/dist/src/discovery/interview.js +1 -1
- package/dist/src/extensions/claude-hooks-installer.js +62 -53
- package/dist/src/extensions/loader.js +2 -1
- package/dist/src/extensions/managed-hook-script-state.js +48 -0
- package/dist/src/extensions/muse-managed-hooks.js +49 -0
- package/dist/src/issues/cli.js +15 -3
- package/dist/src/issues/external-cli.js +79 -0
- package/dist/src/issues/live.js +26 -2
- package/dist/src/issues/local.js +5 -1
- package/dist/src/issues/tracker-policy.js +27 -0
- package/dist/src/mcp/json-document.d.mts +2 -0
- package/dist/src/mcp/tools/worker-invoke.mjs +2 -1
- package/dist/src/mcp/tools/worker-stdin-runtime.mjs +12 -0
- package/dist/src/models/conductor-data-policy.d.mts +3 -2
- package/dist/src/models/conductor-data-policy.mjs +94 -5
- package/dist/src/models/model-capabilities.v1.json +27 -23
- package/dist/src/models/model-catalog.v1.json +3 -3
- package/dist/src/models/provider-policy.js +8 -0
- package/dist/src/models/worker-health-readiness.js +20 -4
- package/dist/src/models/worker-health-snapshot.js +29 -0
- package/dist/src/models/worker-installation.d.mts +5 -1
- package/dist/src/models/worker-installation.mjs +11 -5
- package/dist/src/models/worker-plan.js +3 -3
- package/dist/src/models/worker-qualification-policy.js +54 -0
- package/dist/src/models/worker-selection-policy.js +2 -1
- package/dist/src/providers/deployment-lock.js +77 -0
- package/dist/src/providers/deployment-ownership.d.mts +12 -2
- package/dist/src/providers/deployment-ownership.mjs +115 -21
- package/dist/src/providers/deployment-preservation.d.mts +2 -1
- package/dist/src/providers/deployment-preservation.mjs +3 -0
- package/dist/src/providers/provider-definitions.js +4 -0
- package/dist/src/providers/skill-ownership.d.mts +1 -0
- package/dist/src/providers/transformation-receipt-integration.js +4 -2
- package/dist/src/providers/transformation-receipt.js +4 -2
- package/dist/src/serve/worker-invocation-preparation.js +3 -1
- package/dist/src/serve/worker-invocation.js +6 -2
- package/dist/src/skills/run.js +5 -0
- package/dist/src/smiths/context-pipeline/workspace-audit.js +34 -17
- package/dist/src/smiths/context-pipeline/workspace-context-shared.js +12 -6
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +44 -4
- package/dist/src/smiths/context-pipeline/workspace-document.js +5 -2
- package/dist/src/smiths/context-pipeline/workspace-migration.js +2 -1
- package/dist/src/smiths/hook-bridge/codex-translator.js +150 -92
- package/dist/src/smiths/hook-bridge/codex-trust.js +50 -0
- package/dist/src/smiths/hook-bridge/factory-hook-config.js +132 -0
- package/dist/src/smiths/hook-bridge/factory-translator.js +88 -33
- package/dist/src/smiths/hook-bridge/hermes-translator.js +3 -1
- package/dist/src/smiths/hook-bridge/index.js +3 -3
- package/dist/src/smiths/hook-bridge/loader.js +10 -2
- package/dist/src/smiths/hook-bridge/prompt-discovery-gaps.js +5 -0
- package/dist/src/storage/workspace-permissions-health.js +64 -0
- package/dist/src/storage/workspace-permissions.js +51 -0
- package/package.json +9 -2
- package/schemas/models/model-config-compatibility.v1.schema.json +4 -0
- package/tools/agents/deploy-agents.mjs +15 -0
- package/tools/agents/providers/base-contract.mjs +7 -1
- package/tools/agents/providers/base-files.mjs +2 -1
- package/tools/agents/providers/base-flat-artifacts.mjs +6 -3
- package/tools/agents/providers/base-inventory.mjs +35 -13
- package/tools/agents/providers/base-models-platforms.mjs +3 -3
- package/tools/agents/providers/base-skill-copy.mjs +2 -0
- package/tools/agents/providers/base.mjs +1 -1
- package/tools/agents/providers/bound-rules-pointer.mjs +21 -0
- package/tools/agents/providers/claude-post-deploy.mjs +9 -5
- package/tools/agents/providers/codex-post-deploy.mjs +10 -0
- package/tools/agents/providers/conductor-data-guard.mjs +35 -11
- package/tools/agents/providers/factory-hooks.mjs +43 -0
- package/tools/agents/providers/factory.mjs +4 -91
- package/tools/agents/providers/muse-hooks.mjs +6 -41
- package/tools/agents/providers/muse-prompt-discovery.mjs +18 -0
- package/tools/agents/providers/packaged-codex-agents.mjs +48 -0
- package/tools/agents/providers/provider-prepare-coordinator.mjs +15 -10
- package/tools/agents/providers/rule-delivery-surface.mjs +10 -7
- package/tools/agents/providers/rule-deployment-commit.mjs +10 -0
- package/tools/agents/providers/rule-presentation.mjs +6 -5
- package/tools/agents/providers/rule-projection.mjs +10 -2
- package/tools/agents/providers/rule-startup.mjs +8 -1
- package/tools/agents/providers/stale-artifact-prune.mjs +9 -8
- package/tools/cli/decision-offload-report.mjs +7 -2
- package/tools/plugin/issue-template-copies.mjs +24 -0
- package/tools/plugin/package-plugins.mjs +11 -3
- package/tools/ralph-external/lib/factory-adapter.mjs +7 -8
- package/tools/ralph-external/lib/worker-artifacts.mjs +4 -2
- package/tools/ralph-external/lib/worker-capture.mjs +157 -0
- package/tools/ralph-external/lib/worker-final.mjs +43 -8
- package/tools/ralph-external/lib/worker-health.mjs +3 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +9 -6
- package/tools/ralph-external/lib/worker-launch-cli.mjs +20 -2
- package/tools/ralph-external/lib/worker-process-identity.mjs +30 -0
- package/tools/ralph-external/lib/worker-prompt.mjs +35 -0
- package/tools/ralph-external/lib/worker-retry-evidence.mjs +87 -6
- package/tools/ralph-external/lib/worker-run-directory-refusal.mjs +8 -0
- package/tools/ralph-external/lib/worker-termination.mjs +56 -6
- package/tools/ralph-external/process-monitor.mjs +12 -18
- package/tools/ralph-external/session-launcher.mjs +53 -36
- package/vscode-extension/schemas/aiwg.config.v1.json +15 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Refuse
|
|
2
|
-
import { realpathSync, readFileSync, statSync } from 'node:fs';
|
|
1
|
+
// Refuse local-only reads and direct execution of worker output by the conductor.
|
|
2
|
+
import { realpathSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
3
3
|
import { resolve, dirname, relative, isAbsolute, sep, matchesGlob, basename } from 'node:path';
|
|
4
4
|
|
|
5
5
|
// Literal project-relative files or directory subtrees; no globs, traversal or rule syntax.
|
|
@@ -144,7 +144,95 @@ function recursiveRoots(words) {
|
|
|
144
144
|
return roots.length ? roots : ['.'];
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
// Read Git's existing worktree metadata, never invoke Git or a worker-owned helper.
|
|
148
|
+
// Retained worktrees stay untrusted after the worker stops, until integration.
|
|
149
|
+
export function conductorWorkerTrees(root) {
|
|
150
|
+
const trees = [resolve(root, '.aiwg/working/worktrees')];
|
|
151
|
+
try {
|
|
152
|
+
let git = resolve(root, '.git');
|
|
153
|
+
if (!statSync(git).isDirectory()) {
|
|
154
|
+
git = resolve(root, readFileSync(git, 'utf8').trim().replace(/^gitdir: /, ''));
|
|
155
|
+
}
|
|
156
|
+
try { git = resolve(git, readFileSync(resolve(git, 'commondir'), 'utf8').trim()); } catch { /* Main checkout. */ }
|
|
157
|
+
for (const entry of readdirSync(resolve(git, 'worktrees'))) {
|
|
158
|
+
try {
|
|
159
|
+
const metadata = resolve(git, 'worktrees', entry);
|
|
160
|
+
const tree = dirname(resolve(metadata, readFileSync(resolve(metadata, 'gitdir'), 'utf8').trim()));
|
|
161
|
+
if (canonical(tree) !== canonical(root)) trees.push(tree);
|
|
162
|
+
} catch { /* A stale entry must not hide other registered workers. */ }
|
|
163
|
+
}
|
|
164
|
+
} catch { /* Projects without Git metadata still protect the standard worker directory. */ }
|
|
165
|
+
return [...new Set(trees)];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const workerExecutionDenial = 'AIWG: conductor must not execute or import worker-written code; use aiwg ralph-external --verify-worker instead';
|
|
169
|
+
const runtime = /^(?:node(?:js)?|python(?:\d+(?:\.\d+)*)?|npm|npx|pnpm|yarn|bun|deno|vitest|jest|pytest|py\.test|mocha|ava|tap|tsx|ts-node|make|cmake|ctest|cargo|go|ruby|perl|php|java)$/;
|
|
170
|
+
const shells = new Set(['sh', 'bash', 'dash', 'zsh']);
|
|
171
|
+
const wrappers = new Set(['env', 'nice', 'timeout', 'systemd-run', 'sudo', 'command', 'exec', 'nohup']);
|
|
172
|
+
const wrapperValues = new Set(['-n', '--adjustment', '-p', '--property', '-u', '--user', '-g', '--group',
|
|
173
|
+
'-C', '--chdir', '--working-directory', '--unit', '--description', '--slice', '--kill-after', '-k', '-s', '--signal']);
|
|
174
|
+
|
|
175
|
+
function workerExecution(command, initialCwd, trees, depth = 0) {
|
|
176
|
+
if (depth > 4) return true;
|
|
177
|
+
const protectedTrees = trees.flatMap(tree => [resolve(tree), canonical(resolve(tree))]);
|
|
178
|
+
const copies = [];
|
|
179
|
+
let cwd = initialCwd;
|
|
180
|
+
const untrusted = candidate => {
|
|
181
|
+
const file = resolve(cwd, candidate.replace(/^file:\/\//, ''));
|
|
182
|
+
return [...protectedTrees, ...copies].some(base => contains(base, file) || contains(base, canonical(file)));
|
|
183
|
+
};
|
|
184
|
+
const references = value => (value.match(/[^\s"'`;&|<>()\[\]{},]+/g) ?? [])
|
|
185
|
+
.some(token => untrusted(token.split('=').at(-1)));
|
|
186
|
+
for (const words of shellCommands(command)) {
|
|
187
|
+
let index = 0;
|
|
188
|
+
while (/^[A-Za-z_][A-Za-z0-9_]*=/.test(words[index]?.value ?? '')) index++;
|
|
189
|
+
let name = basename(words[index]?.value ?? '');
|
|
190
|
+
while (wrappers.has(name)) {
|
|
191
|
+
// Common resource/process wrappers confer no verification authority.
|
|
192
|
+
const wrapper = name;
|
|
193
|
+
index++;
|
|
194
|
+
while (index < words.length) {
|
|
195
|
+
const arg = words[index].value;
|
|
196
|
+
if (arg === '--') { index++; break; }
|
|
197
|
+
if (wrapper === 'env' && /^[A-Za-z_][A-Za-z0-9_]*=/.test(arg)) { index++; continue; }
|
|
198
|
+
if (!arg.startsWith('-')) break;
|
|
199
|
+
const [option, assigned] = arg.split('=');
|
|
200
|
+
const takesValue = wrapperValues.has(option) && !(wrapper === 'systemd-run' && option === '--user');
|
|
201
|
+
const value = assigned ?? (takesValue ? words[index + 1]?.value : undefined);
|
|
202
|
+
if (['-C', '--chdir', '--working-directory'].includes(option) && value) cwd = resolve(cwd, value);
|
|
203
|
+
index += takesValue && assigned === undefined ? 2 : 1;
|
|
204
|
+
}
|
|
205
|
+
if (wrapper === 'timeout') index++; // Duration follows timeout's options.
|
|
206
|
+
name = basename(words[index]?.value ?? '');
|
|
207
|
+
}
|
|
208
|
+
const args = words.slice(index + 1).map(word => word.value);
|
|
209
|
+
if (name === 'cd') {
|
|
210
|
+
const target = args.find(arg => arg !== '--' && arg !== '-P' && arg !== '-L');
|
|
211
|
+
if (target) cwd = resolve(cwd, target);
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (['cp', 'mv', 'install'].includes(name)) {
|
|
215
|
+
const operands = args.filter(arg => !arg.startsWith('-'));
|
|
216
|
+
const destination = operands.at(-1);
|
|
217
|
+
for (const source of operands.slice(0, -1)) if (destination && untrusted(source)) {
|
|
218
|
+
copies.push(resolve(cwd, destination), resolve(cwd, destination, basename(source)));
|
|
219
|
+
}
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (words[index]?.value.includes('/') && untrusted(words[index].value)) return true;
|
|
223
|
+
if (shells.has(name)) {
|
|
224
|
+
const inline = args.findIndex(arg => /^-[^-]*c/.test(arg));
|
|
225
|
+
if (inline >= 0 && args[inline + 1] !== undefined) {
|
|
226
|
+
if (workerExecution(args[inline + 1], cwd, [...protectedTrees, ...copies], depth + 1)) return true;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if ((runtime.test(name) || shells.has(name)) && (untrusted('.') || words.some(word => references(word.value)))) return true;
|
|
231
|
+
}
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function conductorToolDenial(event, root, paths, workerTrees = conductorWorkerTrees(root)) {
|
|
148
236
|
const input = event.tool_input ?? {};
|
|
149
237
|
const cwd = typeof event.cwd === 'string' && isAbsolute(event.cwd) ? event.cwd : root;
|
|
150
238
|
const protectedPaths = paths.flatMap(file => [resolve(root, file), canonical(resolve(root, file))]);
|
|
@@ -155,6 +243,7 @@ export function conductorToolDenial(event, root, paths) {
|
|
|
155
243
|
};
|
|
156
244
|
if ([input.file_path, input.path].some(denied)) return 'AIWG: local-only task input is unavailable to this conductor';
|
|
157
245
|
if (typeof input.command === 'string') {
|
|
246
|
+
if (workerTrees.length && workerExecution(input.command, cwd, workerTrees)) return workerExecutionDenial;
|
|
158
247
|
// Covers literal/quoted paths, compound commands and common redirections. This is
|
|
159
248
|
// deliberately conservative, not a shell interpreter or a filesystem sandbox.
|
|
160
249
|
const command = input.command;
|
|
@@ -172,14 +261,14 @@ export function conductorToolDenial(event, root, paths) {
|
|
|
172
261
|
return null;
|
|
173
262
|
}
|
|
174
263
|
|
|
175
|
-
export function runConductorDataHook(root, paths) {
|
|
264
|
+
export function runConductorDataHook(root, paths, denyWorkerExecution = false) {
|
|
176
265
|
try {
|
|
177
266
|
const raw = readFileSync(0, 'utf8');
|
|
178
267
|
if (Buffer.byteLength(raw) > 1024 * 1024) throw new Error('oversized event');
|
|
179
268
|
const event = JSON.parse(raw);
|
|
180
269
|
if (!event || typeof event !== 'object' || typeof event.tool_name !== 'string'
|
|
181
270
|
|| !event.tool_input || typeof event.tool_input !== 'object') throw new Error('invalid event');
|
|
182
|
-
const reason = conductorToolDenial(event, root, paths);
|
|
271
|
+
const reason = conductorToolDenial(event, root, paths, denyWorkerExecution ? conductorWorkerTrees(root) : []);
|
|
183
272
|
if (reason) process.stdout.write(JSON.stringify({ hookSpecificOutput: {
|
|
184
273
|
hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: reason,
|
|
185
274
|
} }) + '\n');
|
|
@@ -1079,7 +1079,7 @@
|
|
|
1079
1079
|
"agent": "native",
|
|
1080
1080
|
"skill": "informational",
|
|
1081
1081
|
"globalChild": "native",
|
|
1082
|
-
"identifierSyntax": "Factory model ID or
|
|
1082
|
+
"identifierSyntax": "Factory built-in model ID or custom BYOK model selector",
|
|
1083
1083
|
"effortValues": [
|
|
1084
1084
|
"low",
|
|
1085
1085
|
"medium",
|
|
@@ -1097,7 +1097,7 @@
|
|
|
1097
1097
|
"id": "factory-direct",
|
|
1098
1098
|
"provider": "factory",
|
|
1099
1099
|
"adapterVersion": "1",
|
|
1100
|
-
"supportedVersions": "0.
|
|
1100
|
+
"supportedVersions": "1.0.0",
|
|
1101
1101
|
"runtimeDriver": "installed:factory",
|
|
1102
1102
|
"catalogAdapter": {
|
|
1103
1103
|
"kind": "file",
|
|
@@ -1122,7 +1122,7 @@
|
|
|
1122
1122
|
],
|
|
1123
1123
|
"stdin": "brief-text",
|
|
1124
1124
|
"cwd": "${workspace}",
|
|
1125
|
-
"envAllowlist": ["FACTORY_API_KEY", "HOME", "PATH"],
|
|
1125
|
+
"envAllowlist": ["FACTORY_API_KEY", "HOME", "OPENROUTER_API_KEY", "PATH"],
|
|
1126
1126
|
"versionArgv": [
|
|
1127
1127
|
"--version"
|
|
1128
1128
|
],
|
|
@@ -1147,78 +1147,82 @@
|
|
|
1147
1147
|
"invocationProfiles": {
|
|
1148
1148
|
"direct-shell": {
|
|
1149
1149
|
"transport": "shell",
|
|
1150
|
-
"supportedVersions": "0.
|
|
1150
|
+
"supportedVersions": "1.0.0",
|
|
1151
1151
|
"controls": {
|
|
1152
1152
|
"model": {
|
|
1153
1153
|
"support": "unqualified",
|
|
1154
|
-
"mapping": "[-m/--model MODEL]; exact catalog model ID, never the CLI default
|
|
1155
|
-
"evidence": "H: droid-cli 0.
|
|
1154
|
+
"mapping": "[-m/--model MODEL]; exact catalog model ID, never the CLI default or a generic alias",
|
|
1155
|
+
"evidence": "H: droid-cli 1.0.0 exec --help documents -m/--model <id>; unqualified until live model-pin evidence"
|
|
1156
1156
|
},
|
|
1157
1157
|
"effort": {
|
|
1158
1158
|
"support": "unqualified",
|
|
1159
1159
|
"mapping": "[-r/--reasoning-effort LEVEL]; valid levels are model-dependent (exec --help 'Model details'); never the per-model default",
|
|
1160
|
-
"evidence": "H: droid-cli 0.
|
|
1160
|
+
"evidence": "H: droid-cli 1.0.0 exec --help documents -r/--reasoning-effort <level> (defaults per model); unqualified until live evidence"
|
|
1161
1161
|
},
|
|
1162
1162
|
"sandbox": {
|
|
1163
1163
|
"support": "unqualified",
|
|
1164
1164
|
"mapping": "workspace-write -> [--auto low]; read-only -> no --auto flag (the CLI's own documented read-only default); --skip-permissions-unsafe and the medium/high --auto tiers are out of this contract's scope and are never emitted",
|
|
1165
|
-
"evidence": "H: droid-cli 0.
|
|
1165
|
+
"evidence": "H: droid-cli 1.0.0 exec --help documents --auto <level> (low|medium|high), its 'Autonomy Levels' default read-only mode, and --skip-permissions-unsafe ('Bypass all checks - DANGEROUS!'); unqualified until live evidence"
|
|
1166
1166
|
},
|
|
1167
1167
|
"approval": {
|
|
1168
1168
|
"support": "unqualified",
|
|
1169
1169
|
"mapping": "unavailable as a separate flag: exec is non-interactive by construction and --auto (the sandbox control) is the only permission gate",
|
|
1170
|
-
"evidence": "H: droid-cli 0.238.0 exec --help documents exec as 'Run non-interactively (for scripts/automation)' with no approval-prompt flag; unqualified until live evidence"
|
|
1170
|
+
"evidence": "H: prior droid-cli 0.238.0 exec --help documents exec as 'Run non-interactively (for scripts/automation)' with no approval-prompt flag; not reverified on 1.0.0, unqualified until live evidence"
|
|
1171
1171
|
},
|
|
1172
1172
|
"workdir": {
|
|
1173
1173
|
"support": "unqualified",
|
|
1174
1174
|
"mapping": "[--cwd W] conductor working root, plus the conductor process cwd",
|
|
1175
|
-
"evidence": "H: droid-cli 0.
|
|
1175
|
+
"evidence": "H: droid-cli 1.0.0 exec --help documents --cwd <path>; unqualified until live evidence"
|
|
1176
1176
|
},
|
|
1177
1177
|
"finalOutput": {
|
|
1178
1178
|
"support": "unqualified",
|
|
1179
1179
|
"mapping": "unavailable as a file target: no -o/output-file flag is documented for exec (-o/--output-format selects stream shape, not a destination); the final is the last type:\"result\" line of the captured --output-format stream-json stdout stream",
|
|
1180
|
-
"evidence": "H: droid-cli 0.
|
|
1180
|
+
"evidence": "H: droid-cli 1.0.0 exec --help documents -o/--output-format <text|json|stream-json|stream-jsonrpc|acp> with no file-path argument; D: https://docs.factory.com/droid-exec/overview documents the terminal result object shape; unqualified until live evidence"
|
|
1181
1181
|
},
|
|
1182
1182
|
"stdin": {
|
|
1183
1183
|
"support": "unqualified",
|
|
1184
1184
|
"mapping": "brief-text: omitting the prompt argument makes exec read the prompt from stdin to EOF; brief text never enters argv, rendered commands or serialized plans",
|
|
1185
|
-
"evidence": "H: droid-cli 0.
|
|
1185
|
+
"evidence": "H: titan eval on droid-cli 1.0.0 verified stdin ingestion: the brief was echoed as the first stream-json message. Live result pending: blocked by 402 No active subscription; no successful inference recorded"
|
|
1186
1186
|
},
|
|
1187
1187
|
"structuredOutput": {
|
|
1188
1188
|
"support": "unqualified",
|
|
1189
1189
|
"mapping": "unavailable: no --output-schema-equivalent flag is documented for exec",
|
|
1190
|
-
"evidence": "H: droid-cli 0.238.0 exec --help advertises no output-schema flag; unqualified until live evidence"
|
|
1190
|
+
"evidence": "H: prior droid-cli 0.238.0 exec --help advertises no output-schema flag; not reverified on 1.0.0, unqualified until live evidence"
|
|
1191
1191
|
},
|
|
1192
1192
|
"stepCap": {
|
|
1193
1193
|
"support": "unqualified",
|
|
1194
|
-
"mapping": "unavailable: no step or turn cap flag is evidenced on 0.
|
|
1195
|
-
"evidence": "H: droid-cli 0.238.0 exec --help advertises no step-cap flag; unknown controls block tasks requiring them"
|
|
1194
|
+
"mapping": "unavailable: no step or turn cap flag is evidenced on 1.0.0; deadline and output-byte bounds come from the invoking shell",
|
|
1195
|
+
"evidence": "H: prior droid-cli 0.238.0 exec --help advertises no step-cap flag; unknown controls block tasks requiring them"
|
|
1196
1196
|
},
|
|
1197
1197
|
"trust": {
|
|
1198
1198
|
"support": "unqualified",
|
|
1199
|
-
"mapping": "unknown: workspace-trust behaviour is not evidenced for non-interactive exec on 0.
|
|
1200
|
-
"evidence": "H: droid-cli 0.238.0 exec --help documents no trust-prompt flag for exec; unqualified until live evidence"
|
|
1199
|
+
"mapping": "unknown: workspace-trust behaviour is not evidenced for non-interactive exec on 1.0.0",
|
|
1200
|
+
"evidence": "H: prior droid-cli 0.238.0 exec --help documents no trust-prompt flag for exec; not reverified on 1.0.0, unqualified until live evidence"
|
|
1201
1201
|
},
|
|
1202
1202
|
"children": {
|
|
1203
1203
|
"support": "unqualified",
|
|
1204
1204
|
"mapping": "controllable: --mission spawns worker sessions via factoryd (never emitted by this profile, which keeps every run single-agent)",
|
|
1205
|
-
"evidence": "H: droid-cli 0.238.0 exec --help documents --mission/--worker-model/--validator-model as mission-mode only; the direct profile never emits them; unqualified until live evidence"
|
|
1205
|
+
"evidence": "H: prior droid-cli 0.238.0 exec --help documents --mission/--worker-model/--validator-model as mission-mode only; the direct profile never emits them; not reverified on 1.0.0, unqualified until live evidence"
|
|
1206
1206
|
},
|
|
1207
1207
|
"fallback": {
|
|
1208
1208
|
"support": "unqualified",
|
|
1209
1209
|
"mapping": "unavailable: no non-mission fallback-model flag is documented for exec (--spec-model/--worker-model/--validator-model are mission-mode only)",
|
|
1210
|
-
"evidence": "H: droid-cli 0.238.0 exec --help scopes --spec-model/--worker-model/--validator-model to --mission/--use-spec; unknown controls block tasks requiring them"
|
|
1210
|
+
"evidence": "H: prior droid-cli 0.238.0 exec --help scopes --spec-model/--worker-model/--validator-model to --mission/--use-spec; unknown controls block tasks requiring them"
|
|
1211
1211
|
}
|
|
1212
1212
|
},
|
|
1213
|
-
"envAllowlist": ["FACTORY_API_KEY", "HOME", "PATH"],
|
|
1213
|
+
"envAllowlist": ["FACTORY_API_KEY", "HOME", "OPENROUTER_API_KEY", "PATH"],
|
|
1214
1214
|
"pitfalls": [
|
|
1215
1215
|
"Documentation/help and synthetic observations are not authenticated live qualification.",
|
|
1216
|
+
"Titan 1.0.0 eval (2026-11-06, BYOK custom model via OpenRouter): the brief on stdin returns the exact smoke reply in read-only mode and with --auto low; -m selects the custom model and the stream-json system event reports it. Catalog evidence stays H; live qualification is recorded only by aiwg doctor --probe-workers --qualify.",
|
|
1217
|
+
"-r/--reasoning-effort is accepted but ignored for BYOK custom models: the system event reports reasoning_effort none, so effort is not enforceable on them.",
|
|
1218
|
+
"droid relabels custom model IDs by display name: custom:<name>-2 is reported back as custom:<name>-0. Match the model by name, not by the numeric suffix.",
|
|
1219
|
+
"Under --auto low a command above the tier ends the run with exit 1 and the error Exec ended early: insufficient permission to proceed; nothing runs.",
|
|
1216
1220
|
"Unknown model, effort, permission or required step mappings block dispatch.",
|
|
1217
1221
|
"Native MCP/client, MSP/ACP, gateway and conversation capabilities do not establish worker authority.",
|
|
1218
1222
|
"--skip-permissions-unsafe is Ralph-loop legacy and never part of the direct profile.",
|
|
1219
1223
|
"The stream-json/json event vocabulary (assistant/user/tool_call/tool_result/hook/error/result) is doc-sourced (docs.factory.com), not help-verified; it never promotes qualification status beyond unqualified.",
|
|
1220
1224
|
"There is no -o/output-file flag on exec: the final is read from the captured stdout stream, never a separate file.",
|
|
1221
|
-
"FACTORY_API_KEY
|
|
1225
|
+
"Auth is the Factory account (FACTORY_API_KEY or keyring) or a BYOK customModels entry in ~/.factory/settings.json whose apiKey is an env reference; the launch env must carry that variable (OPENROUTER_API_KEY is allowlisted; a BYOK key under another name blocks with Custom model apiKey references the environment variable ... which is not set). HOME locates ~/.factory/settings.json."
|
|
1222
1226
|
],
|
|
1223
1227
|
"health": {
|
|
1224
1228
|
"version": 1,
|
|
@@ -1244,8 +1248,8 @@
|
|
|
1244
1248
|
{
|
|
1245
1249
|
"kind": "help",
|
|
1246
1250
|
"ref": "tools/ralph-external/lib/factory-adapter.mjs",
|
|
1247
|
-
"observedAt": "2026-
|
|
1248
|
-
"cliVersion": "0.
|
|
1251
|
+
"observedAt": "2026-11-06T00:00:00Z",
|
|
1252
|
+
"cliVersion": "1.0.0"
|
|
1249
1253
|
},
|
|
1250
1254
|
{
|
|
1251
1255
|
"kind": "documentation",
|
|
@@ -162,17 +162,17 @@
|
|
|
162
162
|
"factory": {
|
|
163
163
|
"roles": {
|
|
164
164
|
"reasoning": {
|
|
165
|
-
"id": "
|
|
165
|
+
"id": "claude-opus-5",
|
|
166
166
|
"status": "active",
|
|
167
167
|
"observed": false
|
|
168
168
|
},
|
|
169
169
|
"coding": {
|
|
170
|
-
"id": "
|
|
170
|
+
"id": "claude-sonnet-5",
|
|
171
171
|
"status": "active",
|
|
172
172
|
"observed": false
|
|
173
173
|
},
|
|
174
174
|
"efficiency": {
|
|
175
|
-
"id": "
|
|
175
|
+
"id": "claude-haiku-4-5-20251001",
|
|
176
176
|
"status": "active",
|
|
177
177
|
"observed": false
|
|
178
178
|
}
|
|
@@ -146,6 +146,14 @@ export class WorkerPolicyError extends Error {
|
|
|
146
146
|
this.name = 'WorkerPolicyError';
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
+
/** Only the trusted installation loader supplies this public policy-drift summary. */
|
|
150
|
+
export class WorkerQualificationPolicyError extends WorkerPolicyError {
|
|
151
|
+
pointer;
|
|
152
|
+
constructor(diagnostic, rejections) {
|
|
153
|
+
super('OG_ADAPTER_UNQUALIFIED', diagnostic.message, { rejections });
|
|
154
|
+
this.pointer = diagnostic.pointer;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
149
157
|
export class WorkerRoleEffortError extends WorkerPolicyError {
|
|
150
158
|
pointer;
|
|
151
159
|
constructor(role) {
|
|
@@ -138,7 +138,20 @@ export function diagnoseWorkerHealthReadiness(snapshot, request, paths = {}) {
|
|
|
138
138
|
}
|
|
139
139
|
const sharedDiagnostics = new Map();
|
|
140
140
|
for (const role of roles) {
|
|
141
|
-
const
|
|
141
|
+
const roleRequest = { now: request.now, context: request.context, role,
|
|
142
|
+
taskClass: Object.entries(snapshot.models.defaults.workerSelection?.taskClasses ?? {})
|
|
143
|
+
.find(([, taskRole]) => taskRole === role)?.[0] };
|
|
144
|
+
let plan = resolveWorkerPlan(snapshot, roleRequest);
|
|
145
|
+
let pendingAuthorization = false;
|
|
146
|
+
if (!plan.selected && plan.exclusions.some(item => item.diagnostics.some(diagnostic => diagnostic.code === 'OG_MODEL_UNAPPROVED' && diagnostic.pointer === '/request/authority'))) {
|
|
147
|
+
// Counterfactual offline check only: never return a launch plan or grant authority.
|
|
148
|
+
const authorized = resolveWorkerPlan(snapshot, { ...roleRequest,
|
|
149
|
+
authority: { premiumAuthorized: true, maxAutoTier: 3 } });
|
|
150
|
+
if (authorized.selected) {
|
|
151
|
+
plan = authorized;
|
|
152
|
+
pendingAuthorization = true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
142
155
|
const isRequired = required.has(role);
|
|
143
156
|
const diagnostics = [
|
|
144
157
|
...plan.diagnostics.map(diagnostic => ({ diagnostic, members: membersFor(diagnostic.pointer, role) })),
|
|
@@ -204,10 +217,13 @@ export function diagnoseWorkerHealthReadiness(snapshot, request, paths = {}) {
|
|
|
204
217
|
message: 'Profile has degraded or unobserved health coverage; progress and stop evidence may be unavailable.',
|
|
205
218
|
nextAction: 'qualify-health-signals' }, [`${tuple.group}/${tuple.member}`]);
|
|
206
219
|
}
|
|
207
|
-
add({ code: '
|
|
220
|
+
add({ code: pendingAuthorization ? 'WORKER_ROLE_PENDING_AUTHORIZATION' : 'WORKER_ROLE_ELIGIBLE',
|
|
221
|
+
status: pendingAuthorization ? 'warn' : 'ok', role,
|
|
208
222
|
pointer: `/defaults/workerSelection/roleGuidance/${role}`,
|
|
209
|
-
message:
|
|
210
|
-
|
|
223
|
+
message: pendingAuthorization
|
|
224
|
+
? 'Role is ready pending authorization; --authorize-premium requires explicit operator confirmation before resolving a launch.'
|
|
225
|
+
: 'Policy route is eligible; launch still requires current installation and task qualification.',
|
|
226
|
+
nextAction: pendingAuthorization ? 'confirm-premium-with-operator' : 'resolve-current-task' }, [`${tuple.group}/${tuple.member}`]);
|
|
211
227
|
}
|
|
212
228
|
catch {
|
|
213
229
|
if (isRequired)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Project signed historical approval inputs for offline health checks without granting launch authority.
|
|
2
|
+
import { inspectRecordedWorkerQualifications } from './worker-installation.mjs';
|
|
3
|
+
export async function recordedWorkerHealthSnapshot(snapshot, cwd) {
|
|
4
|
+
const parallelism = snapshot.config.parallelism;
|
|
5
|
+
const policy = snapshot.models.defaults.workerSelection;
|
|
6
|
+
if (!parallelism || !policy)
|
|
7
|
+
return snapshot;
|
|
8
|
+
const records = await inspectRecordedWorkerQualifications({ cwd, policy, parallelism, includeInputs: true })
|
|
9
|
+
.catch(() => []);
|
|
10
|
+
const result = structuredClone(snapshot);
|
|
11
|
+
for (const { cli, provider, binding, adapter, observations } of records) {
|
|
12
|
+
if (!binding || !adapter || !observations)
|
|
13
|
+
continue;
|
|
14
|
+
const providerEntry = Object.entries(result.registry.providers).find(([id]) => id === provider)?.[1];
|
|
15
|
+
if (providerEntry)
|
|
16
|
+
providerEntry.workerAdapter = adapter;
|
|
17
|
+
else {
|
|
18
|
+
result.registry.workerAdapters ??= {};
|
|
19
|
+
result.registry.workerAdapters[adapter.id] = adapter;
|
|
20
|
+
}
|
|
21
|
+
result.installations[cli] = binding;
|
|
22
|
+
result.catalog.discovery ??= { source: 'static', fetchedAt: observations.observedAt, providers: {} };
|
|
23
|
+
result.catalog.discovery.instances ??= {};
|
|
24
|
+
// These are recorded facts only; current discovery and installation are rechecked at launch.
|
|
25
|
+
result.catalog.discovery.instances[cli] = observations;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=worker-health-snapshot.js.map
|
|
@@ -43,4 +43,8 @@ export function prepareWorkerInstallationStore(input: { workerWritableRoots: str
|
|
|
43
43
|
/** Historical approvals only; no driver import, probe, auth read, or launch authority. */
|
|
44
44
|
export function inspectRecordedWorkerQualifications(input: {
|
|
45
45
|
cwd: string; policy: WorkerSelectionPolicy; parallelism: import('../config/aiwg-config.js').ParallelismConfig;
|
|
46
|
-
|
|
46
|
+
/** Include signed historical inputs for offline health projection, never launch authority. */
|
|
47
|
+
includeInputs?: boolean;
|
|
48
|
+
}): Promise<Array<{ cli: string; provider: string; binding?: WorkerResolutionBinding;
|
|
49
|
+
adapter?: import('./provider-policy.js').WorkerAdapterMetadata;
|
|
50
|
+
observations?: import('./model-discovery.js').ProviderModelDiscovery }>>;
|
|
@@ -754,7 +754,7 @@ async function qualificationSignatureFailure(record, trust) {
|
|
|
754
754
|
* This is historical evidence, not current launch authority; loadRecordedWorkerInstallations
|
|
755
755
|
* performs binary/version/scope checks when dispatch actually requests a binding.
|
|
756
756
|
*/
|
|
757
|
-
export async function inspectRecordedWorkerQualifications({ cwd, policy, parallelism }) {
|
|
757
|
+
export async function inspectRecordedWorkerQualifications({ cwd, policy, parallelism, includeInputs = false }) {
|
|
758
758
|
const filename = installationStorePath();
|
|
759
759
|
await assertTrustedStore(filename, [cwd]);
|
|
760
760
|
const { stored } = await readInstallationStore(filename);
|
|
@@ -776,7 +776,8 @@ export async function inspectRecordedWorkerQualifications({ cwd, policy, paralle
|
|
|
776
776
|
if (!proof || ['scopeDigest', 'fixtureDigest', 'verifiedAt', 'evidenceRef'].some(key => proof[key] !== installation.evidence?.[key])) continue;
|
|
777
777
|
if (await qualificationSignatureFailure(record, () => qualificationTrust(cwd))) continue;
|
|
778
778
|
await assertWorkerInstallationEvidence({ ...installation, adapter, now: Date.now(), policy }, proof.scopeDigest);
|
|
779
|
-
results.push({ cli, provider: adapter.provider
|
|
779
|
+
results.push({ cli, provider: adapter.provider, ...(includeInputs
|
|
780
|
+
? { binding: structuredClone(binding), adapter: structuredClone(adapter), observations: structuredClone(record.modelObservations) } : {}) });
|
|
780
781
|
} catch { /* Malformed, expired or unbound evidence is not qualification. */ }
|
|
781
782
|
}
|
|
782
783
|
return results.filter(row => results.filter(other => row.cli === other.cli).length === 1);
|
|
@@ -836,15 +837,20 @@ export async function recordWorkerInstallation(instance, options) {
|
|
|
836
837
|
/** Read recorded host authority, validate installation bytes and the current CLI
|
|
837
838
|
* version, then load the same approved factory used by Ralph. */
|
|
838
839
|
export async function loadRecordedWorkerInstallations({ registry, cwd, policy, parallelism, storePath, storeDigest, precheckPolicy }) {
|
|
839
|
-
const { WorkerPolicyError, parseProviderModelCapabilities } = await import('./provider-policy.js');
|
|
840
|
+
const { WorkerPolicyError, WorkerQualificationPolicyError, parseProviderModelCapabilities } = await import('./provider-policy.js');
|
|
841
|
+
// Compiled TS modules load lazily so the managed launcher's ESM-only import chain stays minimal (#3851).
|
|
842
|
+
const { workerQualificationPolicyDiagnostic } = await import('./worker-qualification-policy.js');
|
|
840
843
|
const { qualificationDigest } = await import('./qualification-digest.mjs');
|
|
841
|
-
// Only fixed stage codes and
|
|
844
|
+
// Only fixed stage codes, bounded indexes and signed policy-drift summaries leave this boundary.
|
|
842
845
|
// Underlying errors can contain probe output, environment values or paths.
|
|
843
846
|
const rejections = [];
|
|
844
|
-
const fail = () =>
|
|
847
|
+
const fail = () => {
|
|
848
|
+
const mismatch = workerQualificationPolicyDiagnostic(rejections, stored?.registrations, policy);
|
|
849
|
+
return mismatch ? new WorkerQualificationPolicyError(mismatch, rejections) : new WorkerPolicyError('OG_ADAPTER_UNQUALIFIED',
|
|
845
850
|
`Trusted installation qualification is required (${[...new Set(rejections.map(row => row.reason))].join(', ')})${rejections.some(row => row.reason.startsWith('signature-'))
|
|
846
851
|
? `. ${rejections.some(row => row.reason === 'signature-trust-unavailable') ? keyRecoveryMessage : requalifyMessage}` : ''}`,
|
|
847
852
|
{ rejections });
|
|
853
|
+
};
|
|
848
854
|
let reason = 'store-binding';
|
|
849
855
|
let filename;
|
|
850
856
|
let stored, digest;
|
|
@@ -295,11 +295,11 @@ export function resolveWorkerPlan(snapshot, request, ceilingDefaults = {}) {
|
|
|
295
295
|
plan.slots = resources.slots;
|
|
296
296
|
}
|
|
297
297
|
if (!resources.ok)
|
|
298
|
-
deny('
|
|
298
|
+
deny(resources.failures.some(failure => failure.code === 'OG_HOST_ATTRIBUTION') ? 'OG_HOST_ATTRIBUTION' : 'OG_HOST_CAPACITY', '/parallelism/admission/hostResources', resources.failures.map(failure => `${failure.signal}: ${failure.reason}`).join('; '));
|
|
299
299
|
}
|
|
300
300
|
const effectiveMaxParallel = caps.length ? Math.min(...caps) : null;
|
|
301
301
|
if (effectiveMaxParallel === 0)
|
|
302
|
-
deny('
|
|
302
|
+
deny('OG_HOST_CAPACITY', '/constraints/maxParallel', 'Current capacity ceiling is zero');
|
|
303
303
|
if (!reasons.some(reason => reason.blocking !== false))
|
|
304
304
|
plan.eligible.push({ ...tuple, cli: member.cli,
|
|
305
305
|
inferenceProvider: row.llmProvider, modelKey: key, family: observation.family, identityEvidence: binding.identityEvidence,
|
|
@@ -336,7 +336,7 @@ export function resolveWorkerPlan(snapshot, request, ceilingDefaults = {}) {
|
|
|
336
336
|
...(request.substitution && matchesChoice(plan.selected, request.substitution) ? { substitution: structuredClone(request.substitution) } : {}) };
|
|
337
337
|
}
|
|
338
338
|
if (!plan.selected && plan.resources?.slots === 0) {
|
|
339
|
-
block('
|
|
339
|
+
block(plan.resources.failures.some(failure => failure.code === 'OG_HOST_ATTRIBUTION') ? 'OG_HOST_ATTRIBUTION' : 'OG_HOST_CAPACITY', '/parallelism/admission/hostResources', plan.resources.failures.map(failure => `${failure.signal}: ${failure.reason}`).join('; '));
|
|
340
340
|
}
|
|
341
341
|
plan.alternatives = plan.eligible.filter(tuple => tuple !== plan.selected);
|
|
342
342
|
return plan;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Explain recorded worker-policy drift without disclosing policy values or dynamic keys. */
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { WorkerSelectionPolicySchema } from './worker-selection-policy.js';
|
|
4
|
+
import { qualificationDigest } from './qualification-digest.mjs';
|
|
5
|
+
const policyPointer = '/defaults/workerSelection';
|
|
6
|
+
// Schema-owned names are public; model IDs, role aliases, paths and values are not.
|
|
7
|
+
const fieldNames = {
|
|
8
|
+
guards: Object.keys(WorkerSelectionPolicySchema.shape.guards.unwrap().shape),
|
|
9
|
+
dataPolicy: Object.keys(WorkerSelectionPolicySchema.shape.dataPolicy.unwrap().shape),
|
|
10
|
+
freshness: Object.keys(WorkerSelectionPolicySchema.shape.freshness.unwrap().shape),
|
|
11
|
+
};
|
|
12
|
+
function changedPointers(before, after) {
|
|
13
|
+
const pointers = [];
|
|
14
|
+
const oldPolicy = before;
|
|
15
|
+
const newPolicy = (after ?? {});
|
|
16
|
+
for (const key of Object.keys(WorkerSelectionPolicySchema.shape)) {
|
|
17
|
+
if (qualificationDigest([oldPolicy[key]]) === qualificationDigest([newPolicy[key]]))
|
|
18
|
+
continue;
|
|
19
|
+
const fields = fieldNames[key];
|
|
20
|
+
if (!fields) {
|
|
21
|
+
pointers.push(`${policyPointer}/${key}`);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const oldFields = (oldPolicy[key] ?? {});
|
|
25
|
+
const newFields = (newPolicy[key] ?? {});
|
|
26
|
+
for (const field of fields) {
|
|
27
|
+
if (qualificationDigest([oldFields[field]]) !== qualificationDigest([newFields[field]])) {
|
|
28
|
+
pointers.push(`${policyPointer}/${key}/${field}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return pointers.length ? pointers : [policyPointer];
|
|
33
|
+
}
|
|
34
|
+
/** Called only for the loader's fixed rejection stages, after signature verification. */
|
|
35
|
+
export function workerQualificationPolicyDiagnostic(rejections, records, policy) {
|
|
36
|
+
const diagnostics = rejections.filter(row => row.reason === 'effective-config-digest' && row.registration !== null)
|
|
37
|
+
.map(row => {
|
|
38
|
+
const installed = records?.[row.registration]?.installation;
|
|
39
|
+
// Older or inconsistent records cannot establish which individual fields changed.
|
|
40
|
+
const pointers = installed?.policy && qualificationDigest(installed.policy) === installed.effectiveConfigDigest
|
|
41
|
+
? changedPointers(installed.policy, policy) : [policyPointer];
|
|
42
|
+
const workspace = typeof installed?.cwd === 'string' && path.isAbsolute(installed.cwd)
|
|
43
|
+
? ` ${JSON.stringify(installed.cwd)}` : '';
|
|
44
|
+
return { code: 'OG_ADAPTER_UNQUALIFIED',
|
|
45
|
+
pointer: pointers.length === 1 ? pointers[0] : policyPointer,
|
|
46
|
+
message: `Worker policy changed since qualification (effective-config-digest; pointers: ${pointers.join(', ')}); `
|
|
47
|
+
+ `align the shared project policy in the conductor and worker trees, then requalify the worker tree${workspace} `
|
|
48
|
+
+ 'by running aiwg doctor --probe-workers --qualify there.' };
|
|
49
|
+
});
|
|
50
|
+
return diagnostics.length ? { code: 'OG_ADAPTER_UNQUALIFIED',
|
|
51
|
+
pointer: diagnostics.length === 1 ? diagnostics[0].pointer : policyPointer,
|
|
52
|
+
message: diagnostics.map(row => row.message).join(' ') } : null;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=worker-qualification-policy.js.map
|
|
@@ -41,6 +41,7 @@ export const WorkerSelectionPolicySchema = z.strictObject({
|
|
|
41
41
|
deniedEfforts: uniqueStrings.optional(),
|
|
42
42
|
deniedModels: uniqueStrings.optional(),
|
|
43
43
|
denySelfDelegation: z.boolean().optional(),
|
|
44
|
+
denyConductorWorkerExecution: z.boolean().optional(),
|
|
44
45
|
requireExactModel: z.boolean().optional(),
|
|
45
46
|
allowedVisibility: z.array(z.enum(['listed', 'hidden'])).refine(v => new Set(v).size === v.length).optional(),
|
|
46
47
|
allowedLifecycle: z.array(z.enum(['active', 'deprecated'])).refine(v => new Set(v).size === v.length).optional(),
|
|
@@ -150,7 +151,7 @@ export function mergeWorkerSelection(layers) {
|
|
|
150
151
|
relaxation = value.some((v) => !previous.includes(v));
|
|
151
152
|
effective = previous.filter((v) => value.includes(v));
|
|
152
153
|
}
|
|
153
|
-
else if (['denySelfDelegation', 'requireExactModel'].includes(key)) {
|
|
154
|
+
else if (['denySelfDelegation', 'denyConductorWorkerExecution', 'requireExactModel'].includes(key)) {
|
|
154
155
|
relaxation = previous === true && value === false;
|
|
155
156
|
effective = previous || value;
|
|
156
157
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Serialize provider snapshots and writes that share user-home deployment state.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { acquireDirectoryLock, DirectoryLockContentionError } from '../artifacts/prebuilt-build-lock.js';
|
|
6
|
+
import { getUserStateDir } from '../config/user-state.js';
|
|
7
|
+
const ownerVariable = 'AIWG_PROVIDER_DEPLOYMENT_LOCK_OWNER';
|
|
8
|
+
const held = new AsyncLocalStorage();
|
|
9
|
+
/** Forward ownership only to children launched from the owning async operation. */
|
|
10
|
+
export function providerDeploymentLockEnvironment() {
|
|
11
|
+
const owner = held.getStore();
|
|
12
|
+
return owner ? { [ownerVariable]: owner.token } : {};
|
|
13
|
+
}
|
|
14
|
+
export async function acquireProviderDeploymentLock() {
|
|
15
|
+
const lockPath = path.join(getUserStateDir(), 'provider-deployment.lock');
|
|
16
|
+
const local = held.getStore();
|
|
17
|
+
const inherited = local?.lockPath === lockPath ? local.token : process.env[ownerVariable];
|
|
18
|
+
const readOwner = () => readFile(path.join(lockPath, 'owner'), 'utf8').then(value => value.trim());
|
|
19
|
+
let release;
|
|
20
|
+
let token;
|
|
21
|
+
// A stale or forged marker cannot bypass the on-disk lease. Borrowers never
|
|
22
|
+
// remove the parent's lock; only the original acquisition may release it.
|
|
23
|
+
if (inherited && await readOwner().catch(() => undefined) === inherited) {
|
|
24
|
+
token = inherited;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
release = await acquireSharedLock(lockPath);
|
|
28
|
+
try {
|
|
29
|
+
token = await readOwner();
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
await release();
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
let active = true;
|
|
37
|
+
return Object.assign(async () => {
|
|
38
|
+
if (!active)
|
|
39
|
+
return;
|
|
40
|
+
active = false;
|
|
41
|
+
await release?.();
|
|
42
|
+
}, {
|
|
43
|
+
async run(work) {
|
|
44
|
+
if (!active)
|
|
45
|
+
throw new Error('Provider deployment lock is released');
|
|
46
|
+
return held.run({ lockPath, token }, work);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async function acquireSharedLock(lockPath) {
|
|
51
|
+
try {
|
|
52
|
+
return await acquireDirectoryLock(lockPath, { timeoutMs: 0, reclaimDeadOwner: true });
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (!(error instanceof DirectoryLockContentionError))
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
console.warn(`Waiting for shared user-home provider deployment lock: ${lockPath}`);
|
|
59
|
+
try {
|
|
60
|
+
return await acquireDirectoryLock(lockPath, { timeoutMs: 120_000, reclaimDeadOwner: true });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (!(error instanceof DirectoryLockContentionError))
|
|
64
|
+
throw error;
|
|
65
|
+
throw new Error(`Timed out waiting for shared user-home provider deployment lock: ${lockPath}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export async function withProviderDeploymentLock(work) {
|
|
69
|
+
const release = await acquireProviderDeploymentLock();
|
|
70
|
+
try {
|
|
71
|
+
return await release.run(work);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
await release();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=deployment-lock.js.map
|