@aiwg/cli 2026.11.5 → 2026.11.7
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/providers/model-capabilities.v1.json +9 -9
- package/bin/aiwg.mjs +6 -4
- package/dist/src/activity-log/cli.js +1 -1
- package/dist/src/agents/agent-deployer.js +1 -1
- package/dist/src/artifacts/audit/types.js +1 -1
- package/dist/src/artifacts/browser-export.js +1 -0
- package/dist/src/artifacts/discover-facets.js +1 -1
- package/dist/src/artifacts/enrichment/prompt.js +1 -1
- package/dist/src/artifacts/enrichment/types.js +1 -1
- package/dist/src/artifacts/fortemi-core-query-adapter.js +2 -0
- package/dist/src/artifacts/index-builder.js +1 -0
- package/dist/src/artifacts/query-engine-discover-output.js +1 -0
- package/dist/src/artifacts/query-engine-discover.js +2 -2
- package/dist/src/artifacts/query-engine-scoring.js +7 -0
- package/dist/src/artifacts/template-output-kind.js +10 -0
- package/dist/src/artifacts/types.js +1 -1
- package/dist/src/artifacts/views/definition.js +1 -1
- package/dist/src/artifacts/views/types.js +1 -1
- package/dist/src/catalog/cli.js +1 -1
- package/dist/src/catalog/cli.mjs +1 -1
- package/dist/src/catalog/loader.js +1 -1
- package/dist/src/catalog/loader.mjs +1 -1
- package/dist/src/catalog/types.js +1 -1
- package/dist/src/cli/cli-extension-loader.js +19 -5
- package/dist/src/cli/cli-extension-paths.js +65 -0
- package/dist/src/cli/handlers/best-practices-audit.js +1 -1
- package/dist/src/cli/handlers/dataset.js +11 -2
- package/dist/src/cli/handlers/help.js +3 -4
- package/dist/src/cli/handlers/index.js +1 -1
- package/dist/src/cli/handlers/marketplace-plugin-search.js +37 -0
- package/dist/src/cli/handlers/marketplace.js +3 -1
- package/dist/src/cli/handlers/models.js +1 -1
- package/dist/src/cli/handlers/ralph-launcher.js +8 -2
- package/dist/src/cli/handlers/ralph.js +1 -1
- package/dist/src/cli/handlers/runtime-info.js +1 -1
- package/dist/src/cli/handlers/scaffolding.js +2 -2
- package/dist/src/cli/handlers/script-runner.js +1 -1
- package/dist/src/cli/handlers/sdlc-accelerate.js +1 -1
- package/dist/src/cli/handlers/subcommands-bundles.js +1 -1
- package/dist/src/cli/handlers/subcommands-list-format.js +19 -1
- package/dist/src/cli/handlers/types.js +1 -1
- package/dist/src/cli/handlers/update.js +26 -12
- package/dist/src/cli/handlers/use.js +6 -5
- package/dist/src/cli/handlers/utilities.js +1 -1
- package/dist/src/cli/handlers/version.js +1 -1
- package/dist/src/cli/handlers/workspace.js +1 -1
- package/dist/src/cli/handlers/writing.js +7 -1
- package/dist/src/cli/help-generator.js +9 -11
- package/dist/src/cli/hooks/builtin/activity-log-hook.js +1 -1
- package/dist/src/cli/router.js +1 -1
- package/dist/src/cli/workflow-orchestrator.js +1 -1
- package/dist/src/config/worker-context.js +37 -7
- package/dist/src/config/worker-parallelism.js +11 -0
- package/dist/src/contributors/detect.js +1 -1
- package/dist/src/contributors/discover.js +1 -1
- package/dist/src/contributors/heuristic.js +1 -1
- package/dist/src/contributors/index.js +1 -1
- package/dist/src/contributors/types.js +1 -1
- package/dist/src/contributors/validation.js +1 -1
- package/dist/src/dataset/backend-selection.d.ts +3 -0
- package/dist/src/dataset/backend-selection.js +11 -0
- package/dist/src/dataset/contract-range.d.ts +7 -0
- package/dist/src/dataset/contract-range.js +55 -0
- package/dist/src/dataset/fortemi-execution-bridge.d.ts +2 -0
- package/dist/src/dataset/fortemi-execution-bridge.js +12 -1
- package/dist/src/dataset/index.d.ts +2 -0
- package/dist/src/dataset/index.js +2 -0
- package/dist/src/dataset/orchestration-service.d.ts +1 -1
- package/dist/src/dataset/orchestration-service.js +7 -8
- package/dist/src/dataset/orchestration-types.d.ts +2 -0
- package/dist/src/dataset/service-binding-checkpoints.d.ts +10 -0
- package/dist/src/dataset/service-binding-checkpoints.js +26 -0
- package/dist/src/dataset/service-binding-contract.d.ts +46 -0
- package/dist/src/dataset/service-binding-contract.js +25 -0
- package/dist/src/dataset/service-binding-registry.d.ts +12 -0
- package/dist/src/dataset/service-binding-registry.js +118 -0
- package/dist/src/effects/worker-delivery.js +83 -0
- package/dist/src/extensions/capability-index.js +1 -1
- package/dist/src/extensions/commands/definitions.js +2 -2
- package/dist/src/extensions/deployment-registration.js +1 -1
- package/dist/src/extensions/index.js +1 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/manifest.js +27 -9
- package/dist/src/extensions/project-local-activity.js +1 -1
- package/dist/src/extensions/project-local-discovery.js +2 -2
- package/dist/src/extensions/project-local-doctor.js +9 -4
- package/dist/src/extensions/project-local-promote.js +3 -3
- package/dist/src/extensions/project-local-remove.js +3 -3
- package/dist/src/extensions/project-local-scaffold.js +1 -1
- package/dist/src/extensions/project-quickref-discovery.js +11 -0
- package/dist/src/extensions/project-quickref.js +4 -7
- package/dist/src/extensions/registry.js +1 -1
- package/dist/src/extensions/shadow-resolver.js +1 -1
- package/dist/src/extensions/types.js +1 -1
- package/dist/src/extensions/upstream-registry.js +1 -1
- package/dist/src/extensions/validation.js +1 -1
- package/dist/src/intake/git-history-analyzer.js +1 -1
- package/dist/src/kb/cli.js +1 -1
- package/dist/src/marketplace/plugin-directory.js +36 -0
- package/dist/src/marketplace/plugin-search.js +180 -0
- package/dist/src/mcp/cli.mjs +2 -2
- package/dist/src/mcp/helpers.mjs +1 -1
- package/dist/src/mcp/http-tools.mjs +8 -6
- package/dist/src/mcp/http-transport.mjs +3 -1
- package/dist/src/mcp/server.mjs +1 -1
- package/dist/src/mcp/tools/command-run.mjs +1 -1
- package/dist/src/mcp/tools/discovery.mjs +1 -1
- package/dist/src/mcp/tools/subsystems.mjs +1 -1
- package/dist/src/mcp/tools/worker-invoke.mjs +71 -23
- package/dist/src/mcp/tools/worker-launch-ledger.mjs +33 -0
- package/dist/src/mcp/tools/worker-local-only-preflight.mjs +79 -0
- package/dist/src/mcp/tools/worker-recorded-launch.mjs +26 -0
- package/dist/src/mcp/tools/worker-stdin-runtime.mjs +33 -6
- package/dist/src/mcp/tools/worker-verify-deliver-schema.mjs +49 -0
- package/dist/src/mcp/tools/worker-verify-deliver.mjs +25 -0
- package/dist/src/models/catalog-policy.js +2 -2
- package/dist/src/models/conductor-data-policy.mjs +83 -14
- package/dist/src/models/config-loader.js +2 -2
- package/dist/src/models/index.js +2 -2
- package/dist/src/models/local-endpoint-models.js +155 -0
- package/dist/src/models/model-capabilities.v1.json +9 -9
- package/dist/src/models/model-discovery.js +9 -5
- package/dist/src/models/opencode-worker-model.mjs +16 -0
- package/dist/src/models/resolver.js +2 -2
- package/dist/src/models/worker-installation.mjs +5 -3
- package/dist/src/models/worker-plan.js +1 -1
- package/dist/src/plugin/plugin-installer.js +2 -2
- package/dist/src/plugin/registry-validator.js +2 -2
- package/dist/src/plugin/skill-command-translator.js +1 -1
- package/dist/src/providers/deployment-input-session.d.mts +2 -0
- package/dist/src/providers/deployment-input-session.mjs +38 -0
- package/dist/src/rlm/cache/hash.js +1 -1
- package/dist/src/rlm/cache/store.js +1 -1
- package/dist/src/rlm/cache/types.js +1 -1
- package/dist/src/serve/worker-invocation-preparation.js +54 -22
- package/dist/src/serve/worker-invocation.js +25 -8
- package/dist/src/serve/worker-shell-prompt.d.mts +6 -0
- package/dist/src/serve/worker-shell-prompt.mjs +78 -0
- package/dist/src/skills/run.js +0 -11
- package/dist/src/smiths/agentsmith/generator.js +1 -1
- package/dist/src/smiths/context-pipeline/index.js +1 -1
- package/dist/src/smiths/context-pipeline/provider-policy.js +1 -1
- package/dist/src/smiths/context-pipeline/types.js +1 -1
- package/dist/src/smiths/mcpsmith/analyzers/cli-analyzer.js +2 -2
- package/dist/src/smiths/mcpsmith/generator.js +2 -2
- package/dist/src/smiths/mcpsmith/index.js +2 -2
- package/dist/src/smiths/mcpsmith/types.js +2 -2
- package/dist/src/smiths/skillsmith/collision-detector.js +1 -1
- package/dist/src/smiths/skillsmith/namespace-adapter.js +1 -1
- package/dist/src/smiths/toolsmith/runtime-discovery.mjs +2 -2
- package/dist/src/smiths/toolsmith/types.js +2 -2
- package/dist/src/storage/backends/fortemi.js +1 -1
- package/dist/src/storage/backends/fs.js +1 -1
- package/dist/src/storage/backends/logseq.js +1 -1
- package/dist/src/storage/backends/obsidian.js +1 -1
- package/dist/src/storage/cli.js +2 -2
- package/dist/src/storage/config.js +1 -1
- package/dist/src/storage/index.js +1 -1
- package/dist/src/storage/subsystem-cli.js +1 -1
- package/dist/src/storage/types.js +1 -1
- package/dist/src/testing/generators/test-case-generator.js +1 -1
- package/dist/src/writing/campaign-patterns.js +96 -0
- package/dist/src/writing/campaign-report.js +41 -0
- package/dist/src/writing/contextual-diagnostics.js +29 -5
- package/dist/src/writing/current-patterns.catalogue.json +87 -0
- package/dist/src/writing/current-patterns.js +99 -0
- package/dist/src/writing/prose-mask.js +80 -0
- package/dist/src/writing/structural-patterns.js +109 -0
- package/dist/src/writing/validation-campaign.js +19 -0
- package/dist/src/writing/validation-engine.js +18 -11
- package/dist/src/writing/validation-rules.js +4 -3
- package/package.json +11 -1
- package/schemas/dataset/service-binding.v1.schema.json +70 -0
- package/schemas/models/model-catalog.v1.schema.json +6 -3
- package/tools/agents/providers/base-models-platforms.mjs +87 -48
- package/tools/agents/providers/conductor-data-guard.mjs +1 -1
- package/tools/agents/providers/rule-deployment-corpus-inputs.mjs +19 -0
- package/tools/agents/providers/rule-deployment-input-session.mjs +40 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +15 -6
- package/tools/plugin/package-plugins.mjs +2 -0
- package/tools/ralph-external/lib/mcp-worker-launch.mjs +67 -0
- package/tools/ralph-external/lib/opencode-adapter.mjs +9 -7
- package/tools/ralph-external/lib/trusted-verification.mjs +1021 -0
- package/tools/ralph-external/lib/typed-stop-delivery.mjs +55 -0
- package/tools/ralph-external/lib/verification-isolation.mjs +509 -0
- package/tools/ralph-external/lib/worker-context.mjs +3 -3
- package/tools/ralph-external/lib/worker-delivery-guards.mjs +141 -0
- package/tools/ralph-external/lib/worker-delivery-record.mjs +15 -0
- package/tools/ralph-external/lib/worker-final.mjs +4 -1
- package/tools/ralph-external/lib/worker-isolation-status.mjs +3 -0
- package/tools/ralph-external/lib/worker-launch-cli.mjs +8 -0
- package/tools/ralph-external/lib/worker-local-only-paths.mjs +45 -0
- package/tools/ralph-external/lib/worker-prompt.mjs +4 -1
- package/tools/ralph-external/lib/worker-retry-evidence.mjs +2 -1
- package/tools/ralph-external/lib/worker-run-directory-refusal.mjs +2 -1
- package/tools/ralph-external/lib/worker-run-directory.mjs +45 -0
- package/tools/ralph-external/lib/worker-unit-cleanup.mjs +10 -2
- package/tools/ralph-external/lib/worker-verification-cli.mjs +164 -0
- package/tools/ralph-external/lib/worktree-preparation.mjs +417 -0
- package/tools/ralph-external/session-launcher.mjs +8 -15
- package/vscode-extension/schemas/aiwg.config.v1.json +27 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Pattern matches and legacy scores do not establish human or machine authorship.
|
|
6
6
|
*
|
|
7
7
|
* @implements @.aiwg/requirements/use-cases/UC-001-validate-ai-generated-content.md
|
|
8
|
-
* @architecture
|
|
8
|
+
* @architecture @docs/architecture/cli/index.md
|
|
9
9
|
* @nfr @.aiwg/requirements/nfr-modules/performance.md - NFR-PERF-001 (<60s validation)
|
|
10
10
|
* @nfr @.aiwg/requirements/nfr-modules/accuracy.md - NFR-ACC-001 (<5% false positives)
|
|
11
11
|
* @tests @test/unit/writing/validation-engine.test.ts
|
|
@@ -17,6 +17,9 @@ import { existsSync } from 'fs';
|
|
|
17
17
|
import { ValidationRuleLoader } from './validation-rules.js';
|
|
18
18
|
import { loadScoringConfig, getScoringConfig } from './scoring-config-loader.js';
|
|
19
19
|
import { diagnoseWriting } from './contextual-diagnostics.js';
|
|
20
|
+
import { currentPatternIssues, rhetoricalTriad } from './current-patterns.js';
|
|
21
|
+
import { validateCampaign } from './validation-campaign.js';
|
|
22
|
+
import { maskProse } from './prose-mask.js';
|
|
20
23
|
/**
|
|
21
24
|
* Core Writing Validation Engine
|
|
22
25
|
*/
|
|
@@ -59,13 +62,14 @@ export class WritingValidationEngine {
|
|
|
59
62
|
/**
|
|
60
63
|
* Validate content and return comprehensive results
|
|
61
64
|
*/
|
|
62
|
-
async validate(content, context) {
|
|
65
|
+
async validate(content, context, campaign = []) {
|
|
63
66
|
await this.initialize();
|
|
64
67
|
const issues = [];
|
|
65
68
|
// Run all detections
|
|
66
69
|
issues.push(...this.detectBannedPhrases(content, context));
|
|
67
70
|
issues.push(...this.detectAIPatterns(content, context));
|
|
68
71
|
issues.push(...this.detectFormulicStructures(content));
|
|
72
|
+
issues.push(...currentPatternIssues(content, campaign));
|
|
69
73
|
// Analyze authenticity
|
|
70
74
|
const authenticityAnalysis = this.analyzeAuthenticity(content);
|
|
71
75
|
// Check for missing authenticity markers
|
|
@@ -109,7 +113,9 @@ export class WritingValidationEngine {
|
|
|
109
113
|
/**
|
|
110
114
|
* Validate multiple files in batch
|
|
111
115
|
*/
|
|
112
|
-
async validateBatch(files, context) {
|
|
116
|
+
async validateBatch(files, context, options = {}) {
|
|
117
|
+
if (options.cross)
|
|
118
|
+
return validateCampaign(this, files, context);
|
|
113
119
|
const results = new Map();
|
|
114
120
|
// Process in parallel
|
|
115
121
|
await Promise.all(files.map(async (file) => {
|
|
@@ -207,6 +213,7 @@ export class WritingValidationEngine {
|
|
|
207
213
|
* Analyze content for authenticity markers
|
|
208
214
|
*/
|
|
209
215
|
analyzeAuthenticity(content) {
|
|
216
|
+
content = maskProse(content);
|
|
210
217
|
const humanMarkers = [];
|
|
211
218
|
const aiTells = [];
|
|
212
219
|
const missingMarkers = [];
|
|
@@ -232,7 +239,7 @@ export class WritingValidationEngine {
|
|
|
232
239
|
{ pattern: /\b(comprehensive|robust|innovative|optimal|best-in-class)\b/gi, name: 'vague intensifiers' },
|
|
233
240
|
{ pattern: /\b(it is important to note|it is worth noting|it should be mentioned)\b/gi, name: 'throat-clearing phrases' },
|
|
234
241
|
{ pattern: /\b(may help to|can serve to|has the potential to)\b/gi, name: 'excessive hedging' },
|
|
235
|
-
{ pattern:
|
|
242
|
+
{ pattern: rhetoricalTriad, name: 'three-item lists' }
|
|
236
243
|
];
|
|
237
244
|
for (const { pattern, name } of aiTellPatterns) {
|
|
238
245
|
const matches = content.match(pattern);
|
|
@@ -324,7 +331,7 @@ export class WritingValidationEngine {
|
|
|
324
331
|
findPatternMatches(content, pattern) {
|
|
325
332
|
const matches = [];
|
|
326
333
|
const regex = typeof pattern === 'string' ? new RegExp(pattern, 'gi') : pattern;
|
|
327
|
-
const lines = content.split('\n');
|
|
334
|
+
const lines = maskProse(content).split('\n');
|
|
328
335
|
let absolutePos = 0;
|
|
329
336
|
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
330
337
|
const line = lines[lineIdx];
|
|
@@ -335,7 +342,7 @@ export class WritingValidationEngine {
|
|
|
335
342
|
// Extract context (surrounding text)
|
|
336
343
|
const contextStart = Math.max(0, (match.index || 0) - 30);
|
|
337
344
|
const contextEnd = Math.min(line.length, (match.index || 0) + match[0].length + 30);
|
|
338
|
-
const context =
|
|
345
|
+
const context = content.slice(absolutePos + contextStart, absolutePos + contextEnd);
|
|
339
346
|
matches.push({
|
|
340
347
|
match: match[0],
|
|
341
348
|
location: {
|
|
@@ -356,12 +363,12 @@ export class WritingValidationEngine {
|
|
|
356
363
|
const warningCount = issues.filter(i => i.severity === 'warning').length;
|
|
357
364
|
const infoCount = issues.filter(i => i.severity === 'info').length;
|
|
358
365
|
// Count words and sentences
|
|
359
|
-
const words = content.split(/\s+/).filter(w => w.length > 0);
|
|
360
|
-
const sentences = content.split(/[.!?]+/).filter(s => s.trim().length > 0);
|
|
366
|
+
const words = maskProse(content).replace(/\u0001/g, ' ').split(/\s+/).filter(w => w.length > 0);
|
|
367
|
+
const sentences = maskProse(content).replace(/\u0001/g, ' ').split(/[.!?]+/).filter(s => s.trim().length > 0);
|
|
361
368
|
// Calculate AI pattern score (0-100, higher = more AI-like)
|
|
362
369
|
const config = getScoringConfig();
|
|
363
370
|
const aiPatternCount = issues.filter(i => i.type === 'ai_pattern' || i.type === 'banned_phrase').length;
|
|
364
|
-
const aiPatternScore = Math.min(100, (aiPatternCount / Math.max(1, words.length
|
|
371
|
+
const aiPatternScore = Math.min(100, (aiPatternCount * 50 / Math.max(1, words.length)) * config.issueScoring.aiPatternNormalizer);
|
|
365
372
|
return {
|
|
366
373
|
totalIssues: issues.length,
|
|
367
374
|
criticalCount,
|
|
@@ -378,9 +385,9 @@ export class WritingValidationEngine {
|
|
|
378
385
|
// Start with authenticity score
|
|
379
386
|
let score = authenticityAnalysis.score;
|
|
380
387
|
// Deduct for critical issues (heavy penalty)
|
|
381
|
-
score -= summary.criticalCount * config.issueScoring.criticalPenalty;
|
|
388
|
+
score -= summary.criticalCount * 50 / Math.max(1, summary.wordCount) * config.issueScoring.criticalPenalty;
|
|
382
389
|
// Deduct for warnings (moderate penalty)
|
|
383
|
-
score -= summary.warningCount * config.issueScoring.warningPenalty;
|
|
390
|
+
score -= summary.warningCount * 50 / Math.max(1, summary.wordCount) * config.issueScoring.warningPenalty;
|
|
384
391
|
// Deduct for high AI pattern score
|
|
385
392
|
score -= summary.aiPatternScore * config.issueScoring.aiPatternMultiplier;
|
|
386
393
|
// Clamp to 0-100
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { readFile } from 'fs/promises';
|
|
8
8
|
import { existsSync } from 'fs';
|
|
9
9
|
import { join } from 'path';
|
|
10
|
+
import { rhetoricalTriad } from './current-patterns.js';
|
|
10
11
|
/**
|
|
11
12
|
* Loads validation rules from AIWG markdown files
|
|
12
13
|
*/
|
|
@@ -368,10 +369,10 @@ export class ValidationRuleLoader {
|
|
|
368
369
|
{
|
|
369
370
|
id: 'struct_three_items',
|
|
370
371
|
type: 'formulaic_structure',
|
|
371
|
-
pattern:
|
|
372
|
+
pattern: rhetoricalTriad,
|
|
372
373
|
severity: 'info',
|
|
373
|
-
message: '
|
|
374
|
-
suggestion: '
|
|
374
|
+
message: 'Rhetorical three-item predicate detected',
|
|
375
|
+
suggestion: 'Replace generic claims with supported details; retain real inventories',
|
|
375
376
|
category: 'Lists'
|
|
376
377
|
}
|
|
377
378
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwg/cli",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.7",
|
|
4
4
|
"description": "Lightweight AIWG CLI for signed, versioned web-backed resources.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,9 +67,17 @@
|
|
|
67
67
|
"tools/ralph-external/lib/worker-inputs.mjs",
|
|
68
68
|
"tools/ralph-external/lib/worker-final.mjs",
|
|
69
69
|
"tools/ralph-external/lib/worker-prompt.mjs",
|
|
70
|
+
"tools/ralph-external/lib/worker-verification-cli.mjs",
|
|
71
|
+
"tools/ralph-external/lib/worker-delivery-guards.mjs",
|
|
72
|
+
"tools/ralph-external/lib/typed-stop-delivery.mjs",
|
|
73
|
+
"tools/ralph-external/lib/trusted-verification.mjs",
|
|
74
|
+
"tools/ralph-external/lib/verification-isolation.mjs",
|
|
75
|
+
"tools/ralph-external/lib/worker-delivery-record.mjs",
|
|
76
|
+
"tools/ralph-external/lib/mcp-worker-launch.mjs",
|
|
70
77
|
"tools/ralph-external/lib/worker-capture.mjs",
|
|
71
78
|
"tools/ralph-external/lib/worker-launch-cli.mjs",
|
|
72
79
|
"tools/ralph-external/lib/worker-run-directory-refusal.mjs",
|
|
80
|
+
"tools/ralph-external/lib/worker-run-directory.mjs",
|
|
73
81
|
"tools/ralph-external/lib/worker-isolation.mjs",
|
|
74
82
|
"tools/ralph-external/lib/worker-isolation-args.mjs",
|
|
75
83
|
"tools/ralph-external/lib/worker-unit-cleanup.mjs",
|
|
@@ -81,6 +89,8 @@
|
|
|
81
89
|
"tools/ralph-external/lib/worker-invocation-processes.mjs",
|
|
82
90
|
"tools/ralph-external/lib/worker-invocation-ancestry.mjs",
|
|
83
91
|
"tools/ralph-external/lib/worker-context.mjs",
|
|
92
|
+
"tools/ralph-external/lib/worktree-preparation.mjs",
|
|
93
|
+
"tools/ralph-external/lib/worker-local-only-paths.mjs",
|
|
84
94
|
"tools/ralph-external/lib/systemd-client.mjs",
|
|
85
95
|
"tools/ralph-external/lib/consecutive-failure-circuit-breaker.mjs",
|
|
86
96
|
"tools/ralph-external/lib/launcher-recovery-evidence.mjs",
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://aiwg.io/schemas/dataset/service-binding.v1.schema.json",
|
|
4
|
+
"title": "Qualified dataset service binding v1",
|
|
5
|
+
"oneOf": [
|
|
6
|
+
{ "$ref": "#/$defs/selection" },
|
|
7
|
+
{ "$ref": "#/$defs/descriptor" }
|
|
8
|
+
],
|
|
9
|
+
"$defs": {
|
|
10
|
+
"contract": { "const": "aiwg.dataset.service-binding/v1" },
|
|
11
|
+
"id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{1,127}$" },
|
|
12
|
+
"version": { "type": "string", "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$" },
|
|
13
|
+
"digest": {
|
|
14
|
+
"type": "object", "additionalProperties": false, "required": ["algorithm", "value"],
|
|
15
|
+
"properties": { "algorithm": { "const": "sha256" }, "value": { "type": "string", "pattern": "^[a-f0-9]{64}$" } }
|
|
16
|
+
},
|
|
17
|
+
"component": {
|
|
18
|
+
"type": "object", "additionalProperties": false, "required": ["id", "version", "packageDigest"],
|
|
19
|
+
"properties": { "id": { "$ref": "#/$defs/id" }, "version": { "$ref": "#/$defs/version" }, "packageDigest": { "$ref": "#/$defs/digest" } }
|
|
20
|
+
},
|
|
21
|
+
"capability": {
|
|
22
|
+
"type": "object", "additionalProperties": false, "required": ["name", "version"],
|
|
23
|
+
"properties": { "name": { "$ref": "#/$defs/id" }, "version": { "$ref": "#/$defs/version" } }
|
|
24
|
+
},
|
|
25
|
+
"selection": {
|
|
26
|
+
"type": "object", "additionalProperties": false, "required": ["contractVersion", "kind", "id", "version", "descriptorDigest"],
|
|
27
|
+
"properties": {
|
|
28
|
+
"contractVersion": { "$ref": "#/$defs/contract" }, "kind": { "const": "DatasetBindingSelection" },
|
|
29
|
+
"id": { "$ref": "#/$defs/id" }, "version": { "$ref": "#/$defs/version" }, "descriptorDigest": { "$ref": "#/$defs/digest" }
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"descriptor": {
|
|
33
|
+
"type": "object", "additionalProperties": false,
|
|
34
|
+
"required": ["contractVersion", "kind", "id", "version", "datasetContractVersion", "adapterContractVersion", "adapter", "adapterManifestDigest", "backend", "capabilities", "limits", "qualification"],
|
|
35
|
+
"properties": {
|
|
36
|
+
"contractVersion": { "$ref": "#/$defs/contract" }, "kind": { "const": "DatasetServiceBinding" },
|
|
37
|
+
"id": { "$ref": "#/$defs/id" }, "version": { "$ref": "#/$defs/version" },
|
|
38
|
+
"datasetContractVersion": { "const": "aiwg.dataset/v1" }, "adapterContractVersion": { "const": "aiwg.dataset.adapter/v1" },
|
|
39
|
+
"adapter": { "$ref": "#/$defs/component" }, "adapterManifestDigest": { "$ref": "#/$defs/digest" }, "backend": { "$ref": "#/$defs/component" },
|
|
40
|
+
"capabilities": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "#/$defs/capability" } },
|
|
41
|
+
"limits": {
|
|
42
|
+
"type": "object", "additionalProperties": false, "required": ["maxRecords", "maxBytes", "maxRecordBytes", "timeoutMs"],
|
|
43
|
+
"properties": {
|
|
44
|
+
"maxRecords": { "type": "integer", "minimum": 1, "maximum": 10000 },
|
|
45
|
+
"maxBytes": { "type": "integer", "minimum": 1, "maximum": 16777216 },
|
|
46
|
+
"maxRecordBytes": { "type": "integer", "minimum": 1, "maximum": 1048576 },
|
|
47
|
+
"timeoutMs": { "type": "integer", "minimum": 1, "maximum": 30000 }
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"qualification": {
|
|
51
|
+
"type": "object", "additionalProperties": false, "required": ["fixtureRevision", "cells"],
|
|
52
|
+
"properties": {
|
|
53
|
+
"fixtureRevision": { "type": "string", "minLength": 1, "maxLength": 128 },
|
|
54
|
+
"cells": {
|
|
55
|
+
"type": "array", "minItems": 5, "maxItems": 5,
|
|
56
|
+
"items": {
|
|
57
|
+
"type": "object", "additionalProperties": false, "required": ["name", "passed", "evidence"],
|
|
58
|
+
"properties": {
|
|
59
|
+
"name": { "enum": ["admission", "capability-version", "cancellation-resume", "replay", "receipt-mismatch"] },
|
|
60
|
+
"passed": { "type": "boolean" },
|
|
61
|
+
"evidence": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "minLength": 1, "maxLength": 1024 } }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"additionalProperties": false,
|
|
52
52
|
"required": ["source", "fetchedAt", "providers"],
|
|
53
53
|
"properties": {
|
|
54
|
-
"source": { "enum": ["native", "cache", "remote", "static"] },
|
|
55
|
-
"upstreamSource": { "enum": ["native", "remote", "static"] },
|
|
54
|
+
"source": { "enum": ["native", "cache", "remote", "static", "local-endpoint"] },
|
|
55
|
+
"upstreamSource": { "enum": ["native", "remote", "static", "local-endpoint"] },
|
|
56
56
|
"fetchedAt": { "type": "string", "format": "date-time" },
|
|
57
57
|
"remoteUrl": { "type": "string", "format": "uri" },
|
|
58
58
|
"remoteError": { "type": "string" },
|
|
@@ -92,6 +92,9 @@
|
|
|
92
92
|
"family": { "type": "string", "minLength": 1 },
|
|
93
93
|
"runtimeVersion": { "type": "string", "minLength": 1 },
|
|
94
94
|
"accountScope": { "type": "string", "minLength": 1 },
|
|
95
|
+
"endpoint": { "type": "string", "format": "uri" },
|
|
96
|
+
"checkpoint": { "type": "string", "minLength": 1 },
|
|
97
|
+
"unavailableReason": { "enum": ["endpoint-down", "timeout", "unauthorized", "model-missing", "invalid-response", "host-denied", "auth-env-missing"] },
|
|
95
98
|
"endpointFingerprint": { "type": "string", "minLength": 1 },
|
|
96
99
|
"observedAt": { "type": "string", "minLength": 1, "format": "date-time" },
|
|
97
100
|
"verifiedAt": { "type": "string", "minLength": 1, "format": "date-time" },
|
|
@@ -301,7 +304,7 @@
|
|
|
301
304
|
"required": ["provider", "source", "observedAt", "accountScope", "models"],
|
|
302
305
|
"properties": {
|
|
303
306
|
"provider": { "type": "string" },
|
|
304
|
-
"source": { "enum": ["native", "cache", "remote", "static"] },
|
|
307
|
+
"source": { "enum": ["native", "cache", "remote", "static", "local-endpoint"] },
|
|
305
308
|
"observedAt": { "type": "string", "format": "date-time" },
|
|
306
309
|
"runtimeVersion": { "type": "string" },
|
|
307
310
|
"accountScope": { "enum": ["local-account", "local-runtime", "public-feed", "static"] },
|
|
@@ -1,68 +1,107 @@
|
|
|
1
1
|
// Shared provider models platforms utilities.
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
2
3
|
import { resolveAiwgRoot } from './base-inventory.mjs';
|
|
3
|
-
import { fs, os, path, yaml } from './base-runtime.mjs';
|
|
4
|
+
import { createRequire, fs, os, path, yaml } from './base-runtime.mjs';
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
// ============================================================================
|
|
7
8
|
// Model Configuration
|
|
8
9
|
// ============================================================================
|
|
9
10
|
|
|
11
|
+
const isPlainObject = value => value !== null && typeof value === 'object'
|
|
12
|
+
&& Object.getPrototypeOf(value) === Object.prototype;
|
|
13
|
+
|
|
14
|
+
/** Merge plain objects; malformed overrides cannot erase inherited object fields. */
|
|
15
|
+
function mergeModelConfig(base, layer, source, prefix = '') {
|
|
16
|
+
const merged = { ...base };
|
|
17
|
+
for (const [key, value] of Object.entries(layer)) {
|
|
18
|
+
if (['_source', '__proto__', 'constructor', 'prototype'].includes(key)) continue;
|
|
19
|
+
const field = prefix ? `${prefix}.${key}` : key;
|
|
20
|
+
if (isPlainObject(base[key]) && !isPlainObject(value)) {
|
|
21
|
+
console.warn(`Warning: Ignoring non-object models.json key "${field}" at ${source}; keeping inherited object`);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
merged[key] = isPlainObject(value)
|
|
25
|
+
? mergeModelConfig(isPlainObject(base[key]) ? base[key] : {}, value, source, field)
|
|
26
|
+
: value;
|
|
27
|
+
}
|
|
28
|
+
return merged;
|
|
29
|
+
}
|
|
30
|
+
|
|
10
31
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
32
|
+
* Merge model configuration: AIWG defaults ← user ← project.
|
|
33
|
+
* Omitted fields inherit; object fields require object overrides. _source lists applied layers.
|
|
13
34
|
*/
|
|
14
35
|
export function loadModelConfig(srcRoot) {
|
|
15
|
-
//
|
|
16
|
-
// shipped
|
|
17
|
-
// through to the hardcoded fallback and deployed bare aliases (#2563).
|
|
36
|
+
// Bundle sources are not corpus roots. If no corpus can be found, read the
|
|
37
|
+
// defaults shipped beside this loader before falling back to the catalog.
|
|
18
38
|
const aiwgRoot = (srcRoot && resolveAiwgRoot(srcRoot)) || srcRoot;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (fs.existsSync(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} catch (err) {
|
|
32
|
-
console.warn(`Warning: Could not parse models.json at ${loc.path}: ${err.message}`);
|
|
39
|
+
const shippedPath = 'agentic/code/frameworks/sdlc-complete/config/models.json';
|
|
40
|
+
const bundledPath = new URL(`../../../${shippedPath}`, import.meta.url);
|
|
41
|
+
const defaultPaths = [...new Set([
|
|
42
|
+
...(aiwgRoot ? [path.join(aiwgRoot, shippedPath)] : []),
|
|
43
|
+
fileURLToPath(bundledPath),
|
|
44
|
+
])];
|
|
45
|
+
function readConfig(file) {
|
|
46
|
+
if (!fs.existsSync(file)) return null;
|
|
47
|
+
try {
|
|
48
|
+
const config = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
49
|
+
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
|
50
|
+
throw new Error('expected a JSON object');
|
|
33
51
|
}
|
|
52
|
+
return config;
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.warn(`Warning: Could not parse models.json at ${file}: ${err.message}`);
|
|
55
|
+
return null;
|
|
34
56
|
}
|
|
35
57
|
}
|
|
36
58
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
'haiku': 'claude-haiku-4-5',
|
|
53
|
-
'inherit': 'inherit'
|
|
54
|
-
},
|
|
55
|
-
claude_shorthand: {
|
|
56
|
-
'opus': 'opus',
|
|
57
|
-
'opus-1m': 'opus[1m]',
|
|
58
|
-
'opus[1m]': 'opus[1m]',
|
|
59
|
-
'sonnet': 'sonnet',
|
|
60
|
-
'sonnet-1m': 'sonnet[1m]',
|
|
61
|
-
'sonnet[1m]': 'sonnet[1m]',
|
|
62
|
-
'haiku': 'haiku',
|
|
63
|
-
'inherit': 'inherit'
|
|
59
|
+
let config;
|
|
60
|
+
const sources = [];
|
|
61
|
+
for (const file of defaultPaths) {
|
|
62
|
+
config = readConfig(file);
|
|
63
|
+
if (config) {
|
|
64
|
+
sources.push(`AIWG defaults (${file})`);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!config) {
|
|
69
|
+
const catalog = createRequire(import.meta.url)('../../../agentic/code/providers/model-catalog.v1.json');
|
|
70
|
+
config = {};
|
|
71
|
+
for (const provider of ['claude', 'factory']) {
|
|
72
|
+
config[provider] = Object.fromEntries(Object.entries(catalog.providers[provider].roles)
|
|
73
|
+
.map(([role, entry]) => [role, { model: entry.id }]));
|
|
64
74
|
}
|
|
65
|
-
|
|
75
|
+
// Windsurf's catalog currently has only "inherited" placeholders. Until it
|
|
76
|
+
// supplies concrete IDs, use Factory's API pins, matching shipped Windsurf.
|
|
77
|
+
config.windsurf = Object.fromEntries(Object.entries(config.factory).map(([role, entry]) => {
|
|
78
|
+
const id = catalog.providers.windsurf?.roles?.[role]?.id;
|
|
79
|
+
return [role, { model: typeof id === 'string' && id.trim() && id !== 'inherited' ? id : entry.model }];
|
|
80
|
+
}));
|
|
81
|
+
config.shorthand = { inherit: 'inherit' };
|
|
82
|
+
config.claude_shorthand = { inherit: 'inherit' };
|
|
83
|
+
for (const [alias, role] of Object.entries({ opus: 'reasoning', sonnet: 'coding', haiku: 'efficiency' })) {
|
|
84
|
+
config.shorthand[alias] = config.claude[role].model;
|
|
85
|
+
config.claude_shorthand[alias] = alias;
|
|
86
|
+
if (alias !== 'haiku') {
|
|
87
|
+
config.claude_shorthand[`${alias}-1m`] = `${alias}[1m]`;
|
|
88
|
+
config.claude_shorthand[`${alias}[1m]`] = `${alias}[1m]`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
sources.push('model catalog (fallback)');
|
|
92
|
+
}
|
|
93
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
94
|
+
for (const loc of [
|
|
95
|
+
{ path: path.join(homeDir, '.config', 'aiwg', 'models.json'), label: 'user' },
|
|
96
|
+
{ path: path.join(process.cwd(), 'models.json'), label: 'project' },
|
|
97
|
+
]) {
|
|
98
|
+
const layer = readConfig(loc.path);
|
|
99
|
+
if (layer) {
|
|
100
|
+
config = mergeModelConfig(config, layer, loc.path);
|
|
101
|
+
sources.push(`${loc.label} (${loc.path})`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return { ...config, _source: sources.join(' ← ') };
|
|
66
105
|
}
|
|
67
106
|
|
|
68
107
|
|
|
@@ -80,6 +80,6 @@ export async function deployConductorDataGuard(targetDir, provider, opts = {}) {
|
|
|
80
80
|
fs.mkdirSync(path.dirname(rulesPath), { recursive: true });
|
|
81
81
|
fs.writeFileSync(rulesPath, lines.join('\n') + '\n');
|
|
82
82
|
}
|
|
83
|
-
console.log(`Conductor guard (${provider}): ${paths.join(', ')}${executionGuard ? '; worker execution checks enabled' : ''}; shell coverage is limited.`);
|
|
83
|
+
console.log(`Conductor guard (${provider}): ${paths.join(', ')}${executionGuard ? '; worker execution/integration checks enabled' : ''}; shell coverage is limited.`);
|
|
84
84
|
return paths;
|
|
85
85
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Preview live corpus inputs without copying or sealing a never-committed source snapshot.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { snapshotPreimages, within } from './rule-deployment-state.mjs';
|
|
4
|
+
|
|
5
|
+
export function corpusInputPlan(original, corpusRoot, sourceTree, pool) {
|
|
6
|
+
const preview = original.dryRun === true;
|
|
7
|
+
return {
|
|
8
|
+
preimages: preview ? [] : pool?.preimages ?? snapshotPreimages([
|
|
9
|
+
sourceTree, path.join(corpusRoot, 'prebuilt', 'framework-relations'),
|
|
10
|
+
path.join(corpusRoot, 'package.json'), path.join(corpusRoot, 'schemas'),
|
|
11
|
+
]),
|
|
12
|
+
snapshotRequired: !preview && !pool,
|
|
13
|
+
snapshotRoot: temp => preview ? corpusRoot : pool?.snapshotRoot ?? path.join(temp, 'input'),
|
|
14
|
+
// Binding discovery may return absolute corpus paths. These are already
|
|
15
|
+
// readable in a preview; copying each selected target would rebuild the
|
|
16
|
+
// snapshot piecemeal. Output still renders in the isolated project stage.
|
|
17
|
+
isLiveInput: file => preview && within(corpusRoot, file),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Reuse the existing immutable input pool within an update and measure staging.
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { channel } from 'node:diagnostics_channel';
|
|
4
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
5
|
+
import { resolveAiwgRoot } from './base.mjs';
|
|
6
|
+
import { createRuleDeploymentInputPool, disposeRuleDeploymentInputPool } from './rule-deployment-state.mjs';
|
|
7
|
+
|
|
8
|
+
const { deploymentSessionInput } = await importImpl(import.meta.url, 'providers/deployment-input-session.mjs');
|
|
9
|
+
const timings = channel('aiwg.provider-staging');
|
|
10
|
+
const sourceRoot = srcRoot => path.resolve(resolveAiwgRoot(srcRoot) || srcRoot);
|
|
11
|
+
|
|
12
|
+
export function sessionInputPool(srcRoot) {
|
|
13
|
+
const root = sourceRoot(srcRoot);
|
|
14
|
+
return deploymentSessionInput(root, () => {
|
|
15
|
+
const start = performance.now();
|
|
16
|
+
let status = 'failed';
|
|
17
|
+
try {
|
|
18
|
+
const pool = createRuleDeploymentInputPool(srcRoot);
|
|
19
|
+
status = 'succeeded';
|
|
20
|
+
return pool;
|
|
21
|
+
}
|
|
22
|
+
finally {
|
|
23
|
+
timings.publish({ phase: 'snapshot-provider-inputs', source: root, durationMs: performance.now() - start, status });
|
|
24
|
+
}
|
|
25
|
+
}, disposeRuleDeploymentInputPool);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function measureProviderStaging(original, provider, prepare) {
|
|
29
|
+
const source = sourceRoot(original.srcRoot);
|
|
30
|
+
const start = performance.now();
|
|
31
|
+
let status = 'failed';
|
|
32
|
+
try {
|
|
33
|
+
const plan = await prepare();
|
|
34
|
+
status = 'prepared';
|
|
35
|
+
return plan;
|
|
36
|
+
} finally {
|
|
37
|
+
timings.publish({ phase: 'prepare-provider-staging', source, provider: provider.name,
|
|
38
|
+
durationMs: performance.now() - start, status });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -49,10 +49,18 @@ const { captureDeploymentOutputs, recordDeploymentOutputs } = await importImpl(i
|
|
|
49
49
|
const { preserveDeploymentOutputs } = await importImpl(import.meta.url, 'providers/deployment-preservation.mjs');
|
|
50
50
|
import { retireInlineStartup } from './rule-startup.mjs';
|
|
51
51
|
import { createStagedDirectoryReference } from './staged-directory-reference.mjs';
|
|
52
|
+
import { measureProviderStaging, sessionInputPool } from './rule-deployment-input-session.mjs';
|
|
53
|
+
import { corpusInputPlan } from './rule-deployment-corpus-inputs.mjs';
|
|
52
54
|
|
|
53
55
|
/** Stage only provider/context output, never the user's source tree. On failure
|
|
54
56
|
* no staged output (including skills and behaviors) reaches the prior deployment. */
|
|
55
57
|
export async function prepareRuleDeployment(original, provider, deploy) {
|
|
58
|
+
return measureProviderStaging(original, provider, () => prepareWithInputs({
|
|
59
|
+
...original, inputPool: original.dryRun ? undefined : original.inputPool || sessionInputPool(original.srcRoot),
|
|
60
|
+
}, provider, deploy));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function prepareWithInputs(original, provider, deploy) {
|
|
56
64
|
const budgetEnv = { ...process.env };
|
|
57
65
|
const ruleDir = path.isAbsolute(provider.paths.rules || '') ? provider.paths.rules : path.join(original.target, provider.paths.rules || `.${provider.name}/rules`);
|
|
58
66
|
const manifestFile = path.join(ruleDir, '.aiwg-manifest.json');
|
|
@@ -78,7 +86,8 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
78
86
|
const localSources = Object.values(projectConfig.installed || {}).filter(entry => entry?.localPath)
|
|
79
87
|
.map(entry => path.resolve(original.target, entry.localPath));
|
|
80
88
|
const selectedRules = collectDeploymentRuleSources({ ...original, previousRuleSources: previous.ruleSources || [] });
|
|
81
|
-
const
|
|
89
|
+
const corpusInputs = corpusInputPlan(original, corpusRoot, sourceTree, pool);
|
|
90
|
+
const initialPreimages = [...corpusInputs.preimages, ...snapshotPreimages([path.join(corpusRoot, '.aiwg', '.index'),
|
|
82
91
|
manifestFile, path.join(original.target, '.aiwg', 'aiwg.config'), path.join(original.target, '.aiwg', 'AIWG.md'), path.join(original.target, '.aiwg', 'skills'), path.join(original.target, '.aiwg-location'), ...projectGraphFiles, ...userGraphFiles, ...localSources,
|
|
83
92
|
...(path.resolve(original.srcRoot) === path.resolve(corpusRoot) ? [] : [original.srcRoot]), ...(original.additionalSources || []), ...selectedRules, ...selectedRules.map(file => path.dirname(file)),
|
|
84
93
|
userConfigFile('aiwg.config'), process.env.AIWG_USER_REGISTRY_PATH || userConfigFile('installed.json'),
|
|
@@ -114,14 +123,14 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
114
123
|
const priorArtifacts = process.env.AIWG_ARTIFACTS_PATH;
|
|
115
124
|
const priorXdgData = process.env.XDG_DATA_HOME;
|
|
116
125
|
try {
|
|
117
|
-
const snapshotRoot =
|
|
126
|
+
const snapshotRoot = corpusInputs.snapshotRoot(temp);
|
|
118
127
|
const treeRelative = path.relative(corpusRoot, sourceTree);
|
|
119
128
|
const isCorpusTree = treeRelative === path.join('agentic', 'code');
|
|
120
129
|
const snapshotTree = isCorpusTree ? path.join(snapshotRoot, 'agentic', 'code') : snapshotRoot;
|
|
121
|
-
if (
|
|
130
|
+
if (corpusInputs.snapshotRequired) { fs.mkdirSync(path.dirname(snapshotTree), { recursive: true }); materializeInput(sourceTree, snapshotTree); }
|
|
122
131
|
const expectedTree = initialPreimages.find(item => item.path === path.resolve(sourceTree));
|
|
123
|
-
if (
|
|
124
|
-
if (isCorpusTree &&
|
|
132
|
+
if (corpusInputs.snapshotRequired && JSON.stringify(capturePreimage(snapshotTree)) !== JSON.stringify(materializedPreimage(expectedTree.state))) throw new Error('Source changed while preparing immutable snapshot');
|
|
133
|
+
if (isCorpusTree && corpusInputs.snapshotRequired) {
|
|
125
134
|
for (const rel of ['package.json', 'prebuilt', 'schemas']) {
|
|
126
135
|
const from = path.join(corpusRoot, rel), to = path.join(snapshotRoot, rel);
|
|
127
136
|
if (fs.existsSync(from)) materializeInput(from, to);
|
|
@@ -323,7 +332,7 @@ export async function prepareRuleDeployment(original, provider, deploy) {
|
|
|
323
332
|
const remappedBindings = new Map();
|
|
324
333
|
for (const entry of delivery.targets) {
|
|
325
334
|
const source = path.resolve(entry.source);
|
|
326
|
-
const alreadyFrozen = source.startsWith(`${temp}${path.sep}`);
|
|
335
|
+
const alreadyFrozen = corpusInputs.isLiveInput(source) || source.startsWith(`${temp}${path.sep}`) || Boolean(pool && source.startsWith(`${pool.snapshotRoot}${path.sep}`));
|
|
327
336
|
if (!alreadyFrozen) {
|
|
328
337
|
const state = capturePreimage(source);
|
|
329
338
|
const to = path.join(temp, 'discovered-input', String(sourceMappings.length), path.basename(source));
|
|
@@ -246,6 +246,8 @@ Writing quality validation and AI pattern detection.
|
|
|
246
246
|
...['artifact-output-policy', 'artifact-output-policy-guidance'].map(name =>
|
|
247
247
|
({ from: `agentic/code/addons/aiwg-utils/rules/${name}.md`, to: `rules/${name}.md` })),
|
|
248
248
|
{ from: 'agentic/code/addons/aiwg-utils/templates/subagent-brief.md', to: 'templates/subagent-brief.md' },
|
|
249
|
+
...['checkpoint-handoff', 'commit-message', 'agent-handoff', 'stakeholder-status-report', 'security-finding', 'code-review-findings'].map(name =>
|
|
250
|
+
({ from: `agentic/code/addons/aiwg-utils/templates/${name}.md`, to: `templates/${name}.md` })),
|
|
249
251
|
{ from: 'agentic/code/addons/aiwg-utils/templates/issues', to: 'templates/issues' },
|
|
250
252
|
{ from: 'agentic/code/addons/aiwg-utils/templates/pull-requests', to: 'templates/pull-requests' }
|
|
251
253
|
],
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Adapt MCP shell dispatch to the same one-shot launch and capture owner as --launch-worker.
|
|
2
|
+
import { mkdtemp, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { SessionLauncher, planDirectWorkerLaunch } from '../session-launcher.mjs';
|
|
5
|
+
import { checkWorkerDispatch, launchIsolatedWorker } from './worker-isolation.mjs';
|
|
6
|
+
|
|
7
|
+
// The capture owner's attached launch connects stdio itself, so the planner must not default capture
|
|
8
|
+
// paths from the invocation; systemd-run refuses attached mode with redirects (#4157).
|
|
9
|
+
function attachedInvocation(invocation) {
|
|
10
|
+
return { ...invocation, stdoutPath: undefined, stderrPath: undefined, briefPath: undefined };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function launchMcpShellWorker(invocation, { plan, invocationId, releaseOutput, runDir, servedRoot,
|
|
14
|
+
loadInputs, now, onRunDir, memoryMaxGb = 2, allowDegraded, admission, dispatchGuard,
|
|
15
|
+
live, readers, thresholdOverlay, isolation, spawn, spawnAsync }) {
|
|
16
|
+
if (!Number.isFinite(memoryMaxGb) || memoryMaxGb <= 0) throw new Error('Worker isolation requires a positive memoryMaxGb ceiling');
|
|
17
|
+
const parent = await mkdtemp(join(servedRoot, '.worker-run-'));
|
|
18
|
+
runDir ??= join(parent, 'run');
|
|
19
|
+
const invocationPath = join(parent, 'plan.json');
|
|
20
|
+
await writeFile(invocationPath, JSON.stringify(plan), { flag: 'wx', mode: 0o600 });
|
|
21
|
+
onRunDir(runDir);
|
|
22
|
+
await releaseOutput(); // The launcher exclusively reserves every output before spawning.
|
|
23
|
+
const owner = new SessionLauncher();
|
|
24
|
+
let launch;
|
|
25
|
+
let attempt;
|
|
26
|
+
let resolveStarted;
|
|
27
|
+
const started = new Promise(resolve => { resolveStarted = resolve; });
|
|
28
|
+
owner.once('launched', () => resolveStarted(launch));
|
|
29
|
+
const completion = owner.launchWorker({ invocationPath, invocationId, runDir, loadInputs, now: () => now().toISOString(),
|
|
30
|
+
projectRoot: servedRoot, memoryMaxGb, allowDegraded, scopedBreaker: null, isolation,
|
|
31
|
+
checkDispatch: options => checkWorkerDispatch({ ...options, live, readers, thresholdOverlay }),
|
|
32
|
+
launchIsolated: async options => {
|
|
33
|
+
const onSpawnAttempt = value => { attempt = value; };
|
|
34
|
+
// The MCP bridge retains its single recovery admission and leaf dispatch guard.
|
|
35
|
+
launch = await (admission === undefined
|
|
36
|
+
? launchIsolatedWorker({ ...options, spawn, spawnAsync, onSpawnAttempt })
|
|
37
|
+
: planDirectWorkerLaunch({ ...options, invocation: options.attached ? attachedInvocation(invocation) : invocation, invocationId, admission, dispatchGuard,
|
|
38
|
+
live, readers, thresholdOverlay, spawn, spawnAsync, onSpawnAttempt }));
|
|
39
|
+
launch.child?.once('close', (exitCode, signalCode) => {
|
|
40
|
+
launch.spawnObservation = { closed: true, exitCode, signalCode };
|
|
41
|
+
});
|
|
42
|
+
return launch;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
// Observe rejection immediately; preparation failures must never strand MCP admission.
|
|
46
|
+
const settled = completion.then(() => launch, error => {
|
|
47
|
+
error.launchAttempted = !!(launch?.child?.pid || launch?.unit || attempt?.child?.pid || attempt?.unit);
|
|
48
|
+
throw error;
|
|
49
|
+
});
|
|
50
|
+
const result = await Promise.race([started, settled]);
|
|
51
|
+
// A transport's close cannot override the capture owner's descendant proof.
|
|
52
|
+
const stop = () => { if (!owner.workerStop) return false; owner.workerStop(); return true; };
|
|
53
|
+
const outcome = async () => { const value = await completion; return { ...value, stopped: !!value.cancelled }; };
|
|
54
|
+
const control = {
|
|
55
|
+
stop: async () => stop(),
|
|
56
|
+
stopAndConfirm: async () => { stop(); return outcome(); },
|
|
57
|
+
wait: async (deadlineMs, { deadlineAtMs, nowMs = () => performance.now() } = {}) => {
|
|
58
|
+
const remaining = Math.max(0, Math.min(deadlineMs, (deadlineAtMs ?? Infinity) - nowMs()));
|
|
59
|
+
const timer = setTimeout(() => owner.workerStop?.('HARD_DEADLINE'), remaining);
|
|
60
|
+
try { return await outcome(); } finally { clearTimeout(timer); }
|
|
61
|
+
},
|
|
62
|
+
dispose() {},
|
|
63
|
+
};
|
|
64
|
+
return { ...result, runDir, launchAttempted: !!(result?.child?.pid || result?.unit),
|
|
65
|
+
ownedGroup: result?.ownedGroup ?? (['native-sandbox', 'degraded'].includes(result?.mode) && !!result?.pid),
|
|
66
|
+
control, cleanup: () => settled };
|
|
67
|
+
}
|