devworkspace 0.5.1 → 0.5.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/CHANGELOG.md +30 -2
- package/README.md +57 -509
- package/dist/agents/claude/adapter.js +0 -1
- package/dist/agents/claude/content.js +0 -1
- package/dist/agents/codex/adapter.js +0 -1
- package/dist/agents/copilot/adapter.js +0 -1
- package/dist/agents/cursor/adapter.js +0 -1
- package/dist/agents/index.js +0 -1
- package/dist/agents/shared.js +0 -1
- package/dist/agents/types.js +0 -1
- package/dist/cli/args.d.ts +16 -0
- package/dist/cli/args.js +5 -1
- package/dist/cli/help.js +59 -17
- package/dist/cli/main.js +0 -1
- package/dist/cli/prompt.d.ts +15 -0
- package/dist/cli/prompt.js +113 -0
- package/dist/cli/render.d.ts +10 -0
- package/dist/cli/render.js +174 -4
- package/dist/cli/run.d.ts +3 -0
- package/dist/cli/run.js +366 -17
- package/dist/config/feature-gate.d.ts +15 -0
- package/dist/config/feature-gate.js +77 -0
- package/dist/config/feature-registry.d.ts +49 -0
- package/dist/config/feature-registry.js +451 -0
- package/dist/config/schemas.js +0 -1
- package/dist/config/settings.d.ts +54 -0
- package/dist/config/settings.js +293 -0
- package/dist/config/validate.js +0 -1
- package/dist/core/artifacts.js +0 -1
- package/dist/core/contracts.js +0 -1
- package/dist/core/migrations.js +0 -1
- package/dist/core/version.js +0 -1
- package/dist/core/versioned.js +0 -1
- package/dist/core/workspace.d.ts +1 -0
- package/dist/core/workspace.js +1 -1
- package/dist/decisions/decision.js +0 -1
- package/dist/discovery/cache.js +0 -1
- package/dist/discovery/commands.js +0 -1
- package/dist/discovery/detect.js +0 -1
- package/dist/discovery/docs.js +0 -1
- package/dist/discovery/entrypoints.js +0 -1
- package/dist/discovery/ignore.js +0 -1
- package/dist/discovery/scan.js +0 -1
- package/dist/discovery/types.js +0 -1
- package/dist/dx/dashboard.js +2 -1
- package/dist/dx/guidance.js +0 -1
- package/dist/dx/guided-setup.d.ts +102 -0
- package/dist/dx/guided-setup.js +508 -0
- package/dist/dx/index.js +0 -1
- package/dist/dx/onboarding.js +0 -1
- package/dist/dx/types.js +0 -1
- package/dist/errors/index.js +0 -1
- package/dist/features/schema.js +0 -1
- package/dist/features/types.js +0 -1
- package/dist/features/validate.js +0 -1
- package/dist/git/git.js +0 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.js +10 -2
- package/dist/integrations/adapters/agent-skills.js +0 -1
- package/dist/integrations/adapters/claudePlugin.js +0 -1
- package/dist/integrations/adapters/graphify.js +0 -1
- package/dist/integrations/adapters/omniroute.js +0 -1
- package/dist/integrations/adapters/pluginSkill.js +0 -1
- package/dist/integrations/adapters/ponytail.js +0 -1
- package/dist/integrations/exec.js +0 -1
- package/dist/integrations/index.js +0 -1
- package/dist/integrations/manager.d.ts +2 -1
- package/dist/integrations/manager.js +22 -3
- package/dist/integrations/notices.js +0 -1
- package/dist/integrations/persistentPath.js +0 -1
- package/dist/integrations/protect.js +0 -1
- package/dist/integrations/state.js +0 -1
- package/dist/integrations/types.d.ts +1 -1
- package/dist/integrations/types.js +1 -1
- package/dist/intelligence/agents/profiles.js +0 -1
- package/dist/intelligence/agents/registry.js +0 -1
- package/dist/intelligence/agents/types.js +0 -1
- package/dist/intelligence/observability/tracer.js +0 -1
- package/dist/intelligence/observability/types.js +0 -1
- package/dist/intelligence/orchestration/engine.d.ts +13 -4
- package/dist/intelligence/orchestration/engine.js +332 -54
- package/dist/intelligence/orchestration/lock-manager.js +0 -1
- package/dist/intelligence/orchestration/store.js +0 -1
- package/dist/intelligence/orchestration/types.d.ts +28 -1
- package/dist/intelligence/orchestration/types.js +0 -1
- package/dist/intelligence/routing/matcher.js +0 -1
- package/dist/intelligence/routing/router.js +0 -1
- package/dist/intelligence/routing/types.js +0 -1
- package/dist/intelligence/runtime/adk/adapter.js +1 -2
- package/dist/intelligence/runtime/adk/detector.js +0 -1
- package/dist/intelligence/runtime/auth-provider.d.ts +63 -0
- package/dist/intelligence/runtime/auth-provider.js +201 -0
- package/dist/intelligence/runtime/boundary.d.ts +118 -6
- package/dist/intelligence/runtime/boundary.js +720 -38
- package/dist/intelligence/runtime/changes.d.ts +59 -0
- package/dist/intelligence/runtime/changes.js +362 -0
- package/dist/intelligence/runtime/external.d.ts +1 -0
- package/dist/intelligence/runtime/external.js +9 -6
- package/dist/intelligence/runtime/native.js +0 -1
- package/dist/intelligence/runtime/types.d.ts +64 -2
- package/dist/intelligence/runtime/types.js +0 -1
- package/dist/intelligence/security/audit.js +8 -2
- package/dist/intelligence/security/policy.js +0 -1
- package/dist/intelligence/security/types.d.ts +8 -0
- package/dist/intelligence/security/types.js +0 -1
- package/dist/intelligence/skills/builtins.js +0 -1
- package/dist/intelligence/skills/loader.js +0 -1
- package/dist/intelligence/skills/registry.js +0 -1
- package/dist/intelligence/skills/types.js +0 -1
- package/dist/intelligence/verification/engine.d.ts +10 -2
- package/dist/intelligence/verification/engine.js +53 -9
- package/dist/intelligence/verification/reviewer.d.ts +18 -2
- package/dist/intelligence/verification/reviewer.js +356 -4
- package/dist/intelligence/verification/types.d.ts +60 -0
- package/dist/intelligence/verification/types.js +0 -1
- package/dist/knowledge/facts.js +0 -1
- package/dist/mcp/protocol.js +0 -1
- package/dist/mcp/server.js +38 -2
- package/dist/mcp/setup.js +5 -2
- package/dist/mcp/tools.js +0 -1
- package/dist/mcp/types.js +0 -1
- package/dist/mcp/verify.js +0 -1
- package/dist/portability/bundle.js +0 -1
- package/dist/prompts/onboarding.js +0 -1
- package/dist/prompts/refresh.js +0 -1
- package/dist/prompts/requirements.js +0 -1
- package/dist/security/files.js +0 -1
- package/dist/security/redact.js +0 -1
- package/dist/services/agent.js +2 -1
- package/dist/services/analysis.js +0 -1
- package/dist/services/common.js +0 -1
- package/dist/services/doctor.js +13 -2
- package/dist/services/drift.js +0 -1
- package/dist/services/features.js +5 -1
- package/dist/services/graph.js +4 -1
- package/dist/services/init.js +0 -1
- package/dist/services/integrations.d.ts +2 -1
- package/dist/services/integrations.js +29 -6
- package/dist/services/intelligence.d.ts +2 -2
- package/dist/services/intelligence.js +38 -36
- package/dist/services/knowledge.js +0 -1
- package/dist/services/migrate.js +0 -1
- package/dist/services/modules.d.ts +85 -0
- package/dist/services/modules.js +313 -0
- package/dist/services/portability.js +0 -1
- package/dist/services/records.js +5 -1
- package/dist/services/refresh.js +0 -1
- package/dist/services/reset.js +0 -1
- package/dist/services/settings.d.ts +36 -0
- package/dist/services/settings.js +102 -0
- package/dist/services/setup.d.ts +4 -5
- package/dist/services/setup.js +40 -28
- package/dist/services/standards.js +10 -1
- package/dist/services/status.js +0 -1
- package/dist/services/taskContext.js +0 -1
- package/dist/services/tasks.js +9 -1
- package/dist/services/verify.js +7 -2
- package/dist/sessions/session.js +0 -1
- package/dist/standards/acquisition/ingest.js +0 -1
- package/dist/standards/applicability/engine.js +0 -1
- package/dist/standards/builtin/code-quality.js +0 -1
- package/dist/standards/builtin/database-safety.js +0 -1
- package/dist/standards/builtin/index.js +0 -1
- package/dist/standards/builtin/security-baseline.js +0 -1
- package/dist/standards/builtin/testing-contracts.js +0 -1
- package/dist/standards/builtin/undo-kit.js +0 -1
- package/dist/standards/config/config.js +0 -1
- package/dist/standards/distribution/cache.js +0 -1
- package/dist/standards/distribution/index.js +0 -1
- package/dist/standards/distribution/keys.js +0 -1
- package/dist/standards/distribution/package.js +0 -1
- package/dist/standards/distribution/server.js +0 -1
- package/dist/standards/distribution/sync.js +0 -1
- package/dist/standards/distribution/types.js +0 -1
- package/dist/standards/engine/compliance.js +0 -1
- package/dist/standards/engine/engine.js +0 -1
- package/dist/standards/engine/reporter.js +0 -1
- package/dist/standards/index.js +0 -1
- package/dist/standards/registry/registry.js +0 -1
- package/dist/standards/schema/types.js +0 -1
- package/dist/standards/schema/validate.js +0 -1
- package/dist/standards/templates/index.js +0 -1
- package/dist/standards/validators/database.js +0 -1
- package/dist/standards/validators/quality.js +0 -1
- package/dist/standards/validators/registry.js +0 -1
- package/dist/standards/validators/security.js +0 -1
- package/dist/standards/validators/testing.js +0 -1
- package/dist/standards/validators/types.js +0 -1
- package/dist/standards/validators/undo-kit.js +0 -1
- package/dist/tasks/routing.js +0 -1
- package/dist/tasks/task.js +0 -1
- package/dist/utils/cleanup.js +0 -1
- package/dist/utils/fs.js +0 -1
- package/dist/utils/lock.js +92 -49
- package/dist/utils/logger.js +0 -1
- package/dist/utils/paths.js +0 -1
- package/dist/utils/proc.d.ts +8 -0
- package/dist/utils/proc.js +54 -46
- package/dist/verification/safety.js +0 -1
- package/dist/verification/scope.js +0 -1
- package/docs/architecture/global-standards-architecture.md +287 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_AUDIT.md +99 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_FINAL_STATUS.md +138 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_IMPLEMENTATION_PLAN.md +100 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_INDEPENDENT_AUDIT.md +219 -0
- package/docs/archive/global-standards/GLOBAL_STANDARDS_SECURITY_REPORT.md +184 -0
- package/docs/configuration.md +67 -0
- package/docs/contributing.md +15 -4
- package/docs/development/EXECUTION_STATE.md +50 -0
- package/docs/features.md +80 -0
- package/docs/getting-started.md +69 -111
- package/docs/guides/global-standards-migration.md +100 -0
- package/docs/integrations.md +7 -0
- package/docs/security/THIRD_PARTY_LICENSES.md +41 -0
- package/docs/testing/FINAL_CORRECTION_AND_CLEANUP_REPORT.md +92 -0
- package/docs/testing/global-standards-real-project-tests.md +218 -0
- package/docs/testing/global-standards-test-report.md +89 -0
- package/docs/testing/global-standards-verification-matrix.md +174 -0
- package/docs/troubleshooting.md +3 -0
- package/package.json +1 -1
- package/dist/agents/claude/adapter.js.map +0 -1
- package/dist/agents/claude/content.js.map +0 -1
- package/dist/agents/codex/adapter.js.map +0 -1
- package/dist/agents/copilot/adapter.js.map +0 -1
- package/dist/agents/cursor/adapter.js.map +0 -1
- package/dist/agents/index.js.map +0 -1
- package/dist/agents/shared.js.map +0 -1
- package/dist/agents/types.js.map +0 -1
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/render.js.map +0 -1
- package/dist/cli/run.js.map +0 -1
- package/dist/config/schemas.js.map +0 -1
- package/dist/config/validate.js.map +0 -1
- package/dist/core/artifacts.js.map +0 -1
- package/dist/core/contracts.js.map +0 -1
- package/dist/core/migrations.js.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/core/versioned.js.map +0 -1
- package/dist/core/workspace.js.map +0 -1
- package/dist/decisions/decision.js.map +0 -1
- package/dist/discovery/cache.js.map +0 -1
- package/dist/discovery/commands.js.map +0 -1
- package/dist/discovery/detect.js.map +0 -1
- package/dist/discovery/docs.js.map +0 -1
- package/dist/discovery/entrypoints.js.map +0 -1
- package/dist/discovery/ignore.js.map +0 -1
- package/dist/discovery/scan.js.map +0 -1
- package/dist/discovery/types.js.map +0 -1
- package/dist/dx/dashboard.js.map +0 -1
- package/dist/dx/guidance.js.map +0 -1
- package/dist/dx/index.js.map +0 -1
- package/dist/dx/onboarding.js.map +0 -1
- package/dist/dx/types.js.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/features/schema.js.map +0 -1
- package/dist/features/types.js.map +0 -1
- package/dist/features/validate.js.map +0 -1
- package/dist/git/git.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integrations/adapters/agent-skills.js.map +0 -1
- package/dist/integrations/adapters/claudePlugin.js.map +0 -1
- package/dist/integrations/adapters/graphify.js.map +0 -1
- package/dist/integrations/adapters/omniroute.js.map +0 -1
- package/dist/integrations/adapters/pluginSkill.js.map +0 -1
- package/dist/integrations/adapters/ponytail.js.map +0 -1
- package/dist/integrations/exec.js.map +0 -1
- package/dist/integrations/index.js.map +0 -1
- package/dist/integrations/manager.js.map +0 -1
- package/dist/integrations/notices.js.map +0 -1
- package/dist/integrations/persistentPath.js.map +0 -1
- package/dist/integrations/protect.js.map +0 -1
- package/dist/integrations/state.js.map +0 -1
- package/dist/integrations/types.js.map +0 -1
- package/dist/intelligence/agents/profiles.js.map +0 -1
- package/dist/intelligence/agents/registry.js.map +0 -1
- package/dist/intelligence/agents/types.js.map +0 -1
- package/dist/intelligence/observability/tracer.js.map +0 -1
- package/dist/intelligence/observability/types.js.map +0 -1
- package/dist/intelligence/orchestration/engine.js.map +0 -1
- package/dist/intelligence/orchestration/lock-manager.js.map +0 -1
- package/dist/intelligence/orchestration/store.js.map +0 -1
- package/dist/intelligence/orchestration/types.js.map +0 -1
- package/dist/intelligence/routing/matcher.js.map +0 -1
- package/dist/intelligence/routing/router.js.map +0 -1
- package/dist/intelligence/routing/types.js.map +0 -1
- package/dist/intelligence/runtime/adk/adapter.js.map +0 -1
- package/dist/intelligence/runtime/adk/detector.js.map +0 -1
- package/dist/intelligence/runtime/boundary.js.map +0 -1
- package/dist/intelligence/runtime/external.js.map +0 -1
- package/dist/intelligence/runtime/native.js.map +0 -1
- package/dist/intelligence/runtime/types.js.map +0 -1
- package/dist/intelligence/security/audit.js.map +0 -1
- package/dist/intelligence/security/policy.js.map +0 -1
- package/dist/intelligence/security/types.js.map +0 -1
- package/dist/intelligence/skills/builtins.js.map +0 -1
- package/dist/intelligence/skills/loader.js.map +0 -1
- package/dist/intelligence/skills/registry.js.map +0 -1
- package/dist/intelligence/skills/types.js.map +0 -1
- package/dist/intelligence/verification/engine.js.map +0 -1
- package/dist/intelligence/verification/reviewer.js.map +0 -1
- package/dist/intelligence/verification/types.js.map +0 -1
- package/dist/knowledge/facts.js.map +0 -1
- package/dist/mcp/protocol.js.map +0 -1
- package/dist/mcp/server.js.map +0 -1
- package/dist/mcp/setup.js.map +0 -1
- package/dist/mcp/tools.js.map +0 -1
- package/dist/mcp/types.js.map +0 -1
- package/dist/mcp/verify.js.map +0 -1
- package/dist/portability/bundle.js.map +0 -1
- package/dist/prompts/onboarding.js.map +0 -1
- package/dist/prompts/refresh.js.map +0 -1
- package/dist/prompts/requirements.js.map +0 -1
- package/dist/security/files.js.map +0 -1
- package/dist/security/redact.js.map +0 -1
- package/dist/services/agent.js.map +0 -1
- package/dist/services/analysis.js.map +0 -1
- package/dist/services/common.js.map +0 -1
- package/dist/services/doctor.js.map +0 -1
- package/dist/services/drift.js.map +0 -1
- package/dist/services/features.js.map +0 -1
- package/dist/services/graph.js.map +0 -1
- package/dist/services/init.js.map +0 -1
- package/dist/services/integrations.js.map +0 -1
- package/dist/services/intelligence.js.map +0 -1
- package/dist/services/knowledge.js.map +0 -1
- package/dist/services/migrate.js.map +0 -1
- package/dist/services/portability.js.map +0 -1
- package/dist/services/records.js.map +0 -1
- package/dist/services/refresh.js.map +0 -1
- package/dist/services/reset.js.map +0 -1
- package/dist/services/setup.js.map +0 -1
- package/dist/services/standards.js.map +0 -1
- package/dist/services/status.js.map +0 -1
- package/dist/services/taskContext.js.map +0 -1
- package/dist/services/tasks.js.map +0 -1
- package/dist/services/verify.js.map +0 -1
- package/dist/sessions/session.js.map +0 -1
- package/dist/standards/acquisition/ingest.js.map +0 -1
- package/dist/standards/applicability/engine.js.map +0 -1
- package/dist/standards/builtin/code-quality.js.map +0 -1
- package/dist/standards/builtin/database-safety.js.map +0 -1
- package/dist/standards/builtin/index.js.map +0 -1
- package/dist/standards/builtin/security-baseline.js.map +0 -1
- package/dist/standards/builtin/testing-contracts.js.map +0 -1
- package/dist/standards/builtin/undo-kit.js.map +0 -1
- package/dist/standards/config/config.js.map +0 -1
- package/dist/standards/distribution/cache.js.map +0 -1
- package/dist/standards/distribution/index.js.map +0 -1
- package/dist/standards/distribution/keys.js.map +0 -1
- package/dist/standards/distribution/package.js.map +0 -1
- package/dist/standards/distribution/server.js.map +0 -1
- package/dist/standards/distribution/sync.js.map +0 -1
- package/dist/standards/distribution/types.js.map +0 -1
- package/dist/standards/engine/compliance.js.map +0 -1
- package/dist/standards/engine/engine.js.map +0 -1
- package/dist/standards/engine/reporter.js.map +0 -1
- package/dist/standards/index.js.map +0 -1
- package/dist/standards/registry/registry.js.map +0 -1
- package/dist/standards/schema/types.js.map +0 -1
- package/dist/standards/schema/validate.js.map +0 -1
- package/dist/standards/templates/index.js.map +0 -1
- package/dist/standards/validators/database.js.map +0 -1
- package/dist/standards/validators/quality.js.map +0 -1
- package/dist/standards/validators/registry.js.map +0 -1
- package/dist/standards/validators/security.js.map +0 -1
- package/dist/standards/validators/testing.js.map +0 -1
- package/dist/standards/validators/types.js.map +0 -1
- package/dist/standards/validators/undo-kit.js.map +0 -1
- package/dist/tasks/routing.js.map +0 -1
- package/dist/tasks/task.js.map +0 -1
- package/dist/utils/cleanup.js.map +0 -1
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/lock.js.map +0 -1
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/proc.js.map +0 -1
- package/dist/verification/safety.js.map +0 -1
- package/dist/verification/scope.js.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
|
+
import path from 'node:path';
|
|
2
3
|
import { StageLockManager } from './lock-manager.js';
|
|
3
4
|
import { NativeRuntimeAdapter } from '../runtime/native.js';
|
|
4
|
-
import { createExecutionId } from '../runtime/boundary.js';
|
|
5
|
+
import { createExecutionId, evaluateApprovalGrants, evaluateStageScope, readRevokedGrantState, recordApprovalAuditEvent, revokeApprovalGrant, verifyGrantSecurity, withRevocationAuthLock, } from '../runtime/boundary.js';
|
|
6
|
+
import { captureWorkspaceSnapshotDetailed, detectGitRenames, diffWorkspaceSnapshots, hashWorkspaceSnapshot, } from '../runtime/changes.js';
|
|
5
7
|
import { isValidStateTransition } from './types.js';
|
|
6
8
|
import { DevWorkspaceError } from '../../errors/index.js';
|
|
7
9
|
import { redact } from '../../security/redact.js';
|
|
@@ -13,13 +15,15 @@ export class OrchestrationEngine {
|
|
|
13
15
|
router;
|
|
14
16
|
store;
|
|
15
17
|
lockManager;
|
|
16
|
-
|
|
18
|
+
authProvider;
|
|
19
|
+
constructor(router, store, authProvider) {
|
|
17
20
|
this.router = router;
|
|
18
21
|
this.store = store;
|
|
19
22
|
this.lockManager = new StageLockManager();
|
|
23
|
+
this.authProvider = authProvider;
|
|
20
24
|
}
|
|
21
|
-
/** Compute a workspace
|
|
22
|
-
async
|
|
25
|
+
/** Compute a workspace SHA-256 fingerprint across git HEAD and all non-ignored workspace files, plus completeness metadata. */
|
|
26
|
+
async computeWorkspaceFingerprintDetailed(workspaceRoot, filePaths) {
|
|
23
27
|
const hash = crypto.createHash('sha256');
|
|
24
28
|
if (workspaceRoot) {
|
|
25
29
|
try {
|
|
@@ -29,23 +33,25 @@ export class OrchestrationEngine {
|
|
|
29
33
|
catch {
|
|
30
34
|
hash.update('head:nogit\n');
|
|
31
35
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
catch {
|
|
40
|
-
hash.update('missing-or-unsafe');
|
|
41
|
-
}
|
|
42
|
-
hash.update('\n');
|
|
43
|
-
}
|
|
36
|
+
const snapshot = await captureWorkspaceSnapshotDetailed(workspaceRoot);
|
|
37
|
+
hash.update(`snapshot:${hashWorkspaceSnapshot(snapshot)}\n`);
|
|
38
|
+
return {
|
|
39
|
+
fingerprint: hash.digest('hex'),
|
|
40
|
+
complete: snapshot.complete,
|
|
41
|
+
incompleteReasons: snapshot.incompleteReasons,
|
|
42
|
+
};
|
|
44
43
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
hash.update(`files:${[...filePaths].sort().join(',')}`);
|
|
45
|
+
return {
|
|
46
|
+
fingerprint: hash.digest('hex'),
|
|
47
|
+
complete: false,
|
|
48
|
+
incompleteReasons: ['Workspace root not supplied for fingerprint computation.'],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Compute a workspace SHA-256 fingerprint across git HEAD and all non-ignored workspace files. */
|
|
52
|
+
async computeWorkspaceFingerprint(workspaceRoot, filePaths) {
|
|
53
|
+
const res = await this.computeWorkspaceFingerprintDetailed(workspaceRoot, filePaths);
|
|
54
|
+
return res.fingerprint;
|
|
49
55
|
}
|
|
50
56
|
/** Safely load bounded contents of modified files for independent verification without leaking secrets. */
|
|
51
57
|
async loadModifiedFileContents(workspaceRoot, filePaths) {
|
|
@@ -77,11 +83,11 @@ export class OrchestrationEngine {
|
|
|
77
83
|
if (!stage.receipt || !stage.receipt.verified)
|
|
78
84
|
continue;
|
|
79
85
|
const root = workspaceRoot ?? stage.receipt.cwd;
|
|
80
|
-
const
|
|
81
|
-
if (stage.receipt.workspaceFingerprint &&
|
|
86
|
+
const fpRes = await this.computeWorkspaceFingerprintDetailed(root, stage.receipt.filesModified);
|
|
87
|
+
if (!fpRes.complete || (stage.receipt.workspaceFingerprint && fpRes.fingerprint !== stage.receipt.workspaceFingerprint)) {
|
|
82
88
|
stage.receipt.verified = false;
|
|
83
89
|
stage.receipt.stale = true;
|
|
84
|
-
stage.receipt.verificationStatus = 'NOT_TESTED';
|
|
90
|
+
stage.receipt.verificationStatus = fpRes.complete ? 'NOT_TESTED' : 'BLOCKED';
|
|
85
91
|
stage.status = 'VERIFYING';
|
|
86
92
|
stage.outputs = { ...(stage.outputs ?? {}), verified: false, stale: true, receipt: stage.receipt };
|
|
87
93
|
invalidatedStages.push(stage.id);
|
|
@@ -253,17 +259,98 @@ export class OrchestrationEngine {
|
|
|
253
259
|
await this.store.saveRun(run);
|
|
254
260
|
return run;
|
|
255
261
|
}
|
|
256
|
-
async approve(runId,
|
|
262
|
+
async approve(runId, options) {
|
|
257
263
|
const run = await this.store.getRun(runId);
|
|
258
264
|
if (!run) {
|
|
259
265
|
throw new DevWorkspaceError('NOT_FOUND', `Orchestration run "${runId}" not found.`);
|
|
260
266
|
}
|
|
261
|
-
|
|
267
|
+
const provider = options?.authProvider ?? this.authProvider;
|
|
268
|
+
if (!provider) {
|
|
269
|
+
throw new DevWorkspaceError('SECURITY', 'ApprovalAuthProvider is required to authenticate approval (fail-closed).');
|
|
270
|
+
}
|
|
271
|
+
const session = await provider.authenticate(options?.credentials);
|
|
272
|
+
const grants = options?.grants ?? [];
|
|
273
|
+
const workspaceRoot = options?.workspaceRoot;
|
|
274
|
+
if (run.state !== 'AWAITING_APPROVAL' && run.state !== 'WAITING_APPROVAL' && grants.length === 0) {
|
|
262
275
|
throw new DevWorkspaceError('USAGE', `Run "${runId}" is in state "${run.state}", not AWAITING_APPROVAL.`);
|
|
263
276
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
277
|
+
if (grants.length > 0) {
|
|
278
|
+
for (const g of grants) {
|
|
279
|
+
if (!g.approverIdentity ||
|
|
280
|
+
g.approverIdentity.principalId !== session.principalId ||
|
|
281
|
+
g.approverIdentity.sessionId !== session.sessionId ||
|
|
282
|
+
g.approverIdentity.authMethod !== session.authMethod) {
|
|
283
|
+
throw new DevWorkspaceError('SECURITY', `Grant "${g.grantId}" identity/session does not match authenticated session "${session.principalId}" (${session.sessionId}).`);
|
|
284
|
+
}
|
|
285
|
+
await withRevocationAuthLock(workspaceRoot ?? g.workspaceRoot, async () => {
|
|
286
|
+
const revState = await readRevokedGrantState(workspaceRoot ?? g.workspaceRoot);
|
|
287
|
+
if (!revState.trustworthy) {
|
|
288
|
+
throw new DevWorkspaceError('IO', `Cannot verify revocation state before attaching grant "${g.grantId}": ${revState.reason}`);
|
|
289
|
+
}
|
|
290
|
+
const secCheck = await verifyGrantSecurity(g, {
|
|
291
|
+
authProvider: provider,
|
|
292
|
+
revokedGrantIds: revState.revokedIds,
|
|
293
|
+
});
|
|
294
|
+
if (!secCheck.ok) {
|
|
295
|
+
throw new DevWorkspaceError('SECURITY', `Grant "${g.grantId}" failed verification: ${secCheck.reason}`);
|
|
296
|
+
}
|
|
297
|
+
await recordApprovalAuditEvent(workspaceRoot ?? g.workspaceRoot, {
|
|
298
|
+
timestamp: new Date().toISOString(),
|
|
299
|
+
agentId: session.principalId,
|
|
300
|
+
scope: 'terminal:exec',
|
|
301
|
+
target: `${g.executable} ${g.args.join(' ')}`.trim(),
|
|
302
|
+
allowed: true,
|
|
303
|
+
requiresApproval: true,
|
|
304
|
+
eventType: 'grant-issued',
|
|
305
|
+
grantId: g.grantId,
|
|
306
|
+
approvedBy: session.principalId,
|
|
307
|
+
principalId: session.principalId,
|
|
308
|
+
sessionId: session.sessionId,
|
|
309
|
+
authMethod: session.authMethod,
|
|
310
|
+
stageId: g.stageId,
|
|
311
|
+
operation: g.operation,
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
run.approvalGrants = [...(run.approvalGrants ?? []), ...grants];
|
|
316
|
+
}
|
|
317
|
+
run.approvedBy = session.principalId;
|
|
318
|
+
run.approvedAt = session.authenticatedAt;
|
|
319
|
+
run.approvedSessionId = session.sessionId;
|
|
320
|
+
run.approvedAuthMethod = session.authMethod;
|
|
321
|
+
run.approvedAuthProviderId = provider.id;
|
|
322
|
+
if (run.state === 'AWAITING_APPROVAL' || run.state === 'WAITING_APPROVAL') {
|
|
323
|
+
this.transitionState(run, 'READY', grants.length > 0
|
|
324
|
+
? `Plan approved by ${session.principalId} (session ${session.sessionId}) with ${grants.length} signed approval grant(s). Ready for execution.`
|
|
325
|
+
: `Plan approved by ${session.principalId} (session ${session.sessionId}; no scoped command/destructive grants attached).`);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
run.updatedAt = new Date().toISOString();
|
|
329
|
+
run.checkpoints.push({
|
|
330
|
+
at: run.updatedAt,
|
|
331
|
+
state: run.state,
|
|
332
|
+
note: `Attached ${grants.length} signed approval grant(s) from ${session.principalId} (session ${session.sessionId}).`,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
await this.store.saveRun(run);
|
|
336
|
+
return run;
|
|
337
|
+
}
|
|
338
|
+
async revokeApproval(runId, grantId, revokedBy, reason = 'Revoked by operator', workspaceRoot) {
|
|
339
|
+
const run = await this.store.getRun(runId);
|
|
340
|
+
if (!run) {
|
|
341
|
+
throw new DevWorkspaceError('NOT_FOUND', `Orchestration run "${runId}" not found.`);
|
|
342
|
+
}
|
|
343
|
+
const target = run.approvalGrants?.find((g) => g.grantId === grantId);
|
|
344
|
+
if (!target) {
|
|
345
|
+
throw new DevWorkspaceError('NOT_FOUND', `Approval grant "${grantId}" not found on run "${runId}".`);
|
|
346
|
+
}
|
|
347
|
+
await revokeApprovalGrant(target, revokedBy, reason, workspaceRoot ?? target.workspaceRoot);
|
|
348
|
+
run.updatedAt = new Date().toISOString();
|
|
349
|
+
run.checkpoints.push({
|
|
350
|
+
at: run.updatedAt,
|
|
351
|
+
state: run.state,
|
|
352
|
+
note: `Approval grant "${grantId}" revoked by ${revokedBy}: ${reason}`,
|
|
353
|
+
});
|
|
267
354
|
await this.store.saveRun(run);
|
|
268
355
|
return run;
|
|
269
356
|
}
|
|
@@ -307,15 +394,40 @@ export class OrchestrationEngine {
|
|
|
307
394
|
if (run.state === 'CANCELLED' || run.state === 'TIMED_OUT') {
|
|
308
395
|
throw new DevWorkspaceError('USAGE', `Cannot run "${run.runId}" in terminal state "${run.state}".`);
|
|
309
396
|
}
|
|
310
|
-
|
|
397
|
+
const allGrants = [...(run.approvalGrants ?? []), ...(options.approvalGrants ?? [])];
|
|
398
|
+
const activeAuthProvider = options.authProvider ?? this.authProvider;
|
|
399
|
+
// Approval gating: require cryptographically verified scoped approval grants; fail closed if authentication is unavailable
|
|
311
400
|
if (run.state === 'AWAITING_APPROVAL' || run.state === 'WAITING_APPROVAL') {
|
|
312
|
-
if (options.
|
|
313
|
-
|
|
401
|
+
if (options.approvalGrants && options.approvalGrants.length > 0) {
|
|
402
|
+
if (!activeAuthProvider) {
|
|
403
|
+
throw new DevWorkspaceError('SECURITY', 'ApprovalAuthProvider is required to verify supplied approval grants (fail-closed).');
|
|
404
|
+
}
|
|
405
|
+
for (const g of options.approvalGrants) {
|
|
406
|
+
await withRevocationAuthLock(options.workspaceRoot ?? g.workspaceRoot, async () => {
|
|
407
|
+
const revState = await readRevokedGrantState(options.workspaceRoot ?? g.workspaceRoot);
|
|
408
|
+
if (!revState.trustworthy) {
|
|
409
|
+
throw new DevWorkspaceError('IO', `Cannot verify revocation state: ${revState.reason}`);
|
|
410
|
+
}
|
|
411
|
+
const secCheck = await verifyGrantSecurity(g, {
|
|
412
|
+
authProvider: activeAuthProvider,
|
|
413
|
+
revokedGrantIds: revState.revokedIds,
|
|
414
|
+
});
|
|
415
|
+
if (!secCheck.ok) {
|
|
416
|
+
throw new DevWorkspaceError('SECURITY', `Grant "${g.grantId}" rejected: ${secCheck.reason}`);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
const leadGrant = options.approvalGrants[0];
|
|
421
|
+
run.approvedBy = run.approvedBy ?? leadGrant.approvedBy;
|
|
314
422
|
run.approvedAt = new Date().toISOString();
|
|
315
|
-
|
|
423
|
+
run.approvedSessionId = run.approvedSessionId ?? leadGrant.approverIdentity.sessionId;
|
|
424
|
+
run.approvedAuthMethod = run.approvedAuthMethod ?? leadGrant.approverIdentity.authMethod;
|
|
425
|
+
run.approvedAuthProviderId = run.approvedAuthProviderId ?? activeAuthProvider.id;
|
|
426
|
+
run.approvalGrants = allGrants;
|
|
427
|
+
this.transitionState(run, 'READY', `Execution unlocked with ${options.approvalGrants.length} verified signed approval grant(s).`);
|
|
316
428
|
}
|
|
317
429
|
else {
|
|
318
|
-
throw new DevWorkspaceError('USAGE', `Run "${run.runId}" requires developer approval before execution.`);
|
|
430
|
+
throw new DevWorkspaceError('USAGE', `Run "${run.runId}" requires scoped developer approval before execution (authenticated via ApprovalAuthProvider).`);
|
|
319
431
|
}
|
|
320
432
|
}
|
|
321
433
|
if (run.state !== 'READY' && run.state !== 'PAUSED' && run.state !== 'BLOCKED') {
|
|
@@ -351,12 +463,123 @@ export class OrchestrationEngine {
|
|
|
351
463
|
await this.store.saveRun(run);
|
|
352
464
|
return run;
|
|
353
465
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
466
|
+
const stageExternalCfg = stage.inputs.externalExecution ?? options.externalExecution;
|
|
467
|
+
const stageCommand = stage.inputs.command ?? stageExternalCfg?.command;
|
|
468
|
+
const rootForStage = options.workspaceRoot ?? stageExternalCfg?.sandboxPath;
|
|
469
|
+
// Destructive operations safety gate: serialized against concurrent revocations via shared revocation-auth lock
|
|
470
|
+
if (stage.isDestructive) {
|
|
471
|
+
const gateResult = await withRevocationAuthLock(rootForStage, async () => {
|
|
472
|
+
const revState = await readRevokedGrantState(rootForStage);
|
|
473
|
+
if (!revState.trustworthy) {
|
|
474
|
+
if (rootForStage) {
|
|
475
|
+
try {
|
|
476
|
+
await recordApprovalAuditEvent(rootForStage, {
|
|
477
|
+
timestamp: new Date().toISOString(),
|
|
478
|
+
agentId: stage.agentId,
|
|
479
|
+
scope: 'terminal:exec',
|
|
480
|
+
target: stageCommand?.join(' ') ?? stage.name,
|
|
481
|
+
allowed: false,
|
|
482
|
+
requiresApproval: true,
|
|
483
|
+
eventType: 'grant-rejected',
|
|
484
|
+
stageId: stage.id,
|
|
485
|
+
operation: 'destructive-op',
|
|
486
|
+
reason: revState.reason,
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
// Already blocking execution due to untrustworthy revocation store
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return {
|
|
494
|
+
allowed: false,
|
|
495
|
+
nextState: 'BLOCKED',
|
|
496
|
+
reason: revState.reason ?? 'Untrustworthy revocation store.',
|
|
497
|
+
untrustedRevocation: true,
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
const revokedIds = revState.revokedIds;
|
|
501
|
+
const normalizedRoot = rootForStage ? path.resolve(rootForStage).replace(/[\\/]+$/, '') : undefined;
|
|
502
|
+
let hasDestructiveGrant = false;
|
|
503
|
+
let destructiveRejectionReason = 'Missing, expired, or revoked destructive-op ApprovalGrant.';
|
|
504
|
+
if (!activeAuthProvider) {
|
|
505
|
+
destructiveRejectionReason = 'Approval authentication provider is unavailable; destructive execution fails closed.';
|
|
506
|
+
}
|
|
507
|
+
else if (stageCommand && stageCommand.length > 0 && rootForStage) {
|
|
508
|
+
const evalRes = await evaluateApprovalGrants(allGrants, ['destructive-op'], stageCommand, rootForStage, {
|
|
509
|
+
stageId: stage.id,
|
|
510
|
+
revokedGrantIds: revokedIds,
|
|
511
|
+
authProvider: activeAuthProvider,
|
|
512
|
+
allowStageIndependent: options.allowStageIndependent,
|
|
513
|
+
});
|
|
514
|
+
hasDestructiveGrant = evalRes.matched;
|
|
515
|
+
if (!evalRes.matched && evalRes.reason)
|
|
516
|
+
destructiveRejectionReason = evalRes.reason;
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
for (const g of allGrants) {
|
|
520
|
+
if (g.operation !== 'destructive-op')
|
|
521
|
+
continue;
|
|
522
|
+
if (normalizedRoot) {
|
|
523
|
+
const gRoot = path.resolve(g.workspaceRoot).replace(/[\\/]+$/, '');
|
|
524
|
+
const rootMatch = process.platform === 'win32'
|
|
525
|
+
? gRoot.toLowerCase() === normalizedRoot.toLowerCase()
|
|
526
|
+
: gRoot === normalizedRoot;
|
|
527
|
+
if (!rootMatch)
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
const stageCheck = evaluateStageScope(g, stage.id, Boolean(options.allowStageIndependent));
|
|
531
|
+
if (!stageCheck.ok) {
|
|
532
|
+
destructiveRejectionReason = stageCheck.reason;
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
const secCheck = await verifyGrantSecurity(g, {
|
|
536
|
+
authProvider: activeAuthProvider,
|
|
537
|
+
revokedGrantIds: revokedIds,
|
|
538
|
+
});
|
|
539
|
+
if (!secCheck.ok) {
|
|
540
|
+
destructiveRejectionReason = secCheck.reason;
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
hasDestructiveGrant = true;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (!hasDestructiveGrant) {
|
|
548
|
+
if (rootForStage) {
|
|
549
|
+
await recordApprovalAuditEvent(rootForStage, {
|
|
550
|
+
timestamp: new Date().toISOString(),
|
|
551
|
+
agentId: stage.agentId,
|
|
552
|
+
scope: 'terminal:exec',
|
|
553
|
+
target: stageCommand?.join(' ') ?? stage.name,
|
|
554
|
+
allowed: false,
|
|
555
|
+
requiresApproval: true,
|
|
556
|
+
eventType: 'grant-rejected',
|
|
557
|
+
stageId: stage.id,
|
|
558
|
+
operation: 'destructive-op',
|
|
559
|
+
reason: destructiveRejectionReason,
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
const nextState = !activeAuthProvider && allGrants.length > 0 ? 'BLOCKED' : 'WAITING_APPROVAL';
|
|
563
|
+
return {
|
|
564
|
+
allowed: false,
|
|
565
|
+
nextState,
|
|
566
|
+
reason: destructiveRejectionReason,
|
|
567
|
+
untrustedRevocation: false,
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
return { allowed: true };
|
|
571
|
+
});
|
|
572
|
+
if (!gateResult.allowed) {
|
|
573
|
+
stage.status = gateResult.nextState;
|
|
574
|
+
if (gateResult.nextState === 'BLOCKED') {
|
|
575
|
+
stage.error = gateResult.reason;
|
|
576
|
+
run.error = gateResult.reason;
|
|
577
|
+
}
|
|
578
|
+
const prefix = gateResult.untrustedRevocation ? 'Execution blocked' : 'Execution halted';
|
|
579
|
+
this.transitionState(run, gateResult.nextState, `${prefix}: ${gateResult.reason}`, stage.id);
|
|
580
|
+
await this.store.saveRun(run);
|
|
581
|
+
return run;
|
|
582
|
+
}
|
|
360
583
|
}
|
|
361
584
|
// Single-writer lock acquisition for claimed files
|
|
362
585
|
if (stage.claimedFiles.length > 0) {
|
|
@@ -378,22 +601,53 @@ export class OrchestrationEngine {
|
|
|
378
601
|
let haltState = null;
|
|
379
602
|
while (!stageSuccess && stage.retryCount <= run.maxRetries) {
|
|
380
603
|
try {
|
|
604
|
+
const preExecSnapshot = rootForStage ? await captureWorkspaceSnapshotDetailed(rootForStage) : null;
|
|
381
605
|
const execRes = await adapter.execute({
|
|
382
606
|
agentId: stage.agentId,
|
|
383
607
|
role: stage.name,
|
|
384
608
|
prompt: run.request,
|
|
385
609
|
skills: stage.skillIds,
|
|
386
610
|
contextFiles: stage.claimedFiles,
|
|
611
|
+
stageId: stage.id,
|
|
387
612
|
timeoutMs: timeoutMs > 0 ? Math.max(1000, timeoutMs - (Date.now() - startTs)) : undefined,
|
|
388
613
|
signal: options.signal,
|
|
389
|
-
command:
|
|
390
|
-
cwd:
|
|
391
|
-
workspaceRoot:
|
|
392
|
-
|
|
614
|
+
command: stageCommand,
|
|
615
|
+
cwd: rootForStage,
|
|
616
|
+
workspaceRoot: rootForStage,
|
|
617
|
+
approvalGrants: allGrants,
|
|
618
|
+
authProvider: activeAuthProvider,
|
|
619
|
+
allowStageIndependent: options.allowStageIndependent,
|
|
620
|
+
allowExternalExecution: stageExternalCfg?.allowed,
|
|
621
|
+
sandboxPath: stageExternalCfg?.sandboxPath ?? rootForStage,
|
|
622
|
+
allowlistedEnvKeys: stageExternalCfg?.allowlistedEnvKeys,
|
|
393
623
|
});
|
|
624
|
+
const postExecSnapshot = rootForStage ? await captureWorkspaceSnapshotDetailed(rootForStage) : null;
|
|
625
|
+
let changeManifest;
|
|
626
|
+
if (preExecSnapshot && postExecSnapshot && rootForStage) {
|
|
627
|
+
const gitRenames = await detectGitRenames(rootForStage);
|
|
628
|
+
changeManifest = diffWorkspaceSnapshots(preExecSnapshot, postExecSnapshot, gitRenames);
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
changeManifest = execRes.changeManifest ?? {
|
|
632
|
+
created: [],
|
|
633
|
+
modified: [],
|
|
634
|
+
deleted: [],
|
|
635
|
+
renamed: [],
|
|
636
|
+
changedFiles: [],
|
|
637
|
+
snapshotComplete: false,
|
|
638
|
+
snapshotIncompleteReasons: ['No workspace root was supplied for execution change capture.'],
|
|
639
|
+
};
|
|
640
|
+
}
|
|
394
641
|
const execId = execRes.executionId ?? createExecutionId('exec');
|
|
395
642
|
const execStatus = execRes.status ?? (execRes.ok ? 'SUCCEEDED' : 'FAILED');
|
|
396
|
-
const execFiles =
|
|
643
|
+
const execFiles = changeManifest.changedFiles;
|
|
644
|
+
const inspectableFiles = [...new Set([
|
|
645
|
+
...changeManifest.created,
|
|
646
|
+
...changeManifest.modified,
|
|
647
|
+
...changeManifest.renamed.map((r) => r.to),
|
|
648
|
+
])];
|
|
649
|
+
stage.modifiedFiles = execFiles;
|
|
650
|
+
stage.changeManifest = changeManifest;
|
|
397
651
|
const baseReceipt = (verified, verificationStatus, fp, report) => ({
|
|
398
652
|
executionId: execId,
|
|
399
653
|
stageId: stage.id,
|
|
@@ -405,8 +659,8 @@ export class OrchestrationEngine {
|
|
|
405
659
|
verifiedAt: report?.verifiedAt,
|
|
406
660
|
checksPerformed: report?.checksPerformed ?? [],
|
|
407
661
|
evidenceRefs: report?.evidenceRefs ?? execFiles,
|
|
408
|
-
command: execRes.command ??
|
|
409
|
-
cwd: execRes.cwd ??
|
|
662
|
+
command: execRes.command ?? stageCommand,
|
|
663
|
+
cwd: execRes.cwd ?? rootForStage,
|
|
410
664
|
exitCode: execRes.exitCode,
|
|
411
665
|
durationMs: execRes.durationMs,
|
|
412
666
|
stdout: execRes.stdout,
|
|
@@ -414,6 +668,7 @@ export class OrchestrationEngine {
|
|
|
414
668
|
timedOut: execRes.timedOut,
|
|
415
669
|
aborted: execRes.aborted,
|
|
416
670
|
filesModified: execFiles,
|
|
671
|
+
changeManifest,
|
|
417
672
|
executedAt: execRes.endedAt ?? new Date().toISOString(),
|
|
418
673
|
verified,
|
|
419
674
|
verificationReport: report,
|
|
@@ -442,9 +697,23 @@ export class OrchestrationEngine {
|
|
|
442
697
|
if (execStatus !== 'SUCCEEDED' || !execRes.ok) {
|
|
443
698
|
throw new Error(execRes.error || 'Stage execution failed in runtime adapter.');
|
|
444
699
|
}
|
|
445
|
-
//
|
|
446
|
-
const rootForVerify =
|
|
447
|
-
const
|
|
700
|
+
// Fail closed if workspace snapshot inspection was incomplete (truncation, unreadable dirs/files)
|
|
701
|
+
const rootForVerify = rootForStage ?? execRes.cwd;
|
|
702
|
+
const fpResult = await this.computeWorkspaceFingerprintDetailed(rootForVerify, execFiles);
|
|
703
|
+
const preVerifyFingerprint = fpResult.fingerprint;
|
|
704
|
+
const snapshotComplete = changeManifest.snapshotComplete && fpResult.complete;
|
|
705
|
+
const incompleteReasons = [...new Set([
|
|
706
|
+
...changeManifest.snapshotIncompleteReasons,
|
|
707
|
+
...fpResult.incompleteReasons,
|
|
708
|
+
])];
|
|
709
|
+
if (!snapshotComplete) {
|
|
710
|
+
const incompleteReceipt = baseReceipt(false, 'BLOCKED', preVerifyFingerprint);
|
|
711
|
+
stage.receipt = incompleteReceipt;
|
|
712
|
+
stage.outputs = { outcome: 'blocked', verified: false, snapshotComplete: false, incompleteReasons, receipt: incompleteReceipt };
|
|
713
|
+
lastError = `Workspace snapshot incomplete; cannot verify completion: ${incompleteReasons.join('; ')}`;
|
|
714
|
+
haltState = 'BLOCKED';
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
448
717
|
if (!options.verificationEngine) {
|
|
449
718
|
const unverifiedReceipt = baseReceipt(false, 'NOT_TESTED', preVerifyFingerprint);
|
|
450
719
|
stage.receipt = unverifiedReceipt;
|
|
@@ -455,12 +724,18 @@ export class OrchestrationEngine {
|
|
|
455
724
|
}
|
|
456
725
|
this.transitionState(run, 'VERIFYING', `Running independent verification for stage "${stage.name}".`, stage.id);
|
|
457
726
|
const checks = stage.inputs.contractChecks ?? [];
|
|
458
|
-
const
|
|
459
|
-
const
|
|
727
|
+
const acceptanceCriteria = stage.inputs.acceptanceCriteria ?? [];
|
|
728
|
+
const criteriaMappings = stage.inputs.criteriaEvidenceMap ?? [];
|
|
729
|
+
const modified = await this.loadModifiedFileContents(rootForVerify, inspectableFiles);
|
|
730
|
+
const verificationReport = await options.verificationEngine.verify(checks, modified, acceptanceCriteria, stage.retryCount, run.maxRetries, {
|
|
460
731
|
executionId: execId,
|
|
461
732
|
stageId: stage.id,
|
|
462
733
|
workspaceFingerprint: preVerifyFingerprint,
|
|
463
734
|
evidenceRefs: execFiles,
|
|
735
|
+
changeManifest,
|
|
736
|
+
criteriaMappings,
|
|
737
|
+
snapshotComplete,
|
|
738
|
+
snapshotIncompleteReasons: incompleteReasons,
|
|
464
739
|
});
|
|
465
740
|
if (verificationReport.executionId && verificationReport.executionId !== execId) {
|
|
466
741
|
throw new Error(`Stale verification receipt rejected: bound to "${verificationReport.executionId}", expected "${execId}".`);
|
|
@@ -468,8 +743,11 @@ export class OrchestrationEngine {
|
|
|
468
743
|
if (verificationReport.workspaceFingerprint && verificationReport.workspaceFingerprint !== preVerifyFingerprint) {
|
|
469
744
|
throw new Error('Stale verification receipt rejected: workspace fingerprint mismatch.');
|
|
470
745
|
}
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
746
|
+
const postFpResult = await this.computeWorkspaceFingerprintDetailed(rootForVerify, execFiles);
|
|
747
|
+
if (!postFpResult.complete) {
|
|
748
|
+
throw new Error(`Verification invalidated: post-verify snapshot incomplete (${postFpResult.incompleteReasons.join('; ')}).`);
|
|
749
|
+
}
|
|
750
|
+
if (postFpResult.fingerprint !== preVerifyFingerprint) {
|
|
473
751
|
throw new Error('Verification invalidated: workspace files changed during verification.');
|
|
474
752
|
}
|
|
475
753
|
if (!verificationReport.canComplete || !verificationReport.mandatoryGatesPassed || verificationReport.verificationStatus !== 'PASS') {
|
|
@@ -481,6 +759,7 @@ export class OrchestrationEngine {
|
|
|
481
759
|
stage.outputs = { outcome: 'success', verified: true, receipt };
|
|
482
760
|
stage.receipt = receipt;
|
|
483
761
|
run.metrics.stagesCompleted += 1;
|
|
762
|
+
run.metrics.filesModifiedCount = new Set(run.stages.flatMap((s) => s.modifiedFiles)).size;
|
|
484
763
|
stageSuccess = true;
|
|
485
764
|
}
|
|
486
765
|
catch (err) {
|
|
@@ -575,4 +854,3 @@ export class OrchestrationEngine {
|
|
|
575
854
|
return run;
|
|
576
855
|
}
|
|
577
856
|
}
|
|
578
|
-
//# sourceMappingURL=engine.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RoutingDecision } from '../routing/types.js';
|
|
2
|
-
import type { AgentRuntimeAdapter, RuntimeExecutionStatus } from '../runtime/types.js';
|
|
2
|
+
import type { AgentRuntimeAdapter, ApprovalAuthProvider, ApprovalGrant, ApproverAuthMethod, ApproverCredentials, RuntimeExecutionStatus } from '../runtime/types.js';
|
|
3
|
+
import type { WorkspaceChangeManifest } from '../runtime/changes.js';
|
|
3
4
|
import type { IndependentVerificationEngine } from '../verification/engine.js';
|
|
4
5
|
import type { VerificationEvaluationReport, VerificationStatus } from '../verification/types.js';
|
|
5
6
|
export declare const ORCHESTRATION_STATES: readonly ["CREATED", "PLANNED", "ANALYZING", "PLANNING", "AWAITING_APPROVAL", "WAITING_APPROVAL", "READY", "RUNNING", "VERIFYING", "CORRECTING", "COMPLETED", "SUCCEEDED", "FAILED", "CANCELLED", "TIMED_OUT", "BLOCKED", "PAUSED"];
|
|
@@ -26,6 +27,7 @@ export interface ExecutionReceipt {
|
|
|
26
27
|
timedOut?: boolean;
|
|
27
28
|
aborted?: boolean;
|
|
28
29
|
filesModified: string[];
|
|
30
|
+
changeManifest?: WorkspaceChangeManifest;
|
|
29
31
|
executedAt: string;
|
|
30
32
|
verified: boolean;
|
|
31
33
|
verificationReport?: VerificationEvaluationReport;
|
|
@@ -41,6 +43,7 @@ export interface ExecutionStage {
|
|
|
41
43
|
inputs: Record<string, unknown>;
|
|
42
44
|
outputs?: Record<string, unknown>;
|
|
43
45
|
modifiedFiles: string[];
|
|
46
|
+
changeManifest?: WorkspaceChangeManifest;
|
|
44
47
|
startedAt?: string;
|
|
45
48
|
completedAt?: string;
|
|
46
49
|
error?: string;
|
|
@@ -74,6 +77,10 @@ export interface OrchestrationRun {
|
|
|
74
77
|
checkpoints: RunCheckpoint[];
|
|
75
78
|
approvedBy?: string;
|
|
76
79
|
approvedAt?: string;
|
|
80
|
+
approvedSessionId?: string;
|
|
81
|
+
approvedAuthMethod?: ApproverAuthMethod;
|
|
82
|
+
approvedAuthProviderId?: string;
|
|
83
|
+
approvalGrants?: ApprovalGrant[];
|
|
77
84
|
cancellationReason?: string;
|
|
78
85
|
retryCount: number;
|
|
79
86
|
maxRetries: number;
|
|
@@ -95,6 +102,18 @@ export interface PlanOptions {
|
|
|
95
102
|
maxRetries?: number;
|
|
96
103
|
dryRun?: boolean;
|
|
97
104
|
}
|
|
105
|
+
export interface ExternalExecutionConfig {
|
|
106
|
+
allowed: boolean;
|
|
107
|
+
sandboxPath?: string;
|
|
108
|
+
command?: string[];
|
|
109
|
+
allowlistedEnvKeys?: string[];
|
|
110
|
+
}
|
|
111
|
+
export interface ApproveRunOptions {
|
|
112
|
+
authProvider: ApprovalAuthProvider;
|
|
113
|
+
credentials: ApproverCredentials;
|
|
114
|
+
grants?: ApprovalGrant[];
|
|
115
|
+
workspaceRoot?: string;
|
|
116
|
+
}
|
|
98
117
|
export interface RunOptions {
|
|
99
118
|
runId: string;
|
|
100
119
|
timeoutSeconds?: number;
|
|
@@ -102,7 +121,15 @@ export interface RunOptions {
|
|
|
102
121
|
signal?: AbortSignal;
|
|
103
122
|
runtimeAdapter?: AgentRuntimeAdapter;
|
|
104
123
|
verificationEngine?: IndependentVerificationEngine;
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated Blanket boolean approval no longer authorizes concrete command execution,
|
|
126
|
+
* external provider invocation, or destructive operations; pass bound `approvalGrants`.
|
|
127
|
+
*/
|
|
105
128
|
explicitApproval?: boolean;
|
|
129
|
+
approvalGrants?: ApprovalGrant[];
|
|
130
|
+
authProvider?: ApprovalAuthProvider;
|
|
131
|
+
allowStageIndependent?: boolean;
|
|
132
|
+
externalExecution?: ExternalExecutionConfig;
|
|
106
133
|
workspaceRoot?: string;
|
|
107
134
|
}
|
|
108
135
|
/**
|
|
@@ -36,7 +36,7 @@ export class GoogleAdkAdapter {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
if (request.command && request.command.length > 0) {
|
|
39
|
-
return executeBoundedCommand(request, request.command, 'agent', 60_000, true);
|
|
39
|
+
return executeBoundedCommand(request, request.command, 'agent', 60_000, true, ['external-agent']);
|
|
40
40
|
}
|
|
41
41
|
return nonExecutedResponse('UNSUPPORTED', {
|
|
42
42
|
executionKind: 'none',
|
|
@@ -46,4 +46,3 @@ export class GoogleAdkAdapter {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
//# sourceMappingURL=adapter.js.map
|