@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
|
@@ -100,6 +100,7 @@ async function handleSteward(args, ctx) {
|
|
|
100
100
|
aiwg steward — Provider capability awareness and command routing
|
|
101
101
|
|
|
102
102
|
Usage:
|
|
103
|
+
aiwg steward signed-merges [--apply|--skip] Optional signed local merge setup
|
|
103
104
|
aiwg steward decision-offload [--json] Offline advisory readiness and adoption report
|
|
104
105
|
aiwg steward capabilities --provider <name> Capabilities for a specific provider
|
|
105
106
|
aiwg steward capabilities --feature <name> Provider support matrix for a feature
|
|
@@ -129,6 +130,10 @@ async function handleSteward(args, ctx) {
|
|
|
129
130
|
`);
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
133
|
+
if (subcommand === 'signed-merges') {
|
|
134
|
+
const { stewardSignedMerges } = await import('./steward-signing.js');
|
|
135
|
+
return stewardSignedMerges(args.slice(1), ctx ? getProjectDir(ctx, args) : process.cwd());
|
|
136
|
+
}
|
|
132
137
|
if (subcommand === 'decision-offload') {
|
|
133
138
|
const unknown = args.slice(1).filter(arg => arg !== '--json');
|
|
134
139
|
if (unknown.length)
|
|
@@ -5,7 +5,9 @@ export const indexHandler = {
|
|
|
5
5
|
description: "Artifact index commands (build, query, deps, stats)",
|
|
6
6
|
category: "index",
|
|
7
7
|
aliases: [],
|
|
8
|
-
async help() {
|
|
8
|
+
async help(ctx) {
|
|
9
|
+
if (ctx.args[0] === "discover")
|
|
10
|
+
return discoverHandler.help(ctx);
|
|
9
11
|
const { printIndexUsage } = await import("../../artifacts/cli.js");
|
|
10
12
|
printIndexUsage();
|
|
11
13
|
return { exitCode: 0 };
|
|
@@ -67,6 +69,11 @@ export const discoverHandler = {
|
|
|
67
69
|
description: "Find AIWG operational assets by capability — index-driven on-demand discovery",
|
|
68
70
|
category: "index",
|
|
69
71
|
aliases: [],
|
|
72
|
+
async help() {
|
|
73
|
+
const { printDiscoverUsage } = await import("../../artifacts/discover-cli-help.js");
|
|
74
|
+
printDiscoverUsage();
|
|
75
|
+
return { exitCode: 0 };
|
|
76
|
+
},
|
|
70
77
|
async execute(ctx) {
|
|
71
78
|
try {
|
|
72
79
|
// Delegate to the same handler `aiwg index discover` uses, by
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export async function deployEachProvider(providers, deploy) {
|
|
2
|
+
const providerResults = new Map();
|
|
3
|
+
for (const [order, provider] of providers.entries()) {
|
|
4
|
+
try {
|
|
5
|
+
providerResults.set(provider, await deploy(provider, order));
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
providerResults.set(provider, { exitCode: 1, message: error instanceof Error ? error.message : String(error) });
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const failed = [...providerResults.values()].find(result => result.exitCode !== 0);
|
|
12
|
+
return { exitCode: failed?.exitCode ?? 0, message: failed?.message, providerResults };
|
|
13
|
+
}
|
|
14
|
+
export function resultForProvider(result, provider) {
|
|
15
|
+
return result.providerResults?.get(provider) ?? result;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=use-provider-results.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ContextWriteJournal } from '../../smiths/context-pipeline/context-file-safety.js';
|
|
2
2
|
import { trackTemporaryDirectory } from '../../utils/temporary-directory.js';
|
|
3
|
+
import { codexHookTrustNextStep, readCodexHookTrust } from '../../smiths/hook-bridge/codex-trust.js';
|
|
3
4
|
/**
|
|
4
5
|
* Use Command Handler
|
|
5
6
|
*
|
|
@@ -22,6 +23,7 @@ import { resolveOmpPaths } from '../../providers/omp-paths.mjs';
|
|
|
22
23
|
import YAML from 'yaml';
|
|
23
24
|
import { createScriptRunner } from './script-runner.js';
|
|
24
25
|
import { finalizePreparedProvider, prepareProviderDeployments } from '../services/provider-prepare-coordinator.js';
|
|
26
|
+
import { deployEachProvider, resultForProvider } from './use-provider-results.js';
|
|
25
27
|
import { getFrameworkRoot, getVersionInfo } from '../../channel/manager.mjs';
|
|
26
28
|
import { getRegistry } from '../../extensions/registry.js';
|
|
27
29
|
import { registerDeployedExtensions } from '../../extensions/deployment-registration.js';
|
|
@@ -2522,10 +2524,11 @@ export class UseHandler {
|
|
|
2522
2524
|
}
|
|
2523
2525
|
const providerResults = [];
|
|
2524
2526
|
for (const provider of providers) {
|
|
2527
|
+
const providerResult = resultForProvider(coreResult, provider);
|
|
2525
2528
|
const effectiveScope = provider === 'openclaw' || provider === 'openhuman'
|
|
2526
2529
|
? 'user'
|
|
2527
2530
|
: requestedScope;
|
|
2528
|
-
if (
|
|
2531
|
+
if (providerResult.exitCode === 0 && !dryRun) {
|
|
2529
2532
|
try {
|
|
2530
2533
|
const receiptOptions = {
|
|
2531
2534
|
projectRoot: projectDir,
|
|
@@ -2557,8 +2560,8 @@ export class UseHandler {
|
|
|
2557
2560
|
requestedBundles: [requestedBundle],
|
|
2558
2561
|
contextOptOut,
|
|
2559
2562
|
invocationStartedAt: dryRun ? undefined : startedAt,
|
|
2560
|
-
deploymentExitCode:
|
|
2561
|
-
deploymentMessage:
|
|
2563
|
+
deploymentExitCode: providerResult.exitCode,
|
|
2564
|
+
deploymentMessage: providerResult.message,
|
|
2562
2565
|
// A normal first deployment has no authenticated verifier handoff
|
|
2563
2566
|
// yet, so receipt absence belongs in doctor/status rather than
|
|
2564
2567
|
// degrading an otherwise successful `aiwg use` result.
|
|
@@ -2584,6 +2587,12 @@ export class UseHandler {
|
|
|
2584
2587
|
result.exitClassification = 'failure';
|
|
2585
2588
|
}
|
|
2586
2589
|
}
|
|
2590
|
+
const codexTrustStep = !dryRun && result.exitCode === 0 && requestedScope === 'project' && providers.includes('codex')
|
|
2591
|
+
? codexHookTrustNextStep(await readCodexHookTrust(projectDir)) : '';
|
|
2592
|
+
if (codexTrustStep)
|
|
2593
|
+
result.findings.push({
|
|
2594
|
+
id: 'codex-prompt-discovery-trust', provider: 'codex', severity: 'info', message: codexTrustStep,
|
|
2595
|
+
});
|
|
2587
2596
|
if (json) {
|
|
2588
2597
|
return { exitCode: result.exitCode, message: JSON.stringify(result, null, 2), rawOutput: true };
|
|
2589
2598
|
}
|
|
@@ -2608,7 +2617,7 @@ export class UseHandler {
|
|
|
2608
2617
|
});
|
|
2609
2618
|
return {
|
|
2610
2619
|
exitCode: result.exitCode,
|
|
2611
|
-
message: [coreResult.message, rendered, ...(previewActions ? [...previewActions].sort() : [])].filter(Boolean).join('\n'),
|
|
2620
|
+
message: [coreResult.message, rendered, ...(previewActions ? [...previewActions].sort() : []), codexTrustStep].filter(Boolean).join('\n'),
|
|
2612
2621
|
};
|
|
2613
2622
|
}
|
|
2614
2623
|
async executeCore(ctx, resolvedProviders) {
|
|
@@ -3467,20 +3476,17 @@ export class UseHandler {
|
|
|
3467
3476
|
let session;
|
|
3468
3477
|
try {
|
|
3469
3478
|
session = await prepareProviderDeployments(frameworkRoot, preparedJobs);
|
|
3470
|
-
|
|
3479
|
+
return await session.run(() => deployEachProvider(providers, async (requested, order) => {
|
|
3471
3480
|
await session.commit(order);
|
|
3472
3481
|
const capability = randomUUID();
|
|
3473
3482
|
this.preparedProviderContinuations.add(capability);
|
|
3474
3483
|
try {
|
|
3475
|
-
|
|
3476
|
-
if (result.exitCode !== 0)
|
|
3477
|
-
return result;
|
|
3484
|
+
return await this.execute({ ...ctx, args: [framework, '--provider', requested, preparedFlag, capability, ...remainingArgs] });
|
|
3478
3485
|
}
|
|
3479
3486
|
finally {
|
|
3480
3487
|
this.preparedProviderContinuations.delete(capability);
|
|
3481
3488
|
}
|
|
3482
|
-
}
|
|
3483
|
-
return { exitCode: 0 };
|
|
3489
|
+
}));
|
|
3484
3490
|
}
|
|
3485
3491
|
catch (error) {
|
|
3486
3492
|
return { exitCode: 1, message: `Concurrent provider preparation failed: ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -3489,12 +3495,7 @@ export class UseHandler {
|
|
|
3489
3495
|
await session?.dispose();
|
|
3490
3496
|
}
|
|
3491
3497
|
}
|
|
3492
|
-
|
|
3493
|
-
const result = await this.execute({ ...ctx, args: [framework, '--provider', p, ...remainingArgs] });
|
|
3494
|
-
if (result.exitCode !== 0)
|
|
3495
|
-
return result;
|
|
3496
|
-
}
|
|
3497
|
-
return { exitCode: 0 };
|
|
3498
|
+
return deployEachProvider(providers, p => this.execute({ ...ctx, args: [framework, '--provider', p, ...remainingArgs] }));
|
|
3498
3499
|
}
|
|
3499
3500
|
const requestedProvider = providers[0];
|
|
3500
3501
|
const projectLocalProviderResolution = await resolveProjectLocalProviderAdapter(projectDir, requestedProvider);
|
|
@@ -4094,10 +4095,10 @@ export class UseHandler {
|
|
|
4094
4095
|
// PUW-018 (#1119) cross-provider hook bridge — opt-in via
|
|
4095
4096
|
// --enable-cross-provider-hooks. When enabled and at least one canonical
|
|
4096
4097
|
// hook source exists at agentic/code/addons/aiwg-hooks/canonical/*.yaml,
|
|
4097
|
-
// translate to provider-native artifacts (Codex
|
|
4098
|
+
// translate to provider-native artifacts (Codex project JSON, Copilot JSON,
|
|
4098
4099
|
// Factory shell, Hermes Python plugin). Per ADR-3 §7 autoInstall policy
|
|
4099
4100
|
// this is opt-in.
|
|
4100
|
-
if (remainingArgs.includes('--enable-cross-provider-hooks') && !dryRun) {
|
|
4101
|
+
if (remainingArgs.includes('--enable-cross-provider-hooks') && !remainingArgs.includes('--no-hooks') && !dryRun) {
|
|
4101
4102
|
try {
|
|
4102
4103
|
const { loadHookSources, bridgeAll } = await import('../../smiths/hook-bridge/index.js');
|
|
4103
4104
|
const { sources, errors } = await loadHookSources(frameworkRoot);
|
package/dist/src/cli/router.js
CHANGED
|
@@ -23,6 +23,7 @@ import { maybeAppendCommandLog } from './command-log.js';
|
|
|
23
23
|
import { maybeAppendSkillUsage } from './skill-usage.js';
|
|
24
24
|
// Cached loaded registry
|
|
25
25
|
let cachedRegistry = null;
|
|
26
|
+
let discoveryRegistry = null;
|
|
26
27
|
// Global hook registry and executor. Register built-in hooks at module
|
|
27
28
|
// load time so they fire for every command without per-handler wiring.
|
|
28
29
|
const hookRegistry = new HookRegistry();
|
|
@@ -36,7 +37,16 @@ hookRegistry.register(activityLogPostCommandHook);
|
|
|
36
37
|
*
|
|
37
38
|
* @returns Loaded registry with handlers
|
|
38
39
|
*/
|
|
39
|
-
export async function initRouter() {
|
|
40
|
+
export async function initRouter(discoveryOnly = false) {
|
|
41
|
+
if (discoveryOnly && !cachedRegistry) {
|
|
42
|
+
if (!discoveryRegistry) {
|
|
43
|
+
// Keep normal dispatch, hooks and logging; avoid importing every command's
|
|
44
|
+
// implementation and schema validators for the session's first lookup.
|
|
45
|
+
const { discoverHandler, indexHandler } = await import('./handlers/subcommands-discovery.js');
|
|
46
|
+
discoveryRegistry = await loadRegistry({ handlers: [discoverHandler, indexHandler] });
|
|
47
|
+
}
|
|
48
|
+
return discoveryRegistry;
|
|
49
|
+
}
|
|
40
50
|
if (!cachedRegistry) {
|
|
41
51
|
cachedRegistry = await loadRegistry({ indexCapabilities: true });
|
|
42
52
|
}
|
|
@@ -85,7 +95,7 @@ export async function run(args, options = {}) {
|
|
|
85
95
|
return;
|
|
86
96
|
}
|
|
87
97
|
const started = process.hrtime.bigint();
|
|
88
|
-
const registry = await initRouter();
|
|
98
|
+
const registry = await initRouter(args[0] === 'discover' || args[0] === 'index' && args[1] === 'discover');
|
|
89
99
|
// Normalize `help <command>` into the same non-executing help path.
|
|
90
100
|
const routedArgs = args[0] === 'help' && args[1] && !args[1].startsWith('-')
|
|
91
101
|
? [args[1], ...args.slice(2), '--help']
|
|
@@ -594,6 +594,8 @@ export async function verifyProviderDeployment(options) {
|
|
|
594
594
|
}
|
|
595
595
|
const diagnostics = await diagnoseWorkspaceContext(options.projectRoot);
|
|
596
596
|
for (const diagnostic of diagnostics) {
|
|
597
|
+
if (diagnostic.code === 'codex-prompt-discovery-trust')
|
|
598
|
+
continue; // Doctor advisory; use appends its short next step.
|
|
597
599
|
if (diagnostic.severity === 'info')
|
|
598
600
|
continue;
|
|
599
601
|
findings.push(finding(normalized, `context-diagnostic:${diagnostic.code}`, diagnostic.severity === 'error' ? 'blocking' : 'advisory', diagnostic.message, diagnostic.severity === 'error'
|
|
@@ -895,13 +897,15 @@ export function renderUseDeploymentResult(result, options = {}) {
|
|
|
895
897
|
else {
|
|
896
898
|
lines.push(' Unavailable — the framework index could not be read.');
|
|
897
899
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
900
|
+
for (const severity of ['blocking', 'advisory']) {
|
|
901
|
+
const visibleFindings = result.findings.filter((candidate) => candidate.severity === severity);
|
|
902
|
+
if (visibleFindings.length > 0) {
|
|
903
|
+
lines.push('', severity === 'blocking' ? 'Blocking findings' : 'Advisories');
|
|
904
|
+
for (const item of visibleFindings) {
|
|
905
|
+
lines.push(...wrapParagraph(`${item.provider}: ${item.message}`, width));
|
|
906
|
+
if (item.remediation)
|
|
907
|
+
lines.push(...wrapParagraph(`Fix: ${item.remediation}`, width, ' '));
|
|
908
|
+
}
|
|
905
909
|
}
|
|
906
910
|
}
|
|
907
911
|
if (options.verbose) {
|
|
@@ -142,7 +142,9 @@ export async function mirrorArtifactDir(src, dst, ownedThisCall = new Set()) {
|
|
|
142
142
|
}
|
|
143
143
|
if (Object.keys(copiedRecords).length) {
|
|
144
144
|
const sidecarPath = path.resolve(dst, SIDECAR);
|
|
145
|
-
|
|
145
|
+
// Receipt sidecars are always captured as bytes.
|
|
146
|
+
const priorBytes = before.get(sidecarPath);
|
|
147
|
+
const prior = receipt(Buffer.isBuffer(priorBytes) ? priorBytes : undefined);
|
|
146
148
|
const next = { ...prior, managed: { ...object(prior.managed), ...copiedRecords } };
|
|
147
149
|
await fs.writeFile(sidecarPath, `${JSON.stringify(next, null, 2)}\n`);
|
|
148
150
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateDeliverySettings } from './delivery-validation.js';
|
|
1
2
|
import { validateInstalled } from './installed-validation.js';
|
|
2
3
|
import { preserveInstalledSelection } from './installed-selection.js';
|
|
3
4
|
import { validateHitlPolicy } from '../policy/hitl-validation.js';
|
|
@@ -29,7 +30,7 @@ import { readFileSync, existsSync } from 'node:fs';
|
|
|
29
30
|
import { readFile, access, readdir } from 'fs/promises';
|
|
30
31
|
import { createHash } from 'crypto';
|
|
31
32
|
import { resolve, join, isAbsolute } from 'path';
|
|
32
|
-
import { normalizeNamedCaptures } from '
|
|
33
|
+
import { normalizeNamedCaptures } from './index-graph-overrides.js';
|
|
33
34
|
import { getProviderDefinition, getProviderKernelSkillPath, PROVIDER_IDS, resolveProviderPathValue, } from '../providers/provider-definitions.js';
|
|
34
35
|
import { validateAuthorization, } from '../policy/authorization.js';
|
|
35
36
|
import { projectAiwgPath, projectControlPath, resolveProjectAiwgDir, } from './project-artifacts.js';
|
|
@@ -169,6 +170,7 @@ export function resolveDelivery(delivery) {
|
|
|
169
170
|
},
|
|
170
171
|
},
|
|
171
172
|
merge_style: delivery?.merge_style ?? 'rebase-merge',
|
|
173
|
+
merge: delivery?.merge ?? 'tracker',
|
|
172
174
|
delete_branch_on_merge: delivery?.delete_branch_on_merge ?? true,
|
|
173
175
|
require_ci_green: delivery?.require_ci_green ?? true,
|
|
174
176
|
require_signed_commits: delivery?.require_signed_commits ?? false,
|
|
@@ -994,6 +996,7 @@ export async function readAiwgConfigCandidate(projectDir) {
|
|
|
994
996
|
const threatAssessmentErrors = [
|
|
995
997
|
...validateThreatAssessmentConfig(parsed.security?.threatAssessment),
|
|
996
998
|
...validateProjectConfig(parsed.project),
|
|
999
|
+
...validateDeliverySettings(parsed),
|
|
997
1000
|
...validateParallelismConfig(parsed.parallelism),
|
|
998
1001
|
...validateDecisionConfig(parsed.decision),
|
|
999
1002
|
...validateRulePinCapabilities(parsed.rules, installedRuleCapabilities(loadRulePinConfigs(projectDir, parsed)), loadRulePinConfigs(projectDir, parsed).user.rules?.pin_groups),
|
|
@@ -1083,6 +1086,7 @@ async function writeAiwgConfigUnlocked(projectDir, config) {
|
|
|
1083
1086
|
const threatAssessmentErrors = [
|
|
1084
1087
|
...validateThreatAssessmentConfig(config.security?.threatAssessment),
|
|
1085
1088
|
...validateProjectConfig(config.project),
|
|
1089
|
+
...validateDeliverySettings(config),
|
|
1086
1090
|
...validateParallelismConfig(config.parallelism),
|
|
1087
1091
|
...validateDecisionConfig(config.decision),
|
|
1088
1092
|
...validateRulePinCapabilities(config.rules, installedRuleCapabilities(loadRulePinConfigs(projectDir, config)), loadRulePinConfigs(projectDir, config).user.rules?.pin_groups),
|
package/dist/src/config/cli.js
CHANGED
|
@@ -175,6 +175,7 @@ const ENUM_ALIAS_NOTES = {
|
|
|
175
175
|
};
|
|
176
176
|
const ENUM_RULES = {
|
|
177
177
|
'delivery.mode': ['direct', 'feature-branch', 'pr-required'],
|
|
178
|
+
'delivery.merge': ['local-signed', 'local', 'tracker'],
|
|
178
179
|
'delivery.merge_style': ['rebase-merge', 'squash', 'merge', 'fast-forward-only'],
|
|
179
180
|
'delivery.force_push_policy': ['never', 'own-branch-only', 'allowed'],
|
|
180
181
|
'delivery.signing.format': ['openpgp', 'ssh', 'x509'],
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function validateDeliverySettings(config) {
|
|
2
|
+
const errors = [];
|
|
3
|
+
const delivery = config.delivery;
|
|
4
|
+
if (delivery?.merge !== undefined && !['local-signed', 'local', 'tracker'].includes(delivery.merge))
|
|
5
|
+
errors.push('delivery.merge must be local-signed, local, or tracker');
|
|
6
|
+
for (const name of ['tracker_actor', 'customer_tracker_actor']) {
|
|
7
|
+
const credential = config.remotes?.[name]?.credential;
|
|
8
|
+
if (credential !== undefined) {
|
|
9
|
+
const entries = credential && typeof credential === 'object' ? Object.entries(credential) : [];
|
|
10
|
+
if (entries.length !== 1 || !entries.every(([key, value]) => typeof value === 'string' &&
|
|
11
|
+
(key === 'env' ? /^[A-Za-z_][A-Za-z0-9_]*$/.test(value) : key === 'store' && /^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(value)))) {
|
|
12
|
+
errors.push(`remotes.${name}.credential requires exactly one store or env reference`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (delivery?.merge === 'local-signed' && (!delivery.signing?.key || !delivery.committer?.name || !delivery.committer.email)) {
|
|
17
|
+
errors.push('delivery.merge=local-signed requires signing.key and committer.name/email');
|
|
18
|
+
}
|
|
19
|
+
return errors;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=delivery-validation.js.map
|
|
@@ -12,7 +12,7 @@ export interface HostResourceReport {
|
|
|
12
12
|
slots: number;
|
|
13
13
|
ok: boolean;
|
|
14
14
|
limits: Array<{ threshold: string; slots: number }>;
|
|
15
|
-
failures: Array<{ signal: string; reason: string; actual?: number; threshold?: number }>;
|
|
15
|
+
failures: Array<{ signal: string; reason: string; code?: 'OG_HOST_ATTRIBUTION' | 'OG_HOST_CAPACITY'; actual?: number; threshold?: number }>;
|
|
16
16
|
counting?: string;
|
|
17
17
|
limitingThreshold?: string;
|
|
18
18
|
groups: Array<{ group: string; maxParallel: number | null; slots: number | null; reason: string }>;
|
|
@@ -31,7 +31,8 @@ export function hostResourceReport({ config, live, readers, paths, thresholdOver
|
|
|
31
31
|
throw new Error(`Unknown group "${group}"; configured groups: ${Object.keys(configured).join(', ') || '(none)'}`);
|
|
32
32
|
}
|
|
33
33
|
// Local collection and evaluation share one clock; supplied snapshots retain their source time.
|
|
34
|
-
const measured = live ?? readLiveHostResources({ ...readers, now, paths,
|
|
34
|
+
const measured = live ?? readLiveHostResources({ ...readers, now, paths, workspace: readers?.workspace ?? paths?.[0],
|
|
35
|
+
groupNames: Object.keys(configured) });
|
|
35
36
|
const evaluated = now();
|
|
36
37
|
const origins = {};
|
|
37
38
|
let thresholds;
|
|
@@ -72,8 +73,13 @@ export function hostResourceReport({ config, live, readers, paths, thresholdOver
|
|
|
72
73
|
'less than one core of load headroom');
|
|
73
74
|
if (thresholds.max_workers !== undefined) add('max_workers', thresholds.max_workers - measured.workers,
|
|
74
75
|
'running workers exhaust the host ceiling or cannot be counted');
|
|
76
|
+
// The project ceiling counts this workspace's attributed workers plus unattributed ones;
|
|
77
|
+
// workers attributed to another workspace consume host capacity (max_workers) only.
|
|
78
|
+
const attributed = Object.values(measured.workerGroups ?? {}).reduce((sum, count) => sum + count, 0);
|
|
79
|
+
const projectRunning = Number.isFinite(measured.workers) && measured.workerGroups && Number.isFinite(measured.workerUnknown)
|
|
80
|
+
? Math.min(measured.workers, attributed + measured.workerUnknown) : measured.workers;
|
|
75
81
|
const admission = [
|
|
76
|
-
{ threshold: 'max_parallel_subagents', limit: parallelism?.max_parallel_subagents
|
|
82
|
+
{ threshold: 'max_parallel_subagents', running: projectRunning, limit: parallelism?.max_parallel_subagents
|
|
77
83
|
?? (parallelism?.worker_dispatch ? getProviderParallelismDefaults(config?.providers?.[0]).max_parallel_subagents : undefined) },
|
|
78
84
|
...(caps ?? []),
|
|
79
85
|
];
|
|
@@ -82,8 +88,9 @@ export function hostResourceReport({ config, live, readers, paths, thresholdOver
|
|
|
82
88
|
if (limit !== undefined && limit !== null) add(threshold, limit - running,
|
|
83
89
|
'admission capacity exhausted or worker count unavailable');
|
|
84
90
|
}
|
|
91
|
+
const unknown = measured.workerUnknown
|
|
92
|
+
?? measured.workers - Object.values(measured.workerGroups ?? {}).reduce((sum, count) => sum + count, 0);
|
|
85
93
|
const groups = Object.entries(configured).map(([id, settings]) => {
|
|
86
|
-
const unknown = measured.workers - Object.values(measured.workerGroups ?? {}).reduce((sum, count) => sum + count, 0);
|
|
87
94
|
const running = (measured.workerGroups?.[id] ?? 0) + unknown;
|
|
88
95
|
const candidates = [
|
|
89
96
|
{ threshold: `groups.${id}.maxParallel`, limit: settings.maxParallel },
|
|
@@ -101,10 +108,22 @@ export function hostResourceReport({ config, live, readers, paths, thresholdOver
|
|
|
101
108
|
return { group: id, maxParallel: settings.maxParallel ?? null, slots,
|
|
102
109
|
reason: threshold ? `${threshold}: ${reason}` : reason };
|
|
103
110
|
});
|
|
111
|
+
// Capacity diagnostics retain inspectable census identities without environment contents.
|
|
112
|
+
const blockers = measured.workerAttributions ?? [];
|
|
113
|
+
for (const failure of failures) {
|
|
114
|
+
if (/workers|max_parallel|admission|groups\./.test(failure.signal)) {
|
|
115
|
+
failure.code = unknown > 0 && !failure.signal.endsWith('.enabled')
|
|
116
|
+
? 'OG_HOST_ATTRIBUTION' : 'OG_HOST_CAPACITY';
|
|
117
|
+
if (!blockers.length) continue;
|
|
118
|
+
failure.reason += `; host workers=${measured.workers ?? 'unavailable'}, unattributed=${unknown ?? 'unavailable'}; counted: `
|
|
119
|
+
+ (blockers.map(record => `${record.kind}:${record.id} (${record.attribution}${record.workspace ? `, ${record.workspace}/${record.group}` : ''})`).join(', ') || 'identities unavailable');
|
|
120
|
+
if (failure.code === 'OG_HOST_ATTRIBUTION') failure.reason += '; recovery: aiwg doctor --resources --json; see docs/getting-started/worker-attribution.md (relaunch through marked launch paths; never relabel another owner\'s jobs)';
|
|
121
|
+
}
|
|
122
|
+
}
|
|
104
123
|
const slots = failures.length ? 0 : Math.min(...limits.map(limit => limit.slots));
|
|
105
124
|
const limitingThreshold = failures[0]?.signal ?? [...limits].sort((a, b) => a.slots - b.slots)[0]?.threshold;
|
|
106
125
|
return { measured, freshness: snapshot, thresholds, origins, slots, ok: slots > 0, limits, failures, groups, limitingThreshold,
|
|
107
126
|
counting: 'current UID AIWG worker units plus distinct AIWG_WORKER_INVOCATION_ID markers outside those units; '
|
|
108
127
|
+ (measured.workerCountingSource === 'owned-process-fallback' ? 'systemd unavailable: owned-process fallback; ' : '')
|
|
109
|
-
+ 'hostCliProcesses: exact codex/muse/muse-bin comm, informational, not used for admission; group attribution uses unambiguous configured prefixes in existing invocation markers or unit names; unattributed workers count against every group; tuple caps without attribution use owned worker total' };
|
|
128
|
+
+ 'hostCliProcesses: exact codex/muse/muse-bin comm, informational, not used for admission; group attribution uses workspace/group markers or unambiguous configured prefixes in existing invocation markers or unit names; unattributed workers count against every group and host capacity; tuple caps without attribution use owned worker total' };
|
|
110
129
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
export interface WorkerAttribution {
|
|
2
|
+
kind: 'unit' | 'unit-count' | 'invocation'; id: string; count: number;
|
|
3
|
+
attribution: 'attributed' | 'unknown' | 'conflicting'; workspace?: string; group?: string;
|
|
4
|
+
}
|
|
1
5
|
export interface HostResourceSample {
|
|
2
6
|
/** Start of collection on the source host; absent on legacy/unavailable snapshots. */
|
|
3
7
|
collectedAt?: string;
|
|
4
8
|
supported: boolean; reason?: string; availMemGb?: number; load1?: number; cores?: number;
|
|
5
9
|
loadRatio?: number; memPsiAvg10?: number; memPsiAvg60?: number; memPsiAvg300?: number;
|
|
10
|
+
workerAttributions?: WorkerAttribution[]; workerWorkspace?: string; workerUnknown?: number;
|
|
6
11
|
workerGroups?: Record<string, number>;
|
|
7
12
|
workers?: number; hostCliProcesses?: Record<string, number>; workerUnits?: number; freeDiskGb?: number;
|
|
8
13
|
workerCountingSource?: 'systemd-units-and-marked-processes' | 'owned-process-fallback';
|
|
9
14
|
}
|
|
10
15
|
export interface WorkerCensus {
|
|
16
|
+
attributions?: WorkerAttribution[]; workspace?: string; unknown?: number;
|
|
11
17
|
byGroup?: Record<string, number>;
|
|
12
18
|
total: number; hostCliProcesses?: Record<string, number>; units?: number;
|
|
13
19
|
source?: HostResourceSample['workerCountingSource'];
|
|
@@ -18,6 +24,7 @@ export interface HostResourceReaders {
|
|
|
18
24
|
readDir?: (path: string) => string[];
|
|
19
25
|
uid?: number;
|
|
20
26
|
groupNames?: string[];
|
|
27
|
+
workspace?: string;
|
|
21
28
|
coreCount?: () => number;
|
|
22
29
|
countWorkers?: () => number | undefined | WorkerCensus;
|
|
23
30
|
countWorkerUnits?: () => number | undefined;
|
|
@@ -27,6 +34,7 @@ export interface HostResourceReaders {
|
|
|
27
34
|
paths?: string[];
|
|
28
35
|
}
|
|
29
36
|
export function readLiveHostResources(readers?: HostResourceReaders): HostResourceSample;
|
|
37
|
+
export function nearestDispatchPathSync(filename: string, fsOps?: { lstat?: (path: string) => { isDirectory(): boolean }; access?: (path: string, mode: number) => void }): string;
|
|
30
38
|
export function countWorkerProcesses(readers?: HostResourceReaders): WorkerCensus | undefined;
|
|
31
39
|
export function defaultCountWorkers(readers?: HostResourceReaders): number | undefined;
|
|
32
40
|
export function countWorkerUnits(options?: { spawn?: (...args: any[]) => any }): number | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Linux host measurements shared by dispatch preflight and resource reports.
|
|
2
|
-
import { readFileSync, readdirSync, statfsSync } from 'node:fs';
|
|
2
|
+
import { accessSync, constants as fsConstants, lstatSync, readFileSync, readdirSync, statfsSync } from 'node:fs';
|
|
3
3
|
import os from 'node:os';
|
|
4
|
+
import { dirname } from 'node:path';
|
|
4
5
|
import { spawnSync } from 'node:child_process';
|
|
5
|
-
import {
|
|
6
|
+
import { readWorkerAttribution, workerWorkspace } from './worker-attribution.mjs';
|
|
6
7
|
const BYTES_PER_GB = 1024 ** 3;
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -73,6 +74,7 @@ function countWorkerProcesses({
|
|
|
73
74
|
readDir = readdirSync,
|
|
74
75
|
readText = path => readFileSync(path, 'utf8'),
|
|
75
76
|
uid = process.getuid?.(),
|
|
77
|
+
workspace,
|
|
76
78
|
groupNames = [],
|
|
77
79
|
listWorkerUnits: readUnitList,
|
|
78
80
|
countWorkerUnits: readUnitCount,
|
|
@@ -86,8 +88,10 @@ function countWorkerProcesses({
|
|
|
86
88
|
if (Number.isInteger(counted) && counted >= 0) units = counted;
|
|
87
89
|
} catch { /* Owned-process scanning remains available. */ }
|
|
88
90
|
const source = units === undefined ? 'owned-process-fallback' : 'systemd-units-and-marked-processes';
|
|
89
|
-
|
|
91
|
+
const currentWorkspace = workerWorkspace(workspace);
|
|
92
|
+
// Keep legacy unambiguous group names; explicit markers add workspace ownership.
|
|
90
93
|
const identify = value => new Set(groupNames.filter(name => value === name || value.startsWith(`${name}-`)));
|
|
94
|
+
const unitEvidence = new Map([...(unitNames ?? [])].map(unit => [unit, new Set()]));
|
|
91
95
|
const unitGroups = new Map([...(unitNames ?? [])].map(unit =>
|
|
92
96
|
[unit, identify(unit.slice('aiwg-worker-'.length, -'.service'.length))]));
|
|
93
97
|
let entries, procUnavailable = false;
|
|
@@ -97,9 +101,7 @@ function countWorkerProcesses({
|
|
|
97
101
|
entries = []; procUnavailable = true;
|
|
98
102
|
}
|
|
99
103
|
const hostCliProcesses = { codex: 0, muse: 0 };
|
|
100
|
-
const invocations = new
|
|
101
|
-
const invocationGroups = new Map();
|
|
102
|
-
const merge = (target, evidence) => { for (const name of evidence) target.add(name); };
|
|
104
|
+
const invocations = new Map();
|
|
103
105
|
for (const entry of entries) {
|
|
104
106
|
if (!/^\d+$/.test(entry)) continue;
|
|
105
107
|
try {
|
|
@@ -112,27 +114,42 @@ function countWorkerProcesses({
|
|
|
112
114
|
const comm = optional('comm').trim();
|
|
113
115
|
if (comm === 'codex') hostCliProcesses.codex += 1;
|
|
114
116
|
if (comm === 'muse-bin' || comm === 'muse') hostCliProcesses.muse += 1;
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
if (!invocation)
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
const evidence = readWorkerAttribution(optional('environ'));
|
|
118
|
+
if (!evidence.invocation) continue;
|
|
119
|
+
if (!invocations.has(evidence.invocation)) invocations.set(evidence.invocation,
|
|
120
|
+
{ evidence: new Set(), groups: identify(evidence.invocation), units: new Set() });
|
|
121
|
+
const record = invocations.get(evidence.invocation);
|
|
122
|
+
if (evidence.workspace && evidence.group) record.evidence.add(JSON.stringify([evidence.workspace, evidence.group]));
|
|
120
123
|
const cgroupUnits = optional('cgroup').match(/aiwg-worker-[^/\s]+\.service(?=\/|\s|$)/g) ?? [];
|
|
121
|
-
|
|
122
|
-
for (const unit of cgroupUnits.filter(unit => unitGroups.has(unit))) {
|
|
123
|
-
merge(unitGroups.get(unit), invocationGroups.get(invocation));
|
|
124
|
-
}
|
|
124
|
+
for (const unit of cgroupUnits.filter(unit => unitNames ? unitNames.has(unit) : units > 0)) record.units.add(unit);
|
|
125
125
|
} catch { /* Processes may exit during the scan. */ }
|
|
126
126
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const [name] = evidence;
|
|
132
|
-
byGroup[name] = (byGroup[name] ?? 0) + 1;
|
|
127
|
+
for (const record of invocations.values()) {
|
|
128
|
+
for (const unit of record.units) {
|
|
129
|
+
if (unitEvidence.has(unit)) for (const evidence of record.evidence) unitEvidence.get(unit).add(evidence);
|
|
130
|
+
if (unitGroups.has(unit)) for (const name of record.groups) unitGroups.get(unit).add(name);
|
|
133
131
|
}
|
|
134
132
|
}
|
|
135
|
-
|
|
133
|
+
const attributions = [];
|
|
134
|
+
const byGroup = {};
|
|
135
|
+
let unknown = 0;
|
|
136
|
+
const add = (kind, id, evidence, legacyGroups = new Set(), count = 1) => {
|
|
137
|
+
const identity = evidence.size === 1 ? JSON.parse([...evidence][0])
|
|
138
|
+
: !evidence.size && legacyGroups.size === 1 ? [null, [...legacyGroups][0]] : undefined;
|
|
139
|
+
const record = { kind, id, count, attribution: identity ? 'attributed' : evidence.size ? 'conflicting' : 'unknown',
|
|
140
|
+
...(identity ? { ...(identity[0] ? { workspace: identity[0] } : {}), group: identity[1] } : {}) };
|
|
141
|
+
attributions.push(record);
|
|
142
|
+
if (!identity || (identity[0] && !currentWorkspace)) unknown += count;
|
|
143
|
+
if (identity && (!identity[0] || identity[0] === currentWorkspace)) {
|
|
144
|
+
byGroup[identity[1]] = (byGroup[identity[1]] ?? 0) + count;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
for (const [unit, evidence] of unitEvidence) add('unit', unit, evidence, unitGroups.get(unit));
|
|
148
|
+
if (units > 0 && !unitNames) add('unit-count', '(unit identities unavailable)', new Set(), new Set(), units);
|
|
149
|
+
for (const [id, record] of invocations) if (!record.units.size) add('invocation', id, record.evidence, record.groups);
|
|
150
|
+
return { byGroup, attributions, workspace: currentWorkspace,
|
|
151
|
+
unknown,
|
|
152
|
+
total: (units ?? 0) + [...invocations.values()].filter(record => !record.units.size).length,
|
|
136
153
|
...(procUnavailable ? {} : { hostCliProcesses }), units, source };
|
|
137
154
|
}
|
|
138
155
|
|
|
@@ -157,6 +174,31 @@ function toFreeDiskGb(disk) {
|
|
|
157
174
|
return Number.isFinite(gb) && gb >= 0 ? gb : undefined;
|
|
158
175
|
}
|
|
159
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Pick the path to sample for a worker directory that may not exist yet,
|
|
179
|
+
* such as a final-output folder the launch creates (#3856). Mirrors the
|
|
180
|
+
* launcher's own rule (session-launcher.mjs workerDispatchPath): walk up only
|
|
181
|
+
* past missing entries to the nearest readable, searchable directory, and
|
|
182
|
+
* never settle on `/`. Anything else returns the original path so sampling
|
|
183
|
+
* still fails closed. Nothing is created.
|
|
184
|
+
*/
|
|
185
|
+
function nearestDispatchPathSync(filename, fsOps = {}) {
|
|
186
|
+
const lstat = fsOps.lstat ?? lstatSync;
|
|
187
|
+
const access = fsOps.access ?? accessSync;
|
|
188
|
+
let candidate = filename;
|
|
189
|
+
while (dirname(candidate) !== candidate) {
|
|
190
|
+
try {
|
|
191
|
+
if (!lstat(candidate).isDirectory()) return filename;
|
|
192
|
+
access(candidate, fsConstants.R_OK | fsConstants.X_OK);
|
|
193
|
+
return candidate;
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (error?.code !== 'ENOENT') return filename;
|
|
196
|
+
candidate = dirname(candidate);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return filename;
|
|
200
|
+
}
|
|
201
|
+
|
|
160
202
|
/**
|
|
161
203
|
* Sample free disk on the caller-supplied filesystem(s): `readers.paths`
|
|
162
204
|
* names the actual evidence root and worktree, and the gate takes the
|
|
@@ -235,7 +277,8 @@ function readLiveHostResources(readers = {}) {
|
|
|
235
277
|
memPsiAvg300: psi?.avg300,
|
|
236
278
|
workers: typeof workers === 'object' ? workers?.total : workers,
|
|
237
279
|
...(typeof workers === 'object' ? { hostCliProcesses: workers?.hostCliProcesses, workerUnits: workers?.units,
|
|
238
|
-
workerCountingSource: workers?.source, workerGroups: workers?.byGroup
|
|
280
|
+
workerCountingSource: workers?.source, workerGroups: workers?.byGroup, workerAttributions: workers?.attributions,
|
|
281
|
+
workerWorkspace: workers?.workspace, workerUnknown: workers?.unknown } : {}),
|
|
239
282
|
freeDiskGb: sampleFreeDiskGb(readers),
|
|
240
283
|
};
|
|
241
284
|
}
|
|
@@ -293,4 +336,4 @@ function evaluateDispatchGate(live, thresholds) {
|
|
|
293
336
|
}
|
|
294
337
|
|
|
295
338
|
|
|
296
|
-
export { parseMemAvailableGb, parseMemoryPsi, parseLoadAverages, listWorkerUnits, countWorkerUnits, countWorkerProcesses, defaultCountWorkers, readLiveHostResources, evaluateDispatchGate };
|
|
339
|
+
export { parseMemAvailableGb, parseMemoryPsi, parseLoadAverages, listWorkerUnits, countWorkerUnits, countWorkerProcesses, defaultCountWorkers, readLiveHostResources, evaluateDispatchGate, nearestDispatchPathSync };
|
|
@@ -33,4 +33,8 @@ export function validateIndexGraphOverrides(overrides) {
|
|
|
33
33
|
}
|
|
34
34
|
return errors;
|
|
35
35
|
}
|
|
36
|
+
/** Normalize graph filename patterns without loading artifact builders. */
|
|
37
|
+
export function normalizeNamedCaptures(pattern) {
|
|
38
|
+
return pattern.replace(/\(\?P</g, '(?<');
|
|
39
|
+
}
|
|
36
40
|
//# sourceMappingURL=index-graph-overrides.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WorkerResolvedInvocation } from '../mission-protocol/types.js';
|
|
2
|
+
export const WORKER_WORKSPACE_MARKER: 'AIWG_WORKER_WORKSPACE';
|
|
3
|
+
export const WORKER_GROUP_MARKER: 'AIWG_WORKER_GROUP';
|
|
4
|
+
export function workerWorkspace(value?: string): string | undefined;
|
|
5
|
+
export function workerAttributionEnvironment(invocationId: string, workspace: string, group: string): Record<string, string>;
|
|
6
|
+
export function directWorkerEnvironment(invocation: WorkerResolvedInvocation): Record<string, string>;
|
|
7
|
+
export function readWorkerAttribution(environment: string): { invocation?: string; workspace?: string; group?: string };
|