@moretea-labs/forge 1.8.0 → 1.8.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/AGENTS.md +73 -7
- package/CHANGELOG.md +34 -0
- package/CLAUDE.md +17 -2
- package/CONTRIBUTING.md +3 -2
- package/README.en.md +24 -3
- package/README.md +10 -6
- package/README.zh-CN.md +5 -3
- package/THIRD_PARTY_NOTICES.md +1 -2
- package/adapters/chatgpt/browser-delivery-host.ts +7 -1
- package/adapters/chatgpt/browser-delivery-runtime.ts +531 -56
- package/adapters/chatgpt/controller-binding-store.ts +101 -22
- package/adapters/chatgpt/controller-round-host.ts +15 -25
- package/adapters/chatgpt/controller-round-settlement-store.ts +58 -4
- package/adapters/chatgpt/provider-delivery.ts +229 -2
- package/adapters/chatgpt/work-conversation-binding-store.ts +99 -54
- package/adapters/computer/chatgpt-extension-target.ts +708 -0
- package/adapters/computer/chrome-extension/background.js +541 -0
- package/adapters/computer/chrome-extension/content.js +402 -0
- package/adapters/computer/chrome-extension/core.js +24 -0
- package/adapters/computer/chrome-extension/manifest.json +32 -0
- package/adapters/computer/desktop-operator-discovery.ts +11 -31
- package/adapters/computer/desktop-operator-provider.ts +18 -6
- package/adapters/computer/interaction-target-authority.ts +178 -24
- package/adapters/mcp/access-mode.ts +18 -39
- package/adapters/mcp/auth.ts +2 -7
- package/adapters/mcp/instructions.ts +6 -5
- package/adapters/mcp/multi-repository.ts +10 -47
- package/adapters/mcp/oauth.ts +73 -0
- package/adapters/mcp/paths.ts +4 -1
- package/adapters/mcp/runtime-gateway/bounded-result-runtime.ts +62 -0
- package/adapters/mcp/runtime-gateway/cognition-settlement.ts +201 -0
- package/adapters/mcp/runtime-gateway/context-adapter.ts +490 -113
- package/adapters/mcp/runtime-gateway/context-pack-sidecar.ts +83 -0
- package/adapters/mcp/runtime-gateway/controller-authority-adapter.ts +20 -5
- package/adapters/mcp/runtime-gateway/core-capability-adapter.ts +258 -0
- package/adapters/mcp/runtime-gateway/engineering-preconditions.ts +10 -27
- package/adapters/mcp/runtime-gateway/engineering-tool-contract.ts +15 -0
- package/adapters/mcp/runtime-gateway/execution-tools.ts +14 -54
- package/adapters/mcp/runtime-gateway/gateway-execution-adapter.ts +2 -1
- package/adapters/mcp/runtime-gateway/plugin-adapter.ts +132 -47
- package/adapters/mcp/runtime-gateway/process-tools.ts +173 -23
- package/adapters/mcp/runtime-gateway/protected-computer-adapter.ts +16 -4
- package/adapters/mcp/runtime-gateway/recovery-adapter.ts +69 -52
- package/adapters/mcp/runtime-gateway/repository-compat-adapter.ts +4 -35
- package/adapters/mcp/runtime-gateway/result-adapter.ts +10 -4
- package/adapters/mcp/runtime-gateway/router.ts +19 -507
- package/adapters/mcp/runtime-gateway/routing-policy.ts +506 -0
- package/adapters/mcp/runtime-gateway/runtime-observation-adapter.ts +15 -66
- package/adapters/mcp/runtime-gateway/runtime-readiness-observation.ts +218 -0
- package/adapters/mcp/runtime-gateway/runtime-tool-definitions.ts +123 -178
- package/adapters/mcp/runtime-gateway/runtime-tools.ts +11 -5
- package/adapters/mcp/runtime-gateway/scheduler-adapter.ts +37 -1
- package/adapters/mcp/runtime-gateway/shared-adapter.ts +20 -0
- package/adapters/mcp/runtime-gateway/status-inbox-adapter.ts +416 -270
- package/adapters/mcp/runtime-gateway/typescript-navigation-sidecar.ts +140 -0
- package/adapters/mcp/runtime-gateway/work-adapter.ts +262 -3123
- package/adapters/mcp/runtime-gateway/work-controller-operations.ts +257 -0
- package/adapters/mcp/runtime-gateway/work-detail-projection.ts +60 -0
- package/adapters/mcp/runtime-gateway/work-input-wire-migration.ts +229 -0
- package/adapters/mcp/runtime-gateway/work-learning-operations.ts +145 -0
- package/adapters/mcp/runtime-gateway/work-list-projection.ts +38 -0
- package/adapters/mcp/runtime-gateway/work-plan-operations.ts +382 -0
- package/adapters/mcp/runtime-gateway/work-repair-adapter.ts +308 -0
- package/adapters/mcp/runtime-gateway/work-requirement-operations.ts +148 -0
- package/adapters/mcp/runtime-gateway/work-semantic-operations.ts +320 -0
- package/adapters/mcp/runtime-gateway/work-workflow-operations.ts +113 -0
- package/adapters/mcp/runtime-gateway/workflow-supervisor-adapter.ts +180 -0
- package/adapters/mcp/server.ts +91 -26
- package/adapters/mcp/setup.ts +5 -13
- package/adapters/mcp/tool-mapping/access-tools.ts +0 -6
- package/adapters/mcp/tool-mapping/legacy-tool-service.ts +703 -3092
- package/adapters/mcp/tool-mapping/post-finalize-work-attribution.ts +5 -10
- package/adapters/mcp/tool-mapping/repository-tools.ts +170 -213
- package/adapters/mcp/toolset-names.ts +11 -37
- package/adapters/mcp/toolset.ts +19 -92
- package/{src/cli → adapters}/mcp/transports/AGENTS.md +5 -5
- package/{src/cli → adapters}/mcp/transports/CLAUDE.md +5 -5
- package/adapters/mcp/transports/http-observation.ts +377 -0
- package/adapters/mcp/transports/http-post-lifecycle.ts +19 -0
- package/adapters/mcp/transports/http.ts +200 -683
- package/adapters/mcp/transports/oauth-http.ts +322 -0
- package/adapters/mcp/transports/session-registry.ts +6 -0
- package/adapters/mcp/tunnels/openai-secure-tunnel.ts +89 -5
- package/adapters/mcp/types.ts +0 -6
- package/assets/hooks/lib/session-state.sh +0 -38
- package/assets/hooks/post-bash.sh +1 -1
- package/assets/hooks/post-tool-observer.sh +0 -5
- package/assets/hooks/prompt-guard.sh +0 -55
- package/assets/partials/04-project-structure.partial.md +1 -1
- package/assets/partials/07-footer.partial.md +1 -1
- package/assets/partials-agents/02-operating-mode.partial.md +1 -1
- package/assets/partials-agents/08-deep-docs.partial.md +1 -1
- package/assets/plugin-registry.v1.json +6 -4
- package/assets/reference-configs/agentic-development-flow.md +26 -1
- package/assets/reference-configs/external-tooling.md +0 -76
- package/assets/reference-configs/global-working-rules.md +19 -0
- package/assets/reference-configs/release-deploy.md +1 -1
- package/assets/templates/helpers/architecture-queue.sh +1 -1
- package/assets/templates/helpers/check-agent-tooling.sh +1 -327
- package/assets/templates/helpers/check-task-workflow.sh +1 -1
- package/assets/templates/helpers/ensure-task-workflow.sh +0 -14
- package/assets/templates/helpers/migrate-project-template.sh +2 -2
- package/assets/workflow-contract.v1.json +0 -2
- package/docs/README.md +5 -2
- package/docs/architecture/CURRENT.md +205 -51
- package/docs/architecture/decisions/20260803-release-identity-binding-and-exit-policy.md +14 -5
- package/docs/architecture/decisions/20260823-immediate-controller-relay.md +6 -3
- package/docs/architecture/decisions/20260904-ios-device-migration-baseline.md +42 -0
- package/docs/architecture/decisions/20260907-assistant-learning-loop.md +2 -0
- package/docs/architecture/decisions/20260907-controller-round-transition-policy.md +19 -4
- package/docs/architecture/decisions/20260916-workflow-supervisor-authority.md +249 -0
- package/docs/architecture/decisions/20260917-cognitive-memory-foundation.md +82 -0
- package/docs/architecture/decisions/20260918-stable-candidate-release-lifecycle.md +234 -0
- package/docs/architecture/decisions/20260919-autonomous-work-liveness.md +62 -0
- package/docs/architecture/decisions/20260924-thin-semantic-working-context.md +74 -0
- package/docs/architecture/decisions/20261001-supervisor-turn-authority.md +342 -0
- package/docs/architecture/decisions/20261005-forge-v3-desktop-client-boundary.md +77 -0
- package/docs/architecture/decisions/20261009-exact-code-context-discovery.md +19 -0
- package/docs/architecture/decisions/20261009-generated-xcode-cache-retention.md +37 -0
- package/docs/architecture/decisions/20261011-autonomous-continuation-convergence.md +597 -0
- package/docs/architecture/decisions/20261017-edit-session-finalization-reconciliation.md +17 -0
- package/docs/architecture/decisions/20261019-retire-host-skills.md +16 -0
- package/docs/architecture/diagrams/agentic-dev-plugin-architecture.html +1 -1
- package/docs/architecture/domains/public-surface.md +3 -5
- package/docs/architecture/domains/verification.md +6 -5
- package/docs/architecture/domains/workflow-engine.md +6 -0
- package/docs/architecture/modules/controller-runtime/transport-lifecycle.md +3 -3
- package/docs/architecture/requests/2026-09-04-computer-plugin-workflow-taxonomy.md +4 -4
- package/docs/architecture/reviews/20261015-code-search-runtime-acceptance.md +75 -0
- package/docs/forge-plugin-management.md +16 -4
- package/docs/operations/controller-browser-plugin.md +23 -0
- package/docs/operations/controller-performance-and-502.md +17 -0
- package/docs/operations/controller-reliability-runbook.md +2 -2
- package/docs/operations/features.md +6 -7
- package/docs/operations/features.zh-CN.md +1 -1
- package/docs/operations/github-repository.md +4 -4
- package/docs/operations/github-semantic-release-projection.md +20 -0
- package/docs/operations/homebrew.md +2 -2
- package/docs/operations/mcp-tool-exposure.md +13 -52
- package/docs/operations/releasing.md +2 -0
- package/docs/operations/runtime-performance-diagnostics.md +8 -0
- package/docs/operations/standalone-disaster-recovery.md +15 -7
- package/docs/tutorials/01-install-and-start.zh-CN.md +1 -1
- package/docs/tutorials/03-first-repository-task.md +2 -0
- package/docs/wiki/Computer-and-Plugins.md +78 -0
- package/docs/wiki/Computer-and-Plugins.zh-CN.md +88 -0
- package/docs/wiki/Home.md +16 -2
- package/docs/wiki/Implementation.md +25 -13
- package/docs/wiki/Installation.md +28 -32
- package/docs/wiki/Integrations.md +4 -0
- package/docs/wiki/Quick-Start.md +35 -22
- package/docs/wiki/Releases-and-Upgrades.md +15 -25
- package/docs/wiki/_Sidebar.md +5 -1
- package/package.json +25 -25
- package/packages/kernel/cognition/api/index.ts +6 -0
- package/packages/kernel/cognition/application/activation-service.ts +451 -0
- package/packages/kernel/cognition/application/consolidation-service.ts +185 -0
- package/packages/kernel/cognition/application/legacy-experience-adapter.ts +38 -0
- package/packages/kernel/cognition/application/memory-service.ts +64 -0
- package/packages/kernel/cognition/domain/learning.ts +106 -0
- package/packages/kernel/cognition/domain/memory.ts +254 -0
- package/packages/kernel/controller/api/index.ts +1 -0
- package/packages/kernel/controller/application/continuation-service.ts +281 -0
- package/packages/kernel/controller/application/controller-round-service.ts +12 -0
- package/packages/kernel/controller/domain/controller-round-transition-policy.ts +242 -21
- package/packages/kernel/controller/domain/controller-round.ts +4 -1
- package/packages/kernel/controller/domain/execution-quality.ts +3 -1
- package/packages/kernel/controller/infrastructure/controller-round-store.ts +689 -103
- package/packages/kernel/controller/infrastructure/controller-session-store.ts +348 -97
- package/packages/kernel/controller/ports/controller-host.ts +2 -0
- package/packages/kernel/identity/api/index.ts +10 -0
- package/packages/kernel/identity/domain/activity-projection.ts +43 -0
- package/packages/kernel/identity/domain/capability-broker.ts +60 -0
- package/packages/kernel/identity/domain/grant.ts +72 -0
- package/packages/kernel/identity/domain/owned-resource.ts +116 -0
- package/packages/kernel/identity/domain/user-request.ts +93 -0
- package/packages/kernel/identity/infrastructure/activity-projection-store.ts +87 -0
- package/packages/kernel/identity/infrastructure/capability-broker.ts +81 -0
- package/packages/kernel/identity/infrastructure/grant-store.ts +284 -0
- package/packages/kernel/identity/infrastructure/owned-resource-store.ts +259 -0
- package/packages/kernel/identity/infrastructure/user-request-store.ts +182 -0
- package/packages/kernel/scheduler/api/index.ts +0 -2
- package/packages/kernel/scheduler/application/eligibility.ts +4 -1
- package/packages/kernel/scheduler/application/schedule-service.ts +3 -0
- package/packages/kernel/scheduler/application/settlement.ts +0 -15
- package/packages/kernel/scheduler/domain/schedule.ts +87 -0
- package/packages/kernel/scheduler/infrastructure/schedule-store.ts +166 -143
- package/packages/kernel/work/api/index.ts +3 -2
- package/packages/kernel/work/application/work-service.ts +18 -42
- package/packages/kernel/work/domain/current-task-lineage.ts +104 -0
- package/packages/kernel/work/domain/engineering-design.ts +10 -5
- package/packages/kernel/work/domain/engineering-profile.ts +8 -12
- package/packages/kernel/work/domain/evaluation-promotion-receipt.ts +186 -0
- package/packages/kernel/work/domain/execution-concurrency.ts +19 -26
- package/packages/kernel/work/domain/execution-snapshot.ts +0 -31
- package/packages/kernel/work/domain/implementation-review.ts +14 -331
- package/packages/kernel/work/domain/objective-graph.ts +119 -0
- package/packages/kernel/work/domain/project-engineering-contract.ts +23 -1
- package/packages/kernel/work/domain/repository-completion-receipt.ts +1 -1
- package/packages/kernel/work/domain/state-machine.ts +34 -65
- package/packages/kernel/work/domain/types.ts +57 -51
- package/packages/kernel/work/infrastructure/work-contract-store.ts +847 -729
- package/packages/kernel/work/ports/work-contract-store.ts +5 -2
- package/packages/plugin-runtime/browser/provider-registry.ts +12 -36
- package/packages/plugin-runtime/browser/session-authority.ts +2 -1
- package/packages/plugin-runtime/computer/chatgpt-identity.ts +24 -0
- package/packages/plugin-runtime/computer/conversation-target.ts +153 -0
- package/packages/plugin-runtime/computer/index.ts +2 -0
- package/packages/plugin-runtime/computer/target-authority.ts +26 -1
- package/packages/plugin-runtime/external/unix-jsonl-transport.ts +142 -18
- package/packages/protocols/computer/contract.ts +27 -1
- package/scripts/activate-source-baseline.ts +7 -9
- package/scripts/assemble-template.ts +11 -72
- package/scripts/canary-controller-semantic-wait.ts +12 -24
- package/scripts/check-mcp-compatibility.ts +94 -201
- package/scripts/check-package-identity.mjs +0 -5
- package/scripts/check-runtime-architecture.mjs +921 -239
- package/scripts/forge-local-recovery-helper.mjs +93 -15
- package/scripts/init-project.sh +0 -46
- package/scripts/install-ios-hid-toolchain.sh +60 -0
- package/scripts/install-standalone-recovery.ts +1 -1
- package/scripts/lib/project-init-lib.sh +6 -3
- package/scripts/migrate-windows-wsl-controller-home.ts +2 -0
- package/scripts/open-source-audit-allowlist.txt +1 -3
- package/scripts/run-bounded-command.mjs +5 -0
- package/scripts/run-governed-gate.ts +2 -1
- package/scripts/run-mobile-monitor-bridge.ts +0 -1
- package/scripts/smoke-control-plane-failure-domain.ts +94 -0
- package/scripts/smoke-ios-physical-device.ts +38 -10
- package/scripts/smoke-mcp-http-runtime.ts +12 -8
- package/scripts/smoke-mcp-tool-surface.ts +27 -41
- package/scripts/smoke-runtime-recovery.ts +12 -43
- package/scripts/smoke-schedule-engine.ts +23 -15
- package/scripts/smoke-unattended-transport-recovery.ts +223 -0
- package/scripts/smoke-user-request-continuation-restart.ts +232 -0
- package/scripts/smoke-workflow-supervisor-chrome-adapter.ts +95 -0
- package/scripts/smoke-workflow-supervisor-process-restart.ts +276 -0
- package/scripts/smoke-workflow-supervisor-restart-recovery.ts +150 -0
- package/scripts/smoke-workflow-supervisor.ts +103 -0
- package/scripts/sync-generated-authority.mjs +0 -1
- package/scripts/verify-forge-runtime.sh +2 -1
- package/src/cli/agent-jobs/executor-health.ts +12 -35
- package/src/cli/agent-jobs/integration.ts +20 -51
- package/src/cli/agent-jobs/job-manager.ts +7 -3
- package/src/cli/chatgpt-browser/file-policy.ts +2 -2
- package/src/cli/commands/brain-assistant.ts +27 -13
- package/src/cli/commands/brain.ts +13 -15
- package/src/cli/commands/chatgpt.ts +1 -163
- package/src/cli/commands/doctor.ts +1 -143
- package/src/cli/commands/global-runtime.ts +3 -196
- package/src/cli/commands/init-hook.ts +6 -23
- package/src/cli/commands/init.ts +3 -252
- package/src/cli/commands/mcp.ts +0 -5
- package/src/cli/commands/prompt-guard-decision.ts +0 -2
- package/src/cli/commands/recovery.ts +137 -135
- package/src/cli/commands/repository.ts +17 -1
- package/src/cli/commands/runtime.ts +3 -3
- package/src/cli/commands/setup-execution.ts +41 -0
- package/src/cli/commands/setup-profile.ts +8 -0
- package/src/cli/controller/check-runner.ts +13 -2
- package/src/cli/controller/completion-backlog.ts +3 -3
- package/src/cli/controller/completion-orchestrator.ts +5 -44
- package/src/cli/controller/completion-target.ts +3 -72
- package/src/cli/controller/composite-operations.ts +1 -1
- package/src/cli/controller/context/instruction-context.ts +1 -1
- package/src/cli/controller/context/known-paths.ts +2 -2
- package/src/cli/controller/context/query-planning.ts +11 -4
- package/src/cli/controller/context/rule-resolution.ts +2 -2
- package/src/cli/controller/context/source-materializer.ts +83 -102
- package/src/cli/controller/context/structural-provider.ts +84 -0
- package/src/cli/controller/context/structural.ts +6 -6
- package/src/cli/controller/context/types.ts +8 -9
- package/src/cli/controller/context-pack.ts +107 -84
- package/src/cli/controller/execution-completion.ts +4 -7
- package/src/cli/controller/execution-policy.ts +36 -153
- package/src/cli/controller/governance.ts +2 -3
- package/src/cli/controller/issue-store.ts +4 -99
- package/src/cli/controller/launch-agents.ts +59 -18
- package/src/cli/controller/operational-plan.ts +25 -52
- package/src/cli/controller/runtime-config.ts +5 -1
- package/src/cli/controller/stuck-state-migration.ts +2 -3
- package/src/cli/controller/systemd-user.ts +42 -10
- package/src/cli/editing/edit-session.ts +18 -12
- package/src/cli/github/github.ts +4 -4
- package/src/cli/github/semantic-projection.ts +174 -0
- package/src/cli/hook/prompt-intents.ts +0 -9
- package/src/cli/index.ts +1 -43
- package/src/cli/local-bridge/connector-freshness.ts +1 -12
- package/src/cli/local-bridge/console-automations.ts +19 -14
- package/src/cli/local-bridge/console-view-models.ts +4 -13
- package/src/cli/local-bridge/facade-api.ts +64 -193
- package/src/cli/local-bridge/server.ts +24 -147
- package/src/cli/local-bridge/types.ts +0 -1
- package/src/cli/mcp/oauth-client-retirement.ts +74 -0
- package/src/cli/repositories/command-classifier.ts +0 -9
- package/src/cli/repositories/command-executor.ts +29 -23
- package/src/cli/repositories/command-scope.ts +37 -18
- package/src/cli/repositories/controller-home.ts +48 -0
- package/src/cli/repositories/ephemeral-workspace.ts +20 -30
- package/src/cli/repositories/git-command-executor.ts +2 -2
- package/src/cli/repositories/locks.ts +20 -0
- package/src/cli/repositories/registry.ts +79 -12
- package/src/cli/repositories/safe-patch.ts +2 -12
- package/src/cli/repositories/structured-git.ts +101 -5
- package/src/cli/repository/inspector.ts +185 -343
- package/src/cli/repository/session-cache.ts +92 -6
- package/src/effects/process-runner.ts +17 -1
- package/src/runtime/context/assistant-context.ts +20 -7
- package/src/runtime/context/assistant-work-context.ts +89 -27
- package/src/runtime/context/automatic-learning.ts +565 -0
- package/src/runtime/context/cognitive-attention.ts +173 -0
- package/src/runtime/context/cognitive-skill-canary.ts +158 -0
- package/src/runtime/context/context-closure.ts +46 -9
- package/src/runtime/context/context-pack-process.ts +103 -0
- package/src/runtime/context/context-plane.ts +1 -9
- package/src/runtime/context/direct-controller-learning.ts +298 -0
- package/src/runtime/context/generic-lsp-provider.ts +1 -1
- package/src/runtime/context/semantic-navigation-contract.ts +16 -0
- package/src/runtime/context/semantic-navigation.ts +7 -35
- package/src/runtime/context/typescript-navigation-process.ts +145 -0
- package/src/runtime/context/typescript-navigation.ts +89 -3
- package/src/runtime/control-plane/cleanup-artifact-retention.ts +215 -12
- package/src/runtime/control-plane/concurrency/work-execution-concurrency.ts +9 -47
- package/src/runtime/control-plane/execution/controller-authority-recovery.ts +34 -4
- package/src/runtime/control-plane/execution/edit-validation-coordinator.ts +29 -20
- package/src/runtime/control-plane/execution/execution-identity.ts +23 -3
- package/src/runtime/control-plane/execution/repository-work-attribution.ts +7 -30
- package/src/runtime/control-plane/execution/retained-work-resume.ts +206 -199
- package/src/runtime/control-plane/execution/session-store.ts +31 -1
- package/src/runtime/control-plane/execution/validation.ts +6 -8
- package/src/runtime/control-plane/execution/work-authority-reconciler.ts +13 -42
- package/src/runtime/control-plane/execution/work-check-evidence.ts +137 -0
- package/src/runtime/control-plane/execution/work-completion-authority.ts +30 -85
- package/src/runtime/control-plane/execution/work-delivery-service.ts +616 -0
- package/src/runtime/control-plane/execution/work-evidence-policy.ts +12 -50
- package/src/runtime/control-plane/execution/work-execution-support.ts +50 -149
- package/src/runtime/control-plane/execution/work-handle-authority.ts +197 -110
- package/src/runtime/control-plane/execution/work-handle-store.ts +72 -44
- package/src/runtime/control-plane/execution/work-head-settlement.ts +53 -20
- package/src/runtime/control-plane/execution/work-lifecycle-audit.ts +52 -29
- package/src/runtime/control-plane/execution/work-operation-service.ts +60 -34
- package/src/runtime/control-plane/execution/work-preparation-service.ts +231 -267
- package/src/runtime/control-plane/execution/work-process-evidence.ts +2 -2
- package/src/runtime/control-plane/execution/work-remote-delivery.ts +2 -3
- package/src/runtime/control-plane/execution/work-revision-diff.ts +39 -0
- package/src/runtime/control-plane/execution/work-terminal-cleanup.ts +201 -199
- package/src/runtime/control-plane/execution/work-validation-reconciler.ts +33 -85
- package/src/runtime/control-plane/execution/work-verification-service.ts +406 -50
- package/src/runtime/control-plane/execution/work-verification-snapshot.ts +6 -2
- package/src/runtime/control-plane/facade/capability-registry.ts +364 -37
- package/src/runtime/control-plane/facade/check-normalization.ts +3 -9
- package/src/runtime/control-plane/facade/codex-delegation.ts +10 -11
- package/src/runtime/control-plane/facade/controller-connection.ts +135 -0
- package/src/runtime/control-plane/facade/goal-workloop-access.ts +1 -20
- package/src/runtime/control-plane/facade/goal-workloop.ts +281 -1753
- package/src/runtime/control-plane/facade/handoff-inbox-application.ts +12 -25
- package/src/runtime/control-plane/facade/handoff-inbox-store.ts +256 -52
- package/src/runtime/control-plane/facade/index.ts +0 -1
- package/src/runtime/control-plane/facade/operation-digest.ts +12 -15
- package/src/runtime/control-plane/facade/plan-contract-store.ts +451 -991
- package/src/runtime/control-plane/facade/policy-gate.ts +0 -23
- package/src/runtime/control-plane/facade/repository-work-admission.ts +12 -22
- package/src/runtime/control-plane/facade/requirement-authority.ts +102 -199
- package/src/runtime/control-plane/facade/requirement-board.ts +3 -3
- package/src/runtime/control-plane/facade/rh-work-operation-contract.ts +51 -14
- package/src/runtime/control-plane/facade/self-healing-loop.ts +18 -53
- package/src/runtime/control-plane/facade/suggested-actions.ts +15 -18
- package/src/runtime/control-plane/facade/types.ts +49 -108
- package/src/runtime/control-plane/facade/work-continuation.ts +9 -9
- package/src/runtime/control-plane/generated-cache-retention.ts +206 -59
- package/src/runtime/control-plane/global-scheduler/autonomous-continuation.ts +248 -0
- package/src/runtime/control-plane/global-scheduler/durable-admission.ts +1 -1
- package/src/runtime/control-plane/global-scheduler/maintenance.ts +256 -117
- package/src/runtime/control-plane/global-scheduler/reconciliation.ts +3 -12
- package/src/runtime/control-plane/global-scheduler/scheduler.ts +66 -40
- package/src/runtime/control-plane/global-scheduler/wake-signal.ts +42 -2
- package/src/runtime/control-plane/governance/access-policy.ts +19 -2
- package/src/runtime/control-plane/governance/authorization.ts +20 -3
- package/src/runtime/control-plane/governance/external-effects.ts +1 -1
- package/src/runtime/control-plane/launcher/chatgpt-round-continuation.ts +63 -300
- package/src/runtime/control-plane/launcher/chatgpt-work-continuation.ts +29 -300
- package/src/runtime/control-plane/launcher/local-conversation-controller.ts +238 -0
- package/src/runtime/control-plane/launcher/provider-mcp-bootstrap.ts +5 -2
- package/src/runtime/control-plane/launcher/thin-launcher.ts +96 -240
- package/src/runtime/control-plane/persistence/cognition-store.ts +820 -0
- package/src/runtime/control-plane/persistence/experience-store.ts +162 -29
- package/src/runtime/control-plane/persistence/requirement-store.ts +216 -74
- package/src/runtime/control-plane/persistence/sqlite-store.ts +113 -6
- package/src/runtime/control-plane/release-retention.ts +135 -47
- package/src/runtime/control-plane/repository-namespace-retention.ts +2 -2
- package/src/runtime/control-plane/runtime-cleanup.ts +295 -107
- package/src/runtime/control-plane/workspace/project-onboarding.ts +80 -0
- package/src/runtime/control-plane/workspace/semantic-sync-service.ts +19 -5
- package/src/runtime/control-plane/workspace/workspace-store.ts +169 -0
- package/src/runtime/diagnostics/incident-repair.ts +313 -146
- package/src/runtime/diagnostics/mcp-timing.ts +114 -0
- package/src/runtime/evidence/artifact-store.ts +158 -40
- package/src/runtime/evidence/evidence-store.ts +112 -8
- package/src/runtime/evidence/output-handle-index.ts +225 -0
- package/src/runtime/evidence/result-store.ts +158 -44
- package/src/runtime/evidence/sensitive-output.ts +22 -2
- package/src/runtime/execution/jobs/child-reference.ts +11 -0
- package/src/runtime/execution/jobs/receipt-recovery.ts +1 -11
- package/src/runtime/execution/jobs/store.ts +3 -4
- package/src/runtime/execution/managed-workspace.ts +57 -0
- package/src/runtime/execution/process-runtime/check-facade.ts +1 -1
- package/src/runtime/execution/process-runtime/check-result-retention.ts +2 -2
- package/src/runtime/execution/process-runtime/check-result.ts +105 -1
- package/src/runtime/execution/process-runtime/check-runner-sidecar.ts +18 -8
- package/src/runtime/execution/process-runtime/command-facade.ts +82 -30
- package/src/runtime/execution/process-runtime/gc.ts +15 -2
- package/src/runtime/execution/process-runtime/handle-index.ts +176 -0
- package/src/runtime/execution/process-runtime/host-command-lane.ts +139 -0
- package/src/runtime/execution/process-runtime/index.ts +3 -0
- package/src/runtime/execution/process-runtime/lightweight-managed.ts +251 -72
- package/src/runtime/execution/process-runtime/persisted-check.ts +3 -3
- package/src/runtime/execution/process-runtime/process-runner-entry.ts +47 -5
- package/src/runtime/execution/process-runtime/process-scope.ts +160 -0
- package/src/runtime/execution/process-runtime/resource-claims.ts +65 -61
- package/src/runtime/execution/process-runtime/runtime.ts +55 -18
- package/src/runtime/execution/process-runtime/store.ts +30 -2
- package/src/runtime/execution/process-runtime/types.ts +6 -1
- package/src/runtime/execution/thin-harness/execution-router.ts +16 -16
- package/src/runtime/execution/thin-harness/fast-executor.ts +2 -2
- package/src/runtime/execution/thin-harness/search-worker.ts +2 -2
- package/src/runtime/execution/workers/executor.ts +3 -8
- package/src/runtime/maintenance/cleanup.ts +41 -5
- package/src/runtime/platform/service-inventory.ts +130 -0
- package/src/runtime/platform/service-manager.ts +8 -0
- package/src/runtime/plugins/action-application.ts +97 -29
- package/src/runtime/plugins/app-store-connect-adapter.ts +290 -18
- package/src/runtime/plugins/browser-adapter.ts +1124 -333
- package/src/runtime/plugins/browser-automation-service.ts +23 -3
- package/src/runtime/plugins/browser-macos-bridge.ts +431 -137
- package/src/runtime/plugins/browser-manifest-surface.ts +47 -12
- package/src/runtime/plugins/browser-native-session-service.ts +63 -13
- package/src/runtime/plugins/browser-registration.ts +18 -0
- package/src/runtime/plugins/browser-runtime.ts +40 -36
- package/src/runtime/plugins/browser-session-authority.ts +2 -2
- package/src/runtime/plugins/browser-session-store.ts +46 -76
- package/src/runtime/plugins/capability-authorization-grants.ts +258 -62
- package/src/runtime/plugins/computer-chatgpt-browser-adapter-installer.ts +228 -0
- package/src/runtime/plugins/computer-registration.ts +298 -20
- package/src/runtime/plugins/desktop-operator-external-policy.ts +36 -4
- package/src/runtime/plugins/desktop-operator-registration.ts +12 -4
- package/src/runtime/plugins/external-adapter.ts +42 -6
- package/src/runtime/plugins/external-registration.ts +21 -1
- package/src/runtime/plugins/github-adapter.ts +30 -3
- package/src/runtime/plugins/gmail-adapter.ts +189 -3
- package/src/runtime/plugins/google-calendar-adapter.ts +2 -2
- package/src/runtime/plugins/google-shared.ts +24 -12
- package/src/runtime/plugins/google-tasks-adapter.ts +2 -2
- package/src/runtime/plugins/ios/remote-xpc-hid.ts +70 -30
- package/src/runtime/plugins/ios-adapter.ts +46 -41
- package/src/runtime/plugins/ios-agent-device.ts +54 -4
- package/src/runtime/plugins/ios-device-ownership.ts +103 -0
- package/src/runtime/plugins/ios-physical-device.ts +497 -79
- package/src/runtime/plugins/lightweight-action.ts +208 -2
- package/src/runtime/plugins/local-system-adapter.ts +12 -100
- package/src/runtime/plugins/managed-process-adapter.ts +12 -5
- package/src/runtime/plugins/plugin-action-sidecar.ts +17 -13
- package/src/runtime/plugins/plugin-management-adapter.ts +1 -1
- package/src/runtime/plugins/store.ts +682 -435
- package/src/runtime/plugins/types.ts +24 -0
- package/src/runtime/plugins/xiaohongshu-publish.ts +16 -0
- package/src/runtime/projections/git-status-sampler.ts +2 -19
- package/src/runtime/projections/invalidation.ts +7 -3
- package/src/runtime/projections/materialized-view.ts +80 -36
- package/src/runtime/recovery/actions.ts +4 -4
- package/src/runtime/recovery/capability-action-application.ts +46 -45
- package/src/runtime/recovery/lifecycle-inventory.ts +30 -40
- package/src/runtime/recovery/maintenance-executor.ts +374 -123
- package/src/runtime/recovery/probe.ts +2 -2
- package/src/runtime/recovery/store.ts +29 -11
- package/src/runtime/release/release-coordinator.ts +312 -0
- package/src/runtime/release/release-session.ts +716 -0
- package/src/runtime/release/release-state-migration.ts +25 -0
- package/src/runtime/resources/leases/store.ts +56 -25
- package/src/runtime/root/computer-composition.ts +191 -6
- package/src/runtime/root/controller-progression-composition.ts +254 -0
- package/src/runtime/root/controller-round-composition.ts +20 -1
- package/src/runtime/root/deployment-topology.ts +106 -0
- package/src/runtime/root/entry.ts +4 -3
- package/src/runtime/root/known-good-recovery.ts +184 -0
- package/src/runtime/root/local-bridge.ts +0 -1
- package/src/runtime/root/mcp-transport.ts +111 -18
- package/src/runtime/root/ownership.ts +261 -9
- package/src/runtime/root/package-connector-service.ts +227 -29
- package/src/runtime/root/package-runtime-release.ts +117 -30
- package/src/runtime/root/package-runtime-service.ts +24 -24
- package/src/runtime/root/release-execution-canary.ts +57 -12
- package/src/runtime/root/release-loader.ts +90 -8
- package/src/runtime/root/release-manifest.ts +80 -40
- package/src/runtime/root/release-materialize.ts +372 -106
- package/src/runtime/root/release-store.ts +395 -36
- package/src/runtime/root/runtime-lane.ts +191 -0
- package/src/runtime/root/runtime.ts +160 -29
- package/src/runtime/root/scheduled-controller-composition.ts +29 -3
- package/src/runtime/root/service-runner.ts +2 -2
- package/src/runtime/root/service.ts +126 -44
- package/src/runtime/root/status.ts +48 -0
- package/src/runtime/root/types.ts +32 -9
- package/src/runtime/root/workflow-supervisor-composition.ts +681 -0
- package/src/runtime/root/workflow-supervisor-runtime.ts +564 -0
- package/src/runtime/root/write-fence.ts +50 -2
- package/src/runtime/safe-tooling/google-credential-store.ts +67 -22
- package/src/runtime/safe-tooling/google-oauth-broker.ts +25 -7
- package/src/runtime/safe-tooling/ios-development.ts +22 -8
- package/src/runtime/safe-tooling/job-summary.ts +1 -1
- package/src/runtime/safe-tooling/workspace-auth.ts +5 -2
- package/src/runtime/shared/atomic-text-file.ts +21 -0
- package/src/runtime/shared/bounded-child-supervisor.ts +9 -1
- package/src/runtime/shared/json-files.ts +8 -3
- package/src/runtime/shared/process-environment.ts +20 -9
- package/src/runtime/shared/response-budget.ts +1 -3
- package/src/runtime/standalone-recovery/controller-home-migration.ts +16 -24
- package/src/runtime/standalone-recovery/core.ts +3792 -417
- package/src/runtime/standalone-recovery/entry.ts +507 -45
- package/src/runtime/standalone-recovery/installer.ts +262 -148
- package/src/runtime/standalone-recovery/mcp-server.ts +29 -193
- package/src/runtime/standalone-recovery/operation-lock.ts +12 -2
- package/src/runtime/standalone-recovery/performance.ts +54 -16
- package/src/runtime/standalone-recovery/release.ts +53 -5
- package/src/runtime/standalone-recovery/service-labels.ts +5 -2
- package/src/runtime/standalone-recovery/watchdog-heartbeat.ts +5 -2
- package/src/runtime/workflow/schedules/browser-probe.ts +17 -6
- package/src/runtime/workflow/schedules/chatgpt-automation-migration.ts +11 -3
- package/src/runtime/workflow/schedules/engine.ts +166 -178
- package/src/runtime/workflow/schedules/pending-activation.ts +11 -4
- package/src/runtime/workflow/schedules/work-continuation.ts +95 -11
- package/src/runtime/workflows/runtime.ts +15 -19
- package/src/testing/test-governance.ts +5 -1
- package/supervisor/chatgpt-conversation.ts +23 -0
- package/supervisor/client.ts +218 -0
- package/supervisor/control-plane.ts +963 -0
- package/supervisor/entry.ts +15 -0
- package/supervisor/forge-validators.ts +147 -0
- package/supervisor/index.ts +5 -0
- package/supervisor/native-browser-adapter.ts +1151 -0
- package/supervisor/native-messaging/host.ts +58 -0
- package/supervisor/native-messaging/manifest.ts +26 -0
- package/supervisor/native-messaging/protocol.ts +27 -0
- package/supervisor/paths.ts +18 -0
- package/supervisor/protocol.ts +250 -0
- package/supervisor/server.ts +412 -0
- package/supervisor/store.ts +1870 -0
- package/supervisor/tsconfig.json +8 -0
- package/supervisor/types.ts +261 -0
- package/SKILL.md +0 -427
- package/adapters/chatgpt/controller-host.ts +0 -119
- package/adapters/mcp/controller-round-compatibility.ts +0 -184
- package/adapters/mcp/frozen-client-semantic-compatibility.ts +0 -292
- package/adapters/mcp/runtime-gateway/work-compat-adapter.ts +0 -502
- package/adapters/mcp/runtime-gateway/work-validation-reconciler.ts +0 -1
- package/adapters/mcp/toolset-selection.ts +0 -41
- package/agents/openai.yaml +0 -4
- package/assets/skill-hooks.json +0 -41
- package/assets/skill-version.json +0 -189
- package/assets/skills/claude-review/SKILL.md +0 -231
- package/assets/skills/codex-review/SKILL.md +0 -103
- package/assets/templates/helpers/check-skill-version.ts +0 -193
- package/packages/kernel/progression/api/index.ts +0 -2
- package/packages/kernel/progression/application/projector.ts +0 -211
- package/packages/kernel/progression/domain/types.ts +0 -116
- package/packages/kernel/progression/index.ts +0 -1
- package/packages/kernel/scheduler/application/continuation-service.ts +0 -212
- package/packages/kernel/scheduler/domain/continuation.ts +0 -38
- package/packages/kernel/scheduler/infrastructure/continuation-dispatch-store.ts +0 -38
- package/packages/kernel/work/domain/admission-policy.ts +0 -34
- package/scripts/benchmark-background-check-overlap.ts +0 -228
- package/scripts/benchmark-computer-hotpath.ts +0 -255
- package/scripts/benchmark-controller-hotpath.ts +0 -212
- package/scripts/benchmark-controller-round2.ts +0 -191
- package/scripts/benchmark-ios-agent-device.ts +0 -511
- package/scripts/benchmark-mcp-host.sh +0 -117
- package/scripts/benchmark-mcp-transport.ts +0 -169
- package/scripts/benchmark-operational-memory-activation.ts +0 -235
- package/scripts/benchmark-operational-shadow.ts +0 -28
- package/scripts/benchmark-quality-harness.ts +0 -146
- package/scripts/benchmark-route-session-concurrency.ts +0 -915
- package/scripts/benchmark-thin-harness-gateway-ab.ts +0 -632
- package/scripts/benchmark-thin-harness-mcp-e2e.ts +0 -498
- package/scripts/benchmark-thin-harness.ts +0 -251
- package/scripts/benchmark-typescript-navigation.ts +0 -186
- package/scripts/benchmark-work-efficiency.ts +0 -334
- package/scripts/build-controller-ui.ts +0 -28
- package/scripts/check-npm-release.sh +0 -32
- package/scripts/check-public-release-surface.sh +0 -19
- package/scripts/check-release-published.sh +0 -57
- package/scripts/check-release-readiness.sh +0 -37
- package/scripts/check-release-version.mjs +0 -74
- package/scripts/check-skill-version.ts +0 -5
- package/scripts/check-tarball-install-smoke.sh +0 -150
- package/scripts/ensure-codegraph.sh +0 -16
- package/scripts/package-source-archive.sh +0 -147
- package/scripts/public-release-files.txt +0 -39
- package/scripts/public-release.ts +0 -174
- package/scripts/publish-release-tarball.sh +0 -27
- package/scripts/route-nl-vs-ts-eval.ts +0 -679
- package/scripts/run-skill-hook.ts +0 -244
- package/scripts/stage-runtime-release.ts +0 -44
- package/scripts/sync-codex-installed-copies.sh +0 -182
- package/src/cli/commands/tools.ts +0 -167
- package/src/cli/controller/progress.ts +0 -656
- package/src/cli/controller/work-mode.ts +0 -181
- package/src/cli/local-bridge/console-assets.ts +0 -17
- package/src/cli/local-bridge/dashboard.ts +0 -17
- package/src/cli/local-bridge/frontend/src/App.tsx +0 -10
- package/src/cli/local-bridge/frontend/src/components/Button.tsx +0 -1
- package/src/cli/local-bridge/frontend/src/components/DetailPane.tsx +0 -3
- package/src/cli/local-bridge/frontend/src/components/SearchField.tsx +0 -1
- package/src/cli/local-bridge/frontend/src/components/SectionHeader.tsx +0 -1
- package/src/cli/local-bridge/frontend/src/components/Segmented.tsx +0 -1
- package/src/cli/local-bridge/frontend/src/components/StatusText.tsx +0 -3
- package/src/cli/local-bridge/frontend/src/design/icons.tsx +0 -11
- package/src/cli/local-bridge/frontend/src/design/tokens.css +0 -8
- package/src/cli/local-bridge/frontend/src/features/automations/AutomationsView.tsx +0 -153
- package/src/cli/local-bridge/frontend/src/features/capabilities/CapabilitiesView.tsx +0 -37
- package/src/cli/local-bridge/frontend/src/features/overview/OverviewView.tsx +0 -183
- package/src/cli/local-bridge/frontend/src/features/repositories/RepositoriesView.tsx +0 -2
- package/src/cli/local-bridge/frontend/src/features/system/SystemView.tsx +0 -2
- package/src/cli/local-bridge/frontend/src/features/work/WorkView.tsx +0 -4
- package/src/cli/local-bridge/frontend/src/lib/api.ts +0 -30
- package/src/cli/local-bridge/frontend/src/lib/format.ts +0 -4
- package/src/cli/local-bridge/frontend/src/lib/routes.ts +0 -7
- package/src/cli/local-bridge/frontend/src/main.tsx +0 -1
- package/src/cli/local-bridge/frontend/src/shell/AppShell.tsx +0 -1
- package/src/cli/local-bridge/frontend/src/shell/CommandBar.tsx +0 -2
- package/src/cli/local-bridge/frontend/src/shell/Sidebar.tsx +0 -4
- package/src/cli/local-bridge/frontend/src/styles.css +0 -28
- package/src/cli/local-bridge/frontend/src/types.ts +0 -15
- package/src/cli/local-bridge/frontend/src/vite-env.d.ts +0 -1
- package/src/cli/local-bridge/frontend/vite.config.ts +0 -27
- package/src/cli/local-bridge/ui-dist/app.css +0 -1
- package/src/cli/local-bridge/ui-dist/app.js +0 -11228
- package/src/cli/mcp/access-mode.ts +0 -2
- package/src/cli/mcp/access-tools.ts +0 -2
- package/src/cli/mcp/audit.ts +0 -2
- package/src/cli/mcp/auth.ts +0 -2
- package/src/cli/mcp/instructions.ts +0 -2
- package/src/cli/mcp/legacy-context.ts +0 -2
- package/src/cli/mcp/legacy-tool-service.ts +0 -2
- package/src/cli/mcp/multi-repository.ts +0 -2
- package/src/cli/mcp/oauth.ts +0 -2
- package/src/cli/mcp/openai-secure-tunnel.ts +0 -2
- package/src/cli/mcp/paths.ts +0 -2
- package/src/cli/mcp/policy.ts +0 -2
- package/src/cli/mcp/post-finalize-work-attribution.ts +0 -2
- package/src/cli/mcp/proxy-env.ts +0 -2
- package/src/cli/mcp/readiness-projection.ts +0 -2
- package/src/cli/mcp/redaction.ts +0 -2
- package/src/cli/mcp/repo.ts +0 -2
- package/src/cli/mcp/repository-tools.ts +0 -2
- package/src/cli/mcp/server.ts +0 -2
- package/src/cli/mcp/setup.ts +0 -2
- package/src/cli/mcp/tool-capability-cache.ts +0 -2
- package/src/cli/mcp/tool-contract.ts +0 -2
- package/src/cli/mcp/tools.ts +0 -2
- package/src/cli/mcp/toolset-names.ts +0 -2
- package/src/cli/mcp/toolset-selection.ts +0 -2
- package/src/cli/mcp/toolset.ts +0 -2
- package/src/cli/mcp/transports/http.ts +0 -2
- package/src/cli/mcp/transports/session-registry.ts +0 -2
- package/src/cli/mcp/transports/stdio.ts +0 -2
- package/src/cli/mcp/types.ts +0 -2
- package/src/cli/mcp/umbrella-tools.ts +0 -2
- package/src/cli/tools/codegraph.ts +0 -695
- package/src/core/adoption/helper-wrapper-plan.ts +0 -159
- package/src/runtime/context/codegraph-cache-boundary.ts +0 -255
- package/src/runtime/context/codegraph-read-provider.ts +0 -611
- package/src/runtime/context/codegraph-sidecar.cjs +0 -248
- package/src/runtime/control-plane/codegraph-cache-retention.ts +0 -164
- package/src/runtime/control-plane/execution/content-equivalent-commit-authority.ts +0 -169
- package/src/runtime/control-plane/execution/direct-canonical-work-reconciliation.ts +0 -85
- package/src/runtime/control-plane/execution/direct-edit-work-completion.ts +0 -655
- package/src/runtime/control-plane/execution/work-finalization-service.ts +0 -2850
- package/src/runtime/control-plane/execution/work-path-scope.ts +0 -37
- package/src/runtime/control-plane/execution/work-task-receipt.ts +0 -468
- package/src/runtime/control-plane/facade/controller-round-relay.ts +0 -3
- package/src/runtime/control-plane/facade/work-admission-policy.ts +0 -142
- package/src/runtime/control-plane/facade/work-implementation-review.ts +0 -2
- package/src/runtime/control-plane/facade/work-state-machine.ts +0 -2
- package/src/runtime/control-plane/facade/work-task-projection.ts +0 -66
- package/src/runtime/control-plane/routing/index.ts +0 -1
- package/src/runtime/control-plane/routing/route-policy.ts +0 -401
- package/src/runtime/control-plane/routing/workspace-admission.ts +0 -70
- package/src/runtime/gateway/mcp/execution-tools.ts +0 -2
- package/src/runtime/gateway/mcp/legacy-ios-tool-adapter.ts +0 -2
- package/src/runtime/gateway/mcp/persisted-check-process.ts +0 -2
- package/src/runtime/gateway/mcp/process-tools.ts +0 -2
- package/src/runtime/gateway/mcp/router.ts +0 -2
- package/src/runtime/gateway/mcp/runtime-tool-definitions.ts +0 -2
- package/src/runtime/gateway/mcp/runtime-tools.ts +0 -2
- package/src/runtime/gateway/mcp/work-validation-reconciler.ts +0 -2
- package/src/runtime/plugins/browser-provider-registry.ts +0 -2
|
@@ -1,42 +1,59 @@
|
|
|
1
1
|
import { createHash } from "crypto";
|
|
2
|
-
import { existsSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
4
2
|
import { defaultSemanticProviderRegistry, type SemanticNavigationKind, type SemanticNavigationRequest } from "../../../src/runtime/context/semantic-navigation";
|
|
3
|
+
import { isIncidentalSemanticDependencyProbe } from "../../../src/runtime/context/semantic-navigation-contract";
|
|
5
4
|
import { buildContextClosureReceipt } from "../../../src/runtime/context/context-closure";
|
|
6
|
-
import {
|
|
5
|
+
import { readWorkHandle } from "../../../src/runtime/control-plane/execution/work-handle-store";
|
|
7
6
|
import type { MultiRepositoryMcpToolContext } from "../multi-repository";
|
|
8
7
|
import { result } from "./result-adapter";
|
|
8
|
+
import { boundedRuntimeResult } from "./bounded-result-runtime";
|
|
9
9
|
import { selected } from "./shared-adapter";
|
|
10
10
|
import { resolveMcpPath } from "../paths";
|
|
11
11
|
import { freshGitIdentity } from "../../../src/cli/repository/inspector";
|
|
12
|
-
import {
|
|
12
|
+
import { repositorySummary, resolveRepositorySelection } from "../../../src/cli/repositories/registry";
|
|
13
13
|
import { getExecutionJob, listExecutionJobs } from "../../../src/runtime/execution/jobs/store";
|
|
14
14
|
import { isManagedProcessActive, listProcessRecords, listRecoverableProcessRecords, processRuntimeResourceDiagnostics } from "../../../src/runtime/execution/process-runtime";
|
|
15
|
-
import {
|
|
15
|
+
import { CONTROLLER_CONTEXT_IMPACT_DOMAINS, type ControllerContextImpactDomain } from "../../../src/cli/controller/context/types";
|
|
16
|
+
import { buildControllerContextPackInSidecar } from "../../../src/runtime/context/context-pack-process";
|
|
17
|
+
import { isCodeShapedTerm } from "../../../src/cli/controller/context/query-planning";
|
|
16
18
|
import { listControllerChecks } from "../../../src/cli/controller/check-runner";
|
|
17
|
-
import {
|
|
18
|
-
import { allowedFacadeOperations, buildFacadeResult, listCapabilityDescriptors, getCapabilityDescriptor, getPluginActionCapabilitySchema, searchCapabilityDescriptors, summarizeCapabilityGroups, listHandoffItems, normalizeCheckIds, summarizeHandoffItem, buildWorkContinuationSnapshot } from "../../../src/runtime/control-plane/facade";
|
|
19
|
-
import { getWorkContract, readActiveWorkCandidates, type InvalidActiveWorkCandidate } from "../../../packages/kernel/work/api/index";
|
|
19
|
+
import { getAssistantPluginManifest, getControllerPluginManifest, listAssistantPluginManifests, listControllerPluginManifests } from "../../../src/runtime/plugins/store";
|
|
20
|
+
import { allowedFacadeOperations, buildFacadeResult, listCapabilityDescriptors, getCapabilityDescriptor, getCoreCapabilityExecutionSchema, getPluginActionCapabilitySchema, searchCapabilityDescriptors, summarizeCapabilityGroups, listHandoffAttentionItems, listHandoffItems, normalizeCheckIds, summarizeHandoffItem, buildWorkContinuationSnapshot, getPlanContract, planSemanticView, FACADE_TOOLS } from "../../../src/runtime/control-plane/facade";
|
|
21
|
+
import { currentTaskLineageWorkIds, currentTaskSemanticProjectionForWork, getWorkContract, readActiveWorkCandidates, readWorkContractStore, workSemanticView, type InvalidActiveWorkCandidate, type WorkContract } from "../../../packages/kernel/work/api/index";
|
|
22
|
+
import { readRequirement, requirementSemanticView } from '../../../src/runtime/control-plane/persistence/requirement-store';
|
|
23
|
+
import { readForgeInstanceIdentity, type ScopeRef } from "../../../packages/kernel/identity/api/index";
|
|
24
|
+
import { memoryAddressKey } from "../../../packages/kernel/cognition/api/index";
|
|
20
25
|
import { currentControllerInstanceId } from "../../../src/runtime/control-plane/execution/session-store";
|
|
21
26
|
import { getControllerSession } from "../../../packages/kernel/controller/api/index";
|
|
27
|
+
import { resolveProjectForRepositoryPlacement } from "../../../src/runtime/control-plane/workspace/workspace-store";
|
|
28
|
+
import { cognitiveScopesForWork } from "../../../src/runtime/control-plane/persistence/experience-store";
|
|
29
|
+
import { activateCognitiveMemory, auditCognitiveMemory } from "../../../src/runtime/control-plane/persistence/cognition-store";
|
|
30
|
+
import { cognitiveUsageFeedbackForContext, resolveCognitiveAttention } from "../../../src/runtime/context/cognitive-attention";
|
|
22
31
|
import { invalidFacadeOperation, repositoryExecutionReadiness, summarizeInvalidActiveWorkCandidate, summarizeWorkListItem } from './status-inbox-adapter';
|
|
23
32
|
import type { CallToolResult } from '../../../packages/protocols/mcp/tool-contract';
|
|
24
33
|
|
|
25
|
-
const
|
|
34
|
+
const RH_CONTEXT_RECENT_ACTIVITY_WINDOW_MS = 24 * 60 * 60 * 1_000;
|
|
35
|
+
const RH_CONTEXT_AUTOMATIC_RECALL_LIMIT = 4;
|
|
26
36
|
|
|
27
|
-
function
|
|
37
|
+
function timestampIsRecent(value: string | undefined, cutoffMs: number): boolean {
|
|
28
38
|
if (!value) return false;
|
|
29
39
|
const timestamp = Date.parse(value);
|
|
30
40
|
return Number.isFinite(timestamp) && timestamp >= cutoffMs;
|
|
31
41
|
}
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
const RESUME_CONTEXT_HUMAN_REQUEST_REASONS = new Set([
|
|
44
|
+
'policy_approval_required',
|
|
45
|
+
'missing_authorization',
|
|
46
|
+
'invalid_objective',
|
|
47
|
+
'destructive_action_requires_confirmation',
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
function isRecentRhContextWork(
|
|
51
|
+
contract: Pick<WorkContract, 'semanticState' | 'dispatchState' | 'updatedAt'>,
|
|
35
52
|
cutoffMs: number,
|
|
36
53
|
): boolean {
|
|
37
|
-
if (contract.
|
|
38
|
-
if (contract.
|
|
39
|
-
return
|
|
54
|
+
if (contract.semanticState !== 'open') return false;
|
|
55
|
+
if (contract.dispatchState === 'running' || contract.dispatchState === 'launching' || contract.dispatchState === 'claimed') return true;
|
|
56
|
+
return timestampIsRecent(contract.updatedAt, cutoffMs);
|
|
40
57
|
}
|
|
41
58
|
|
|
42
59
|
function rhContextReadSessionId(ctx: MultiRepositoryMcpToolContext): string | undefined {
|
|
@@ -49,6 +66,173 @@ function rhContextReadSessionId(ctx: MultiRepositoryMcpToolContext): string | un
|
|
|
49
66
|
return transportSession ? `transport:${transportSession}` : undefined;
|
|
50
67
|
}
|
|
51
68
|
|
|
69
|
+
function rhContextKnowledgeAuditRequested(args: Record<string, unknown>): boolean {
|
|
70
|
+
return [
|
|
71
|
+
'knowledge_query', 'knowledge_memory_id', 'knowledge_scope_kind', 'knowledge_scope_id',
|
|
72
|
+
'knowledge_concept', 'knowledge_facet', 'knowledge_source_kind', 'knowledge_source_work_id',
|
|
73
|
+
].some(key => typeof args[key] === 'string' && String(args[key]).trim().length > 0)
|
|
74
|
+
|| typeof args.knowledge_limit === 'number';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function rhContextKnowledgeScopes(
|
|
78
|
+
ctx: MultiRepositoryMcpToolContext,
|
|
79
|
+
repository: ReturnType<typeof selected>,
|
|
80
|
+
workId: string | undefined,
|
|
81
|
+
): { scopes: ScopeRef[]; projectId?: string; gaps: string[] } {
|
|
82
|
+
const store = { controllerHome: ctx.controllerHome, repoId: repository.repoId };
|
|
83
|
+
const work = workId ? getWorkContract(store, workId) : undefined;
|
|
84
|
+
if (work) {
|
|
85
|
+
const scopes = cognitiveScopesForWork(work, ctx.controllerHome);
|
|
86
|
+
return { scopes, projectId: scopes.find(scope => scope.kind === 'project')?.id, gaps: [] };
|
|
87
|
+
}
|
|
88
|
+
const instance = readForgeInstanceIdentity(ctx.controllerHome);
|
|
89
|
+
if (!instance) return { scopes: [], gaps: ['forge_instance_identity_unavailable'] };
|
|
90
|
+
const project = resolveProjectForRepositoryPlacement({
|
|
91
|
+
controllerHome: ctx.controllerHome,
|
|
92
|
+
forgeInstanceId: instance.instanceId,
|
|
93
|
+
repositoryId: repository.repoId,
|
|
94
|
+
checkoutId: repository.activeCheckoutId,
|
|
95
|
+
});
|
|
96
|
+
if (!project) return { scopes: [], gaps: ['project_placement_unavailable'] };
|
|
97
|
+
return {
|
|
98
|
+
projectId: project.projectId,
|
|
99
|
+
scopes: [
|
|
100
|
+
{ schemaVersion: 1, kind: 'project', id: project.projectId },
|
|
101
|
+
{ schemaVersion: 1, kind: 'workspace', id: project.workspaceId },
|
|
102
|
+
],
|
|
103
|
+
gaps: [],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function rhContextKnowledgeAudit(
|
|
108
|
+
ctx: MultiRepositoryMcpToolContext,
|
|
109
|
+
repository: ReturnType<typeof selected>,
|
|
110
|
+
args: Record<string, unknown>,
|
|
111
|
+
): Record<string, unknown> {
|
|
112
|
+
const workId = typeof args.work_id === 'string' && args.work_id.trim() ? args.work_id.trim() : undefined;
|
|
113
|
+
const resolved = rhContextKnowledgeScopes(ctx, repository, workId);
|
|
114
|
+
const requestedKind = typeof args.knowledge_scope_kind === 'string' ? args.knowledge_scope_kind.trim() : '';
|
|
115
|
+
const requestedId = typeof args.knowledge_scope_id === 'string' ? args.knowledge_scope_id.trim() : '';
|
|
116
|
+
const scopes = resolved.scopes.filter(scope =>
|
|
117
|
+
(!requestedKind || scope.kind === requestedKind) && (!requestedId || scope.id === requestedId));
|
|
118
|
+
const scopeMismatch = resolved.scopes.length > 0 && scopes.length === 0 && Boolean(requestedKind || requestedId);
|
|
119
|
+
const rawQuery = typeof args.knowledge_query === 'string' ? args.knowledge_query.trim() : '';
|
|
120
|
+
const query = rawQuery === '*' ? '' : rawQuery;
|
|
121
|
+
const audit = auditCognitiveMemory(ctx.controllerHome, {
|
|
122
|
+
scopes,
|
|
123
|
+
...(query ? { query } : {}),
|
|
124
|
+
...(typeof args.knowledge_memory_id === 'string' && args.knowledge_memory_id.trim()
|
|
125
|
+
? { memoryId: args.knowledge_memory_id.trim() } : {}),
|
|
126
|
+
...(typeof args.knowledge_concept === 'string' && args.knowledge_concept.trim()
|
|
127
|
+
? { concept: args.knowledge_concept.trim() } : {}),
|
|
128
|
+
...(typeof args.knowledge_facet === 'string' && args.knowledge_facet.trim()
|
|
129
|
+
? { facet: args.knowledge_facet.trim() } : {}),
|
|
130
|
+
...(typeof args.knowledge_source_kind === 'string' && args.knowledge_source_kind.trim()
|
|
131
|
+
? { sourceKind: args.knowledge_source_kind.trim() as 'experience' | 'outcome' | 'knowledge' | 'controller' | 'system' | 'external' } : {}),
|
|
132
|
+
...(typeof args.knowledge_source_work_id === 'string' && args.knowledge_source_work_id.trim()
|
|
133
|
+
? { sourceWorkId: args.knowledge_source_work_id.trim() } : {}),
|
|
134
|
+
...(typeof args.knowledge_limit === 'number' ? { limit: args.knowledge_limit } : {}),
|
|
135
|
+
});
|
|
136
|
+
const usage = cognitiveUsageFeedbackForContext({
|
|
137
|
+
controllerHome: ctx.controllerHome,
|
|
138
|
+
repoId: repository.repoId,
|
|
139
|
+
scopes,
|
|
140
|
+
...(resolved.projectId ? { projectId: resolved.projectId } : {}),
|
|
141
|
+
});
|
|
142
|
+
const usageByAddress = new Map(usage.map(item => [memoryAddressKey(item.address), item]));
|
|
143
|
+
const activation = query
|
|
144
|
+
? activateCognitiveMemory(ctx.controllerHome, scopes, query, {
|
|
145
|
+
maxItems: Math.min(32, Math.max(1, typeof args.knowledge_limit === 'number' ? Math.trunc(args.knowledge_limit) : 24)),
|
|
146
|
+
usageFeedback: usage,
|
|
147
|
+
})
|
|
148
|
+
: undefined;
|
|
149
|
+
const activationByAddress = new Map((activation?.items ?? []).map(item => [
|
|
150
|
+
memoryAddressKey({ scope: item.memory.scope, id: item.memory.id }),
|
|
151
|
+
{ score: item.score, reasons: item.reasons, activationPath: item.activationPath },
|
|
152
|
+
]));
|
|
153
|
+
return {
|
|
154
|
+
readonly: true,
|
|
155
|
+
advisoryOnly: true,
|
|
156
|
+
authorityBoundary: 'Learned memory never overrides project contracts, authorization, verification, Requirement/Plan/Work, or semantic acceptance.',
|
|
157
|
+
scopes,
|
|
158
|
+
filters: {
|
|
159
|
+
...(rawQuery ? { query: rawQuery } : {}),
|
|
160
|
+
...(requestedKind ? { scopeKind: requestedKind } : {}),
|
|
161
|
+
...(requestedId ? { scopeId: requestedId } : {}),
|
|
162
|
+
...(typeof args.knowledge_memory_id === 'string' && args.knowledge_memory_id.trim() ? { memoryId: args.knowledge_memory_id.trim() } : {}),
|
|
163
|
+
...(typeof args.knowledge_concept === 'string' && args.knowledge_concept.trim() ? { concept: args.knowledge_concept.trim() } : {}),
|
|
164
|
+
...(typeof args.knowledge_facet === 'string' && args.knowledge_facet.trim() ? { facet: args.knowledge_facet.trim() } : {}),
|
|
165
|
+
...(typeof args.knowledge_source_kind === 'string' && args.knowledge_source_kind.trim() ? { sourceKind: args.knowledge_source_kind.trim() } : {}),
|
|
166
|
+
...(typeof args.knowledge_source_work_id === 'string' && args.knowledge_source_work_id.trim() ? { sourceWorkId: args.knowledge_source_work_id.trim() } : {}),
|
|
167
|
+
},
|
|
168
|
+
items: audit.items.map(entry => {
|
|
169
|
+
const address = memoryAddressKey({ scope: entry.memory.scope, id: entry.memory.id });
|
|
170
|
+
return {
|
|
171
|
+
memory: entry.memory,
|
|
172
|
+
relations: entry.relations,
|
|
173
|
+
recentUsage: usageByAddress.get(address),
|
|
174
|
+
activation: activationByAddress.get(address),
|
|
175
|
+
};
|
|
176
|
+
}),
|
|
177
|
+
inspected: audit.inspected,
|
|
178
|
+
truncated: audit.truncated,
|
|
179
|
+
gaps: [...resolved.gaps, ...(scopeMismatch ? ['requested_cognitive_scope_not_reachable'] : [])],
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function rhContextLearningRecall(
|
|
184
|
+
ctx: MultiRepositoryMcpToolContext,
|
|
185
|
+
repository: ReturnType<typeof selected>,
|
|
186
|
+
query: string,
|
|
187
|
+
workId?: string,
|
|
188
|
+
limit = RH_CONTEXT_AUTOMATIC_RECALL_LIMIT,
|
|
189
|
+
): Record<string, unknown> {
|
|
190
|
+
const resolved = rhContextKnowledgeScopes(ctx, repository, workId);
|
|
191
|
+
if (!query.trim() || resolved.scopes.length === 0) {
|
|
192
|
+
return { advisoryOnly: true, scopes: resolved.scopes, items: [], gaps: resolved.gaps };
|
|
193
|
+
}
|
|
194
|
+
const usage = cognitiveUsageFeedbackForContext({
|
|
195
|
+
controllerHome: ctx.controllerHome,
|
|
196
|
+
repoId: repository.repoId,
|
|
197
|
+
scopes: resolved.scopes,
|
|
198
|
+
...(resolved.projectId ? { projectId: resolved.projectId } : {}),
|
|
199
|
+
});
|
|
200
|
+
const activation = resolveCognitiveAttention({
|
|
201
|
+
controllerHome: ctx.controllerHome,
|
|
202
|
+
scopes: resolved.scopes,
|
|
203
|
+
query: query.slice(0, 4_000),
|
|
204
|
+
now: new Date().toISOString(),
|
|
205
|
+
maxItems: Math.min(8, Math.max(1, limit)),
|
|
206
|
+
maxBytes: 12 * 1024,
|
|
207
|
+
usageFeedback: usage,
|
|
208
|
+
});
|
|
209
|
+
return {
|
|
210
|
+
advisoryOnly: true,
|
|
211
|
+
authorityBoundary: 'Learned context may guide model decisions but never grants execution, lifecycle, or acceptance authority.',
|
|
212
|
+
scopePolicy: 'unified_relevance_with_narrow_scope_prior',
|
|
213
|
+
scopes: resolved.scopes,
|
|
214
|
+
items: activation.items.map(entry => ({
|
|
215
|
+
memoryId: memoryAddressKey({ scope: entry.memory.scope, id: entry.memory.id }),
|
|
216
|
+
text: entry.memory.canonicalText,
|
|
217
|
+
score: entry.score,
|
|
218
|
+
reasons: entry.reasons,
|
|
219
|
+
activationPath: entry.activationPath,
|
|
220
|
+
facets: entry.memory.facets,
|
|
221
|
+
concepts: entry.memory.concepts,
|
|
222
|
+
provenance: entry.memory.provenance,
|
|
223
|
+
})),
|
|
224
|
+
gaps: [...resolved.gaps, ...activation.gaps],
|
|
225
|
+
progressiveAttention: {
|
|
226
|
+
workingSetBounded: true,
|
|
227
|
+
moreCandidatesAvailable: activation.truncated,
|
|
228
|
+
inspectedCandidates: activation.inspectedCandidates,
|
|
229
|
+
modelDecision: activation.truncated
|
|
230
|
+
? 'This is an initial working set, not semantic completeness. If the current decision still lacks relevant prior context, issue a narrower rh_context query or an explicit knowledge_query/knowledge_limit expansion; otherwise reuse this working set through routine micro-steps.'
|
|
231
|
+
: 'Decide whether this working set is semantically sufficient. Reuse it through routine micro-steps; only recall again when the task meaning/strategy changes or missing prior context could change the decision.',
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
52
236
|
const RH_CONTEXT_SEMANTIC_QUERY_LIMIT = 8;
|
|
53
237
|
|
|
54
238
|
const RH_CONTEXT_SEMANTIC_LOCATION_LIMIT = 200;
|
|
@@ -96,6 +280,7 @@ interface RhContextSemanticNavigationProjection {
|
|
|
96
280
|
providers: unknown[];
|
|
97
281
|
policyDeniedLocations: number;
|
|
98
282
|
policyDeniedReads: number;
|
|
283
|
+
materialPolicyDeniedReads: number;
|
|
99
284
|
policyDeniedReadSamples: string[];
|
|
100
285
|
requestTruncated: boolean;
|
|
101
286
|
freshness: 'not_requested' | 'changed_during_query' | 'current_at_query';
|
|
@@ -116,6 +301,7 @@ async function rhContextSemanticNavigation(
|
|
|
116
301
|
let anyLocationTruncated = false;
|
|
117
302
|
let policyDeniedLocations = 0;
|
|
118
303
|
let policyDeniedReads = 0;
|
|
304
|
+
let materialPolicyDeniedReads = 0;
|
|
119
305
|
const policyDeniedReadSamples = new Set<string>();
|
|
120
306
|
const semanticAccessScope = createHash('sha256')
|
|
121
307
|
.update(JSON.stringify({ profile: policy.profile, readGlobs: policy.readGlobs, denyGlobs: policy.denyGlobs }))
|
|
@@ -163,6 +349,7 @@ async function rhContextSemanticNavigation(
|
|
|
163
349
|
const decision = resolveMcpPath(repoRoot, relativePath, policy, 'read');
|
|
164
350
|
if (decision.ok) return true;
|
|
165
351
|
policyDeniedReads += 1;
|
|
352
|
+
if (!isIncidentalSemanticDependencyProbe(relativePath)) materialPolicyDeniedReads += 1;
|
|
166
353
|
if (policyDeniedReadSamples.size < 20) policyDeniedReadSamples.add(relativePath);
|
|
167
354
|
return false;
|
|
168
355
|
};
|
|
@@ -171,6 +358,12 @@ async function rhContextSemanticNavigation(
|
|
|
171
358
|
cacheScope: `mcp:${semanticAccessScope}`,
|
|
172
359
|
sourceIdentity: sourceFingerprintBefore,
|
|
173
360
|
profile: policy.profile,
|
|
361
|
+
readPolicy: {
|
|
362
|
+
profile: policy.profile,
|
|
363
|
+
readGlobs: [...policy.readGlobs],
|
|
364
|
+
denyGlobs: [...policy.denyGlobs],
|
|
365
|
+
maxFileBytes: policy.maxFileBytes,
|
|
366
|
+
},
|
|
174
367
|
allowRepositoryPath,
|
|
175
368
|
});
|
|
176
369
|
|
|
@@ -180,12 +373,27 @@ async function rhContextSemanticNavigation(
|
|
|
180
373
|
continue;
|
|
181
374
|
}
|
|
182
375
|
const semantic = outcome.result;
|
|
376
|
+
const sidecarDeniedReads = Math.max(0, Number(semantic.policyDeniedReads ?? 0));
|
|
377
|
+
policyDeniedReads += sidecarDeniedReads;
|
|
378
|
+
materialPolicyDeniedReads += Math.max(0, Number(semantic.materialPolicyDeniedReads ?? sidecarDeniedReads));
|
|
379
|
+
const sidecarDeniedSamples = semantic.details?.policyDeniedReadSamples;
|
|
380
|
+
if (Array.isArray(sidecarDeniedSamples)) {
|
|
381
|
+
for (const sample of sidecarDeniedSamples) {
|
|
382
|
+
if (policyDeniedReadSamples.size >= 20) break;
|
|
383
|
+
if (typeof sample === 'string' && sample.trim()) policyDeniedReadSamples.add(sample);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
183
386
|
const allowedLocations = semantic.locations.filter((location) => {
|
|
184
387
|
const decision = resolveMcpPath(repoRoot, location.path, policy, 'read');
|
|
185
388
|
if (decision.ok) return true;
|
|
186
389
|
policyDeniedLocations += 1;
|
|
187
390
|
return false;
|
|
188
391
|
});
|
|
392
|
+
// With no resolved requested relationship, even dependency-only denied reads
|
|
393
|
+
// may conceal material evidence. Preserve admission blocking for this case.
|
|
394
|
+
if (allowedLocations.length === 0 && sidecarDeniedReads > 0 && Number(semantic.materialPolicyDeniedReads ?? sidecarDeniedReads) === 0) {
|
|
395
|
+
materialPolicyDeniedReads += sidecarDeniedReads;
|
|
396
|
+
}
|
|
189
397
|
const truncated = allowedLocations.length > RH_CONTEXT_SEMANTIC_LOCATION_LIMIT;
|
|
190
398
|
anyLocationTruncated ||= truncated;
|
|
191
399
|
results.push({
|
|
@@ -199,6 +407,7 @@ async function rhContextSemanticNavigation(
|
|
|
199
407
|
returnedLocations: Math.min(allowedLocations.length, RH_CONTEXT_SEMANTIC_LOCATION_LIMIT),
|
|
200
408
|
truncated,
|
|
201
409
|
policyDeniedReads: semantic.policyDeniedReads ?? 0,
|
|
410
|
+
materialPolicyDeniedReads: semantic.materialPolicyDeniedReads ?? semantic.policyDeniedReads ?? 0,
|
|
202
411
|
...(semantic.details ?? {}),
|
|
203
412
|
});
|
|
204
413
|
}
|
|
@@ -227,7 +436,7 @@ async function rhContextSemanticNavigation(
|
|
|
227
436
|
}
|
|
228
437
|
|
|
229
438
|
const requestTruncated = raw.length > RH_CONTEXT_SEMANTIC_QUERY_LIMIT;
|
|
230
|
-
const incomplete = requestTruncated || anyLocationTruncated || policyDeniedLocations > 0 ||
|
|
439
|
+
const incomplete = requestTruncated || anyLocationTruncated || policyDeniedLocations > 0 || materialPolicyDeniedReads > 0 || errors.length > 0 || sourceChangedDuringQuery;
|
|
231
440
|
const languages = new Set(results.map((entry) => String(entry.language ?? '')).filter(Boolean));
|
|
232
441
|
const singleLanguage = languages.size === 1 ? [...languages][0] : undefined;
|
|
233
442
|
const scope = singleLanguage === 'typescript'
|
|
@@ -247,6 +456,7 @@ async function rhContextSemanticNavigation(
|
|
|
247
456
|
providers: defaultSemanticProviderRegistry.list(),
|
|
248
457
|
policyDeniedLocations,
|
|
249
458
|
policyDeniedReads,
|
|
459
|
+
materialPolicyDeniedReads,
|
|
250
460
|
policyDeniedReadSamples: Array.from(policyDeniedReadSamples),
|
|
251
461
|
requestTruncated,
|
|
252
462
|
freshness: raw.length === 0 ? 'not_requested' : sourceChangedDuringQuery ? 'changed_during_query' : 'current_at_query',
|
|
@@ -268,49 +478,96 @@ async function rhContextSemanticNavigation(
|
|
|
268
478
|
};
|
|
269
479
|
}
|
|
270
480
|
|
|
271
|
-
function codegraphIndexExists(controllerHome: string, root: string): boolean {
|
|
272
|
-
return existsSync(join(codegraphRepositoryCacheRoot(controllerHome, root), 'codegraph.db'))
|
|
273
|
-
|| existsSync(join(root, '.codegraph', 'codegraph.db'));
|
|
274
|
-
}
|
|
275
|
-
|
|
276
481
|
/**
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
482
|
+
* Work-specific source evidence uses the exact registered physical placement.
|
|
483
|
+
* Work semantic identity stays in Kernel; Repository Registry owns checkout
|
|
484
|
+
* resolution. This projection neither creates source state nor chooses a
|
|
485
|
+
* different checkout when the exact Work target has disappeared.
|
|
281
486
|
*/
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
487
|
+
function selectContextSourceRepository(
|
|
488
|
+
ctx: MultiRepositoryMcpToolContext,
|
|
489
|
+
args: Record<string, unknown>,
|
|
490
|
+
operation: string,
|
|
491
|
+
): ReturnType<typeof selected> {
|
|
492
|
+
const workId = operation === 'search' && typeof args.query === 'string' && args.query.trim()
|
|
493
|
+
&& typeof args.work_id === 'string' ? args.work_id.trim() : '';
|
|
494
|
+
if (!workId) return selected(ctx, args);
|
|
495
|
+
const repository = selected(ctx, { ...args, checkout_id: undefined });
|
|
496
|
+
const work = getWorkContract({ controllerHome: ctx.controllerHome, repoId: repository.repoId }, workId);
|
|
497
|
+
if (!work) throw new Error(`CONTEXT_WORK_NOT_FOUND: ${workId}`);
|
|
498
|
+
if (work.repoId && work.repoId !== repository.repoId) {
|
|
499
|
+
throw new Error(`CONTEXT_WORK_REPOSITORY_MISMATCH: ${workId}`);
|
|
500
|
+
}
|
|
501
|
+
const handle = readWorkHandle(ctx.controllerHome, repository.repoId, workId);
|
|
502
|
+
const workCheckoutId = handle?.checkoutId?.trim()
|
|
503
|
+
|| work.executionPlacement?.checkoutId?.trim()
|
|
504
|
+
|| work.checkoutId?.trim();
|
|
505
|
+
// Pure semantic Work has no physical source. Keep explicitly elected
|
|
506
|
+
// repository context for this case instead of inventing source placement.
|
|
507
|
+
if (!workCheckoutId) return selected(ctx, args);
|
|
508
|
+
const requestedCheckoutId = typeof args.checkout_id === 'string' ? args.checkout_id.trim() : '';
|
|
509
|
+
if (requestedCheckoutId && requestedCheckoutId !== workCheckoutId) {
|
|
510
|
+
throw new Error(`CONTEXT_WORK_CHECKOUT_MISMATCH: ${workId}`);
|
|
511
|
+
}
|
|
512
|
+
if (handle?.state === 'cleaned' || handle?.state === 'failed') {
|
|
513
|
+
throw new Error(`CONTEXT_WORK_CHECKOUT_RETIRED: ${workId}`);
|
|
514
|
+
}
|
|
515
|
+
let selectedCheckout: ReturnType<typeof selected>;
|
|
516
|
+
try {
|
|
517
|
+
selectedCheckout = selected(ctx, { ...args, repo_id: repository.repoId, checkout_id: workCheckoutId });
|
|
518
|
+
} catch {
|
|
519
|
+
throw new Error(`CONTEXT_WORK_CHECKOUT_UNAVAILABLE: ${workId}`);
|
|
520
|
+
}
|
|
521
|
+
if (selectedCheckout.activeCheckoutId !== workCheckoutId) {
|
|
522
|
+
throw new Error(`CONTEXT_WORK_CHECKOUT_MISMATCH: ${workId}`);
|
|
523
|
+
}
|
|
524
|
+
if (handle?.expectedHead && freshGitIdentity(selectedCheckout.canonicalRoot).head !== handle.expectedHead) {
|
|
525
|
+
throw new Error(`CONTEXT_WORK_SOURCE_REVISION_MISMATCH: ${workId}`);
|
|
526
|
+
}
|
|
527
|
+
return selectedCheckout;
|
|
294
528
|
}
|
|
295
529
|
|
|
296
530
|
export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, name: string, args: Record<string, unknown>): Promise<CallToolResult | undefined> {
|
|
297
531
|
if (name !== 'rh_context') return undefined;
|
|
298
|
-
const repository = selected(ctx, args);
|
|
299
532
|
const operation = String(args.operation ?? 'get');
|
|
533
|
+
const repository = selectContextSourceRepository(ctx, args, operation);
|
|
300
534
|
if (!allowedFacadeOperations('rh_context').includes(operation)) {
|
|
301
535
|
return invalidFacadeOperation('rh_context', operation);
|
|
302
536
|
}
|
|
303
537
|
if (operation === 'search') {
|
|
304
538
|
const query = typeof args.query === 'string' ? args.query.trim() : '';
|
|
305
|
-
|
|
539
|
+
const knowledgeAuditRequested = rhContextKnowledgeAuditRequested(args);
|
|
540
|
+
if (!query && !knowledgeAuditRequested) {
|
|
306
541
|
const facade = buildFacadeResult({
|
|
307
542
|
status: 'failed',
|
|
308
|
-
summary: 'rh_context.search requires a non-empty query.',
|
|
543
|
+
summary: 'rh_context.search requires a non-empty code query or explicit knowledge audit fields.',
|
|
309
544
|
data: { operation, repoId: repository.repoId },
|
|
310
545
|
suggestedNextActions: [],
|
|
311
546
|
});
|
|
312
547
|
return result(facade as unknown as Record<string, unknown>, true);
|
|
313
548
|
}
|
|
549
|
+
const cognitionAudit = knowledgeAuditRequested ? rhContextKnowledgeAudit(ctx, repository, args) : undefined;
|
|
550
|
+
const includeLearningRecall = args.include_learning_recall !== false;
|
|
551
|
+
const learningRecall = query && !knowledgeAuditRequested && includeLearningRecall
|
|
552
|
+
? rhContextLearningRecall(ctx, repository, query, typeof args.work_id === 'string' ? args.work_id.trim() || undefined : undefined)
|
|
553
|
+
: undefined;
|
|
554
|
+
if (!query && cognitionAudit) {
|
|
555
|
+
const items = Array.isArray(cognitionAudit.items) ? cognitionAudit.items : [];
|
|
556
|
+
const facade = buildFacadeResult({
|
|
557
|
+
status: 'ok',
|
|
558
|
+
summary: `Retrieved ${items.length} bounded learned-memory audit item(s).`,
|
|
559
|
+
data: { operation, repoId: repository.repoId, cognitionAudit },
|
|
560
|
+
warnings: [],
|
|
561
|
+
suggestedNextActions: [],
|
|
562
|
+
detailLevel: args.detail_level === 'detail' || args.detail_level === 'raw' ? args.detail_level : 'summary',
|
|
563
|
+
rawAvailable: false,
|
|
564
|
+
});
|
|
565
|
+
// cognitionAudit is already bounded by scope/item/relation/usage/activation budgets.
|
|
566
|
+
// Preserve its nested provenance and reasoning rather than letting generic facade depth
|
|
567
|
+
// bounding turn the read-only audit contract into opaque "[bounded-depth]" markers.
|
|
568
|
+
(facade.data as typeof facade.data & { cognitionAudit: typeof cognitionAudit }).cognitionAudit = cognitionAudit;
|
|
569
|
+
return result(facade as unknown as Record<string, unknown>);
|
|
570
|
+
}
|
|
314
571
|
const legacySemanticQuery = rhContextLegacySemanticQuery(query);
|
|
315
572
|
const retrievalQuery = legacySemanticQuery.retrievalQuery;
|
|
316
573
|
const list = (value: unknown): string[] => Array.isArray(value)
|
|
@@ -321,11 +578,10 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
321
578
|
: 'implementation';
|
|
322
579
|
const impactDomains = list(args.impact_domains)
|
|
323
580
|
.filter((domain): domain is ControllerContextImpactDomain => CONTROLLER_CONTEXT_IMPACT_DOMAINS.includes(domain as ControllerContextImpactDomain));
|
|
581
|
+
// CodeGraph is opt-in. Ordinary source location never starts a graph index.
|
|
324
582
|
const structuralContext = args.structural_context === 'off' || args.structural_context === 'auto' || args.structural_context === 'required'
|
|
325
583
|
? args.structural_context
|
|
326
|
-
:
|
|
327
|
-
? 'required'
|
|
328
|
-
: 'auto';
|
|
584
|
+
: 'off';
|
|
329
585
|
const requestedCheckIds = list(args.requested_check_ids);
|
|
330
586
|
// Source retrieval is the default Context responsibility. Check
|
|
331
587
|
// readiness is only meaningful when the controller has named the
|
|
@@ -340,25 +596,32 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
340
596
|
checkoutId: repository.activeCheckoutId,
|
|
341
597
|
})
|
|
342
598
|
: undefined;
|
|
343
|
-
|
|
599
|
+
// GPT supplies repository-language code hints for natural-language intents.
|
|
600
|
+
// Forge only searches those literal terms; it does not translate or infer semantics.
|
|
601
|
+
const codeSearchTerms = list(args.search_terms).filter((term) => term.length <= 160).slice(0, 8);
|
|
602
|
+
const exactCodeQuery = !/\s/u.test(retrievalQuery) && isCodeShapedTerm(retrievalQuery);
|
|
603
|
+
const pack = await buildControllerContextPackInSidecar({
|
|
604
|
+
repoRoot: repository.canonicalRoot,
|
|
605
|
+
policy: ctx.policy,
|
|
606
|
+
options: {
|
|
344
607
|
description: retrievalQuery,
|
|
345
|
-
//
|
|
346
|
-
//
|
|
347
|
-
//
|
|
348
|
-
|
|
349
|
-
|
|
608
|
+
// Only an actual single code identifier is an implicit exact needle.
|
|
609
|
+
// Prose (including mixed-language queries) stays in description; the
|
|
610
|
+
// model supplies matching source-language hints through search_terms.
|
|
611
|
+
searchTerms: codeSearchTerms.length ? codeSearchTerms
|
|
612
|
+
: exactCodeQuery ? [retrievalQuery] : undefined,
|
|
350
613
|
knownPaths: list(args.known_paths),
|
|
351
614
|
includeGlobs: list(args.include_globs),
|
|
352
615
|
excludeGlobs: list(args.exclude_globs),
|
|
353
616
|
maxFiles: typeof args.max_files === 'number' ? args.max_files : undefined,
|
|
354
617
|
maxSnippets: typeof args.max_snippets === 'number' ? args.max_snippets : undefined,
|
|
355
618
|
structuralContext,
|
|
356
|
-
structuralIndexRoot: structuralContext === 'off' ? undefined : resolveStructuralIndexRoot(ctx.controllerHome, repository),
|
|
357
619
|
retrievalMode,
|
|
358
620
|
impactDomains,
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
621
|
+
session: rhContextReadSessionId(ctx)
|
|
622
|
+
? { sessionId: rhContextReadSessionId(ctx)!, repoId: repository.repoId, checkoutId: repository.activeCheckoutId }
|
|
623
|
+
: undefined,
|
|
624
|
+
},
|
|
362
625
|
});
|
|
363
626
|
const explicitSemanticNavigation = Array.isArray(args.semantic_navigation) ? args.semantic_navigation : [];
|
|
364
627
|
const semanticRequests = [...explicitSemanticNavigation, ...legacySemanticQuery.requests];
|
|
@@ -376,7 +639,7 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
376
639
|
const semanticReasonCodes = Array.from(new Set([
|
|
377
640
|
...semanticNavigation.errors.map((entry) => `semantic.${String(entry.code ?? 'provider_error').toLowerCase()}`),
|
|
378
641
|
...(semanticNavigation.requestTruncated ? ['semantic.request_truncated'] : []),
|
|
379
|
-
...(semanticNavigation.policyDeniedLocations > 0 || semanticNavigation.
|
|
642
|
+
...(semanticNavigation.policyDeniedLocations > 0 || semanticNavigation.materialPolicyDeniedReads > 0 ? ['semantic.policy_denied'] : []),
|
|
380
643
|
...(semanticNavigation.freshness === 'changed_during_query' ? ['semantic.source_changed_during_query'] : []),
|
|
381
644
|
...(semanticNavigation.requested > 0 && semanticNavigation.staticClosure.status !== 'complete_for_requested_symbols' ? ['semantic.static_closure_incomplete'] : []),
|
|
382
645
|
]));
|
|
@@ -446,13 +709,15 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
446
709
|
omitted: pack.omitted,
|
|
447
710
|
limits: pack.limits,
|
|
448
711
|
contextContract: pack.contextContract,
|
|
712
|
+
...(cognitionAudit ? { cognitionAudit } : {}),
|
|
713
|
+
...(learningRecall ? { learningRecall } : {}),
|
|
449
714
|
...(executionReadiness ? {
|
|
450
715
|
executionReadiness,
|
|
451
716
|
registeredChecks: checks.slice(0, 80).map((check) => ({ id: check.id, description: check.description, source: check.source, effects: check.effects })),
|
|
452
717
|
} : {}),
|
|
453
718
|
retrievalPolicy: {
|
|
454
719
|
defaultBackend: 'bounded_lexical',
|
|
455
|
-
structuralBackend: '
|
|
720
|
+
structuralBackend: 'retired',
|
|
456
721
|
rawReadTool: 'read_repository_file',
|
|
457
722
|
shellSearchFallbackOnly: true,
|
|
458
723
|
executionReadiness: 'requested_check_ids_only',
|
|
@@ -460,7 +725,7 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
460
725
|
},
|
|
461
726
|
warnings,
|
|
462
727
|
suggestedNextActions: [],
|
|
463
|
-
detailLevel: 'summary',
|
|
728
|
+
detailLevel: args.detail_level === 'detail' || args.detail_level === 'raw' ? args.detail_level : 'summary',
|
|
464
729
|
rawAvailable: true,
|
|
465
730
|
});
|
|
466
731
|
// ContextClosureReceipt already enforces bounded paths, tests, skills, semantic providers,
|
|
@@ -468,6 +733,41 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
468
733
|
// but it must not corrupt this runtime-issued round-trip contract because rh_work validates
|
|
469
734
|
// the exact full receipt digest supplied by the Controller during engineering re-entry.
|
|
470
735
|
(facade.data as typeof facade.data & { contextClosure: typeof contextClosure }).contextClosure = contextClosure;
|
|
736
|
+
// Individual snippets are bounded, but broad searches can still aggregate
|
|
737
|
+
// a very large direct MCP payload. Keep ContextClosure authority inline and
|
|
738
|
+
// externalize only the heavy file collection through the existing Result Store.
|
|
739
|
+
const boundedFiles = boundedRuntimeResult({
|
|
740
|
+
controllerHome: ctx.controllerHome,
|
|
741
|
+
repoId: repository.repoId,
|
|
742
|
+
sessionId: ctx.sessionId,
|
|
743
|
+
principalId: ctx.principalId,
|
|
744
|
+
controllerInstanceId: ctx.controllerInstanceId,
|
|
745
|
+
workId: typeof args.work_id === 'string' ? args.work_id.trim() || undefined : undefined,
|
|
746
|
+
}, pack.files);
|
|
747
|
+
const data = facade.data as typeof facade.data & {
|
|
748
|
+
files: typeof pack.files;
|
|
749
|
+
filesResult?: unknown;
|
|
750
|
+
filesTruncated?: boolean;
|
|
751
|
+
fileCount?: number;
|
|
752
|
+
filePreview?: Array<{ path: string; reasons: string[]; hitLines: number[]; snippetCount: number }>;
|
|
753
|
+
};
|
|
754
|
+
if (boundedFiles.externalized) {
|
|
755
|
+
data.files = [];
|
|
756
|
+
data.filesResult = boundedFiles.value;
|
|
757
|
+
data.filesTruncated = true;
|
|
758
|
+
data.fileCount = pack.files.length;
|
|
759
|
+
data.filePreview = pack.files.slice(0, 10).map((file) => ({
|
|
760
|
+
path: file.path,
|
|
761
|
+
reasons: file.reasons.slice(0, 4),
|
|
762
|
+
hitLines: file.hitLines.slice(0, 12),
|
|
763
|
+
snippetCount: file.snippetCount,
|
|
764
|
+
}));
|
|
765
|
+
} else {
|
|
766
|
+
data.files = pack.files;
|
|
767
|
+
}
|
|
768
|
+
if (cognitionAudit) {
|
|
769
|
+
(facade.data as typeof facade.data & { cognitionAudit: typeof cognitionAudit }).cognitionAudit = cognitionAudit;
|
|
770
|
+
}
|
|
471
771
|
return result(facade as unknown as Record<string, unknown>);
|
|
472
772
|
}
|
|
473
773
|
const startedAt = performance.now();
|
|
@@ -476,20 +776,20 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
476
776
|
const pluginMatch = /^plugin\.([^.]+)\.(.+)$/.exec(requestedCapabilityId);
|
|
477
777
|
const manifests = pluginMatch ? (() => {
|
|
478
778
|
const pluginId = pluginMatch[1];
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
779
|
+
try {
|
|
780
|
+
return [getAssistantPluginManifest(ctx.controllerHome, repository, pluginId)];
|
|
781
|
+
} catch (error) {
|
|
782
|
+
if (!(error instanceof Error) || !error.message.startsWith('PLUGIN_NOT_FOUND:')) throw error;
|
|
783
|
+
}
|
|
784
|
+
try {
|
|
785
|
+
return [getControllerPluginManifest(ctx.controllerHome, pluginId)];
|
|
786
|
+
} catch (error) {
|
|
787
|
+
if (!(error instanceof Error) || !error.message.startsWith('PLUGIN_NOT_FOUND:')) throw error;
|
|
489
788
|
}
|
|
490
789
|
return [];
|
|
491
790
|
})() : [];
|
|
492
791
|
const descriptor = getCapabilityDescriptor(requestedCapabilityId, manifests);
|
|
792
|
+
const coreCapability = getCoreCapabilityExecutionSchema(requestedCapabilityId);
|
|
493
793
|
const pluginAction = getPluginActionCapabilitySchema(requestedCapabilityId, manifests);
|
|
494
794
|
const facade = buildFacadeResult({
|
|
495
795
|
status: 'ok',
|
|
@@ -509,10 +809,11 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
509
809
|
requestedCapabilityId,
|
|
510
810
|
found: Boolean(descriptor),
|
|
511
811
|
descriptor,
|
|
812
|
+
coreCapability,
|
|
512
813
|
pluginAction,
|
|
513
814
|
},
|
|
514
815
|
toolArchitecture: {
|
|
515
|
-
facadeTools: [
|
|
816
|
+
facadeTools: [...FACADE_TOOLS],
|
|
516
817
|
domainSchemaLoading: 'exact_capability_fast_path',
|
|
517
818
|
},
|
|
518
819
|
bounded: true,
|
|
@@ -534,18 +835,21 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
534
835
|
? args.query.trim()
|
|
535
836
|
: '';
|
|
536
837
|
if (capabilityIntentQuery) {
|
|
537
|
-
const
|
|
838
|
+
const learningRecall = args.include_learning_recall === false
|
|
839
|
+
? undefined
|
|
840
|
+
: rhContextLearningRecall(ctx, repository, capabilityIntentQuery);
|
|
841
|
+
// Intent-ranked capability discovery must reflect the executable plugin contract.
|
|
842
|
+
// Persisted manifests are status projections and may outlive a source release that moved an action.
|
|
843
|
+
const manifestOptions = { preferStored: false };
|
|
538
844
|
const repositoryManifests = listAssistantPluginManifests(ctx.controllerHome, repository, manifestOptions);
|
|
539
|
-
const
|
|
540
|
-
const controllerManifests = repository.repoId === controllerRepository.repoId
|
|
541
|
-
? []
|
|
542
|
-
: listAssistantPluginManifests(ctx.controllerHome, controllerRepository, manifestOptions);
|
|
845
|
+
const controllerManifests = listControllerPluginManifests(ctx.controllerHome, manifestOptions);
|
|
543
846
|
const manifests = [...new Map(
|
|
544
|
-
[...
|
|
847
|
+
[...controllerManifests, ...repositoryManifests].map((manifest) => [manifest.pluginId, manifest] as const),
|
|
545
848
|
).values()];
|
|
546
849
|
const matches = searchCapabilityDescriptors(capabilityIntentQuery, manifests, 12)
|
|
547
850
|
.map((match) => ({
|
|
548
851
|
...match,
|
|
852
|
+
coreCapability: getCoreCapabilityExecutionSchema(match.capabilityId),
|
|
549
853
|
pluginAction: getPluginActionCapabilitySchema(match.capabilityId, manifests),
|
|
550
854
|
}));
|
|
551
855
|
const facade = buildFacadeResult({
|
|
@@ -560,10 +864,11 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
560
864
|
query: capabilityIntentQuery,
|
|
561
865
|
matches,
|
|
562
866
|
readOnlyDiscovery: true,
|
|
563
|
-
executeWith: '
|
|
867
|
+
executeWith: 'capability-specific',
|
|
564
868
|
},
|
|
869
|
+
...(learningRecall ? { learningRecall } : {}),
|
|
565
870
|
toolArchitecture: {
|
|
566
|
-
facadeTools: [
|
|
871
|
+
facadeTools: [...FACADE_TOOLS],
|
|
567
872
|
domainSchemaLoading: 'intent_ranked_capability_search',
|
|
568
873
|
exactCapabilityLookupStillAvailable: true,
|
|
569
874
|
},
|
|
@@ -598,20 +903,25 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
598
903
|
? readActiveWorkCandidates({ ...store, limit: 20 })
|
|
599
904
|
: { contracts: [], invalid: [] as InvalidActiveWorkCandidate[] };
|
|
600
905
|
const activeContractScan = activeWorkProjection.contracts;
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
|
|
906
|
+
const currentLineageWorkIds = work
|
|
907
|
+
? currentTaskLineageWorkIds([work.workId], readWorkContractStore(store).contracts)
|
|
908
|
+
: new Set<string>();
|
|
909
|
+
const recentActivityCutoffMs = Date.now() - RH_CONTEXT_RECENT_ACTIVITY_WINDOW_MS;
|
|
910
|
+
const recentActiveContractScan = isSummary
|
|
911
|
+
? activeContractScan.filter((contract) => isRecentRhContextWork(contract, recentActivityCutoffMs))
|
|
604
912
|
: activeContractScan;
|
|
605
|
-
const activeContracts = isSummary ?
|
|
913
|
+
const activeContracts = isSummary ? recentActiveContractScan.slice(0, 3) : activeContractScan;
|
|
606
914
|
const recentJobs = !isSummary && (operation === 'list' || !workId)
|
|
607
915
|
? listExecutionJobs(ctx.controllerHome, repository.repoId, 20)
|
|
608
|
-
.filter((job) =>
|
|
916
|
+
.filter((job) => timestampIsRecent(job.updatedAt, recentActivityCutoffMs))
|
|
609
917
|
.slice(0, 5)
|
|
610
918
|
: [];
|
|
611
919
|
const processScan = isSummary
|
|
612
920
|
? listRecoverableProcessRecords(ctx.controllerHome, repository.repoId)
|
|
613
921
|
: listProcessRecords(ctx.controllerHome, repository.repoId, workId ? 100 : 50);
|
|
614
|
-
const relevantProcesses = processScan.filter((process) =>
|
|
922
|
+
const relevantProcesses = processScan.filter((process) => work
|
|
923
|
+
? Boolean(process.workId && currentLineageWorkIds.has(process.workId))
|
|
924
|
+
: timestampIsRecent(process.updatedAt, recentActivityCutoffMs));
|
|
615
925
|
const liveProcessIds = new Set(processRuntimeResourceDiagnostics().activeProcessIds);
|
|
616
926
|
const activeProcesses = relevantProcesses.filter((process) => liveProcessIds.has(process.processId) && isManagedProcessActive(process));
|
|
617
927
|
const workController = work ? getControllerSession(store, work.workId) : undefined;
|
|
@@ -620,10 +930,7 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
620
930
|
? []
|
|
621
931
|
: (() => {
|
|
622
932
|
const repositoryManifests = listAssistantPluginManifests(ctx.controllerHome, repository, manifestOptions);
|
|
623
|
-
const
|
|
624
|
-
const controllerManifests = repository.repoId === controllerRepository.repoId
|
|
625
|
-
? []
|
|
626
|
-
: listAssistantPluginManifests(ctx.controllerHome, controllerRepository, manifestOptions);
|
|
933
|
+
const controllerManifests = listControllerPluginManifests(ctx.controllerHome, manifestOptions);
|
|
627
934
|
return [...new Map(
|
|
628
935
|
[...repositoryManifests, ...controllerManifests].map((manifest) => [manifest.pluginId, manifest] as const),
|
|
629
936
|
).values()];
|
|
@@ -636,17 +943,86 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
636
943
|
.filter((check): check is (typeof checks)[number] => Boolean(check))
|
|
637
944
|
.map((check) => ({ id: check.id, description: check.description, source: check.source }));
|
|
638
945
|
const pendingAttention = listHandoffItems({ ...store, status: 'pending', limit: isSummary ? 20 : 5 });
|
|
639
|
-
const
|
|
640
|
-
const
|
|
641
|
-
?
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
:
|
|
946
|
+
const currentAttentionScan = listHandoffAttentionItems(store, isSummary ? 20 : 5);
|
|
947
|
+
const workAttentionItems = work
|
|
948
|
+
? currentAttentionScan.filter((item) => Boolean(item.workId && currentLineageWorkIds.has(item.workId)))
|
|
949
|
+
: [];
|
|
950
|
+
const workAttention = workAttentionItems[0];
|
|
951
|
+
const resumeContext = work ? (() => {
|
|
952
|
+
const semanticWork = workSemanticView(work);
|
|
953
|
+
const requirementRecord = work.requirementId?.trim()
|
|
954
|
+
? readRequirement({ controllerHome: ctx.controllerHome }, work.requirementId.trim())
|
|
955
|
+
: undefined;
|
|
956
|
+
const semanticRequirement = requirementRecord ? requirementSemanticView(requirementRecord.value) : undefined;
|
|
957
|
+
const plan = work.planId?.trim() ? getPlanContract(store, work.planId.trim()) : undefined;
|
|
958
|
+
const semanticPlan = plan ? planSemanticView(plan) : undefined;
|
|
959
|
+
const exactCheckout = work.checkoutId?.trim()
|
|
960
|
+
? repository.checkouts.find((candidate) => candidate.checkoutId === work.checkoutId)
|
|
961
|
+
: repository.checkouts.find((candidate) => candidate.checkoutId === repository.activeCheckoutId);
|
|
962
|
+
const source = freshGitIdentity(exactCheckout?.canonicalRoot ?? repository.canonicalRoot);
|
|
963
|
+
const unresolvedHumanRequests = workAttentionItems
|
|
964
|
+
.filter((item) => Boolean(item.creationReason && RESUME_CONTEXT_HUMAN_REQUEST_REASONS.has(item.creationReason)))
|
|
965
|
+
.slice(0, 8)
|
|
966
|
+
.map((item) => ({
|
|
967
|
+
id: item.id,
|
|
968
|
+
reason: item.reason.slice(0, 500),
|
|
969
|
+
creationReason: item.creationReason,
|
|
970
|
+
blockingDecision: item.blockingDecision?.slice(0, 500),
|
|
971
|
+
recommendedDecision: item.recommendedDecision.slice(0, 500),
|
|
972
|
+
}));
|
|
973
|
+
const checkReceiptRefs = work.checkRefs
|
|
974
|
+
.flatMap((record) => record.receipt?.receiptId?.trim() ? [record.receipt.receiptId.trim()] : [])
|
|
975
|
+
.slice(-24);
|
|
976
|
+
return {
|
|
977
|
+
schemaVersion: 1 as const,
|
|
978
|
+
derived: true as const,
|
|
979
|
+
semantic: {
|
|
980
|
+
...(semanticRequirement ? { requirement: semanticRequirement } : {}),
|
|
981
|
+
...(semanticPlan ? { plan: semanticPlan } : {}),
|
|
982
|
+
work: semanticWork,
|
|
983
|
+
},
|
|
984
|
+
source: {
|
|
985
|
+
checkoutId: exactCheckout?.checkoutId ?? work.checkoutId,
|
|
986
|
+
worktree: exactCheckout?.worktree ?? false,
|
|
987
|
+
head: source.head,
|
|
988
|
+
branch: source.branch,
|
|
989
|
+
dirty: source.dirty,
|
|
990
|
+
workingTreeFingerprint: source.workingTreeFingerprint,
|
|
991
|
+
observedAt: new Date(source.sampledAt).toISOString(),
|
|
992
|
+
},
|
|
993
|
+
staleness: {
|
|
994
|
+
requirementBasisStale: Boolean(semanticRequirement && semanticPlan?.requirementBasisRevision && semanticRequirement.revision !== semanticPlan.requirementBasisRevision),
|
|
995
|
+
workRequirementBasisStale: Boolean(semanticRequirement && semanticWork.requirementRevision && semanticRequirement.revision !== semanticWork.requirementRevision),
|
|
996
|
+
workPlanBasisStale: Boolean(semanticPlan && semanticWork.planRevision && semanticPlan.revision !== semanticWork.planRevision),
|
|
997
|
+
sourceBasisStale: Boolean(semanticPlan?.sourceBasisRevision && source.head && semanticPlan.sourceBasisRevision !== source.head),
|
|
998
|
+
advisoryOnly: true as const,
|
|
999
|
+
},
|
|
1000
|
+
unresolvedHumanRequests,
|
|
1001
|
+
durableHandles: {
|
|
1002
|
+
processes: relevantProcesses.slice(0, 8).map((process) => ({
|
|
1003
|
+
processId: process.processId,
|
|
1004
|
+
status: process.status,
|
|
1005
|
+
workId: process.workId,
|
|
1006
|
+
updatedAt: process.updatedAt,
|
|
1007
|
+
})),
|
|
1008
|
+
...(workController ? { controller: {
|
|
1009
|
+
controllerType: workController.controllerType,
|
|
1010
|
+
sessionId: workController.sessionId,
|
|
1011
|
+
leaseExpiresAt: workController.leaseExpiresAt,
|
|
1012
|
+
} } : {}),
|
|
1013
|
+
},
|
|
1014
|
+
receipts: {
|
|
1015
|
+
resultRefs: semanticWork.resultRefs,
|
|
1016
|
+
...(work.completionReceipt?.receiptId?.trim() ? { completionReceiptRef: work.completionReceipt.receiptId.trim() } : {}),
|
|
1017
|
+
checkReceiptRefs,
|
|
1018
|
+
},
|
|
1019
|
+
};
|
|
1020
|
+
})() : undefined;
|
|
1021
|
+
const currentAttentionItems = work
|
|
1022
|
+
? workAttentionItems
|
|
1023
|
+
: isSummary
|
|
1024
|
+
? currentAttentionScan.slice(0, 3)
|
|
1025
|
+
: currentAttentionScan;
|
|
650
1026
|
const attention = isSummary
|
|
651
1027
|
? currentAttentionItems.map((item) => ({
|
|
652
1028
|
id: item.id,
|
|
@@ -695,8 +1071,7 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
695
1071
|
work: work
|
|
696
1072
|
? {
|
|
697
1073
|
workId: work.workId,
|
|
698
|
-
|
|
699
|
-
mode: work.mode,
|
|
1074
|
+
state: work.semanticState,
|
|
700
1075
|
objective: work.objective.slice(0, 160),
|
|
701
1076
|
continuation: buildWorkContinuationSnapshot(work),
|
|
702
1077
|
}
|
|
@@ -706,14 +1081,13 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
706
1081
|
activeController: workController ? { controllerType: workController.controllerType, sessionId: workController.sessionId, leaseExpiresAt: workController.leaseExpiresAt } : undefined,
|
|
707
1082
|
activeProcesses: activeProcesses.slice(0, 3).map((process) => ({ processId: process.processId, workId: process.workId, status: process.status, route: process.route, startedAt: process.startedAt, updatedAt: process.updatedAt })),
|
|
708
1083
|
recentProcesses: relevantProcesses.slice(0, 5).map((process) => ({ processId: process.processId, workId: process.workId, status: process.status, route: process.route, startedAt: process.startedAt, updatedAt: process.updatedAt })),
|
|
1084
|
+
currentTask: work ? currentTaskSemanticProjectionForWork(work) : undefined,
|
|
1085
|
+
...(resumeContext ? { resumeContext } : {}),
|
|
709
1086
|
activeWork: activeContracts.map((entry) => ({
|
|
1087
|
+
relation: 'repository_inventory' as const,
|
|
1088
|
+
relevance: ['ownership', 'conflict', 'release_admission'] as const,
|
|
710
1089
|
workId: entry.workId,
|
|
711
|
-
|
|
712
|
-
mode: entry.mode,
|
|
713
|
-
objective: entry.objective.slice(0, 160),
|
|
714
|
-
semantics: buildWorkContinuationSnapshot(entry).semantics,
|
|
715
|
-
reconciliationRequired: buildWorkContinuationSnapshot(entry).reconciliationRequired,
|
|
716
|
-
nextSafeAction: buildWorkContinuationSnapshot(entry).nextSafeAction,
|
|
1090
|
+
state: entry.semanticState,
|
|
717
1091
|
})),
|
|
718
1092
|
invalidActiveWork: activeWorkProjection.invalid.slice(0, 3).map(summarizeInvalidActiveWorkCandidate),
|
|
719
1093
|
activeAttention: attention,
|
|
@@ -721,21 +1095,23 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
721
1095
|
availableChecks: checks.length,
|
|
722
1096
|
selectedChecks: selectedChecks.length,
|
|
723
1097
|
capabilityInventoryDeferred: true,
|
|
724
|
-
activeWork:
|
|
1098
|
+
activeWork: recentActiveContractScan.length,
|
|
725
1099
|
activeWorkShown: activeContracts.length,
|
|
1100
|
+
recentActiveWork: recentActiveContractScan.length,
|
|
726
1101
|
invalidActiveWork: activeWorkProjection.invalid.length,
|
|
727
1102
|
invalidActiveWorkShown: Math.min(activeWorkProjection.invalid.length, 3),
|
|
728
1103
|
storedNonTerminalWork: activeContractScan.length,
|
|
729
|
-
currentWork:
|
|
730
|
-
historicalNonTerminalWork: Math.max(0, activeContractScan.length -
|
|
731
|
-
currentAttention:
|
|
1104
|
+
currentWork: work ? 1 : 0,
|
|
1105
|
+
historicalNonTerminalWork: Math.max(0, activeContractScan.length - recentActiveContractScan.length),
|
|
1106
|
+
currentAttention: work ? workAttentionItems.length : 0,
|
|
1107
|
+
repositoryAttention: currentAttentionScan.length,
|
|
732
1108
|
currentAttentionShown: attention.length,
|
|
733
1109
|
activeProcesses: activeProcesses.length,
|
|
734
1110
|
recentProcesses: relevantProcesses.length,
|
|
735
1111
|
historicalProcessScanDeferred: true,
|
|
736
1112
|
pendingAttentionScanned: pendingAttention.length,
|
|
737
1113
|
historicalPendingAttention: Math.max(0, pendingAttention.length - currentAttentionScan.length),
|
|
738
|
-
omittedCurrentAttention: Math.max(0,
|
|
1114
|
+
omittedCurrentAttention: Math.max(0, (work ? workAttentionItems.length : 0) - attention.length),
|
|
739
1115
|
omittedPendingAttention: Math.max(0, pendingAttention.length - attention.length),
|
|
740
1116
|
},
|
|
741
1117
|
historicalExecutionJobsIncluded: false,
|
|
@@ -768,6 +1144,8 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
768
1144
|
domainSchemaLoading: 'static_stable_surface',
|
|
769
1145
|
dynamicDomainSchemaLoadingSupported: false,
|
|
770
1146
|
},
|
|
1147
|
+
currentTask: work ? currentTaskSemanticProjectionForWork(work) : undefined,
|
|
1148
|
+
...(resumeContext ? { resumeContext } : {}),
|
|
771
1149
|
work: work ? { ...work, continuation: buildWorkContinuationSnapshot(work) } : undefined,
|
|
772
1150
|
executionJob: executionJob ? summarizeWorkListItem(executionJob) : undefined,
|
|
773
1151
|
executionState: work ? (workAttention ? 'blocked' : activeProcesses.length > 0 ? 'executing' : workController ? 'controller_active' : 'waiting_trigger') : undefined,
|
|
@@ -775,11 +1153,10 @@ export async function callContextAdapter(ctx: MultiRepositoryMcpToolContext, nam
|
|
|
775
1153
|
activeProcesses: activeProcesses.slice(0, 10),
|
|
776
1154
|
recentProcesses: relevantProcesses.slice(0, 20),
|
|
777
1155
|
activeWork: activeContracts.map((entry) => ({
|
|
1156
|
+
relation: 'repository_inventory' as const,
|
|
1157
|
+
relevance: ['ownership', 'conflict', 'release_admission'] as const,
|
|
778
1158
|
workId: entry.workId,
|
|
779
|
-
|
|
780
|
-
mode: entry.mode,
|
|
781
|
-
objective: entry.objective.slice(0, 240),
|
|
782
|
-
continuation: buildWorkContinuationSnapshot(entry),
|
|
1159
|
+
state: entry.semanticState,
|
|
783
1160
|
})),
|
|
784
1161
|
invalidActiveWork: activeWorkProjection.invalid.slice(0, 10).map(summarizeInvalidActiveWorkCandidate),
|
|
785
1162
|
recentExecutionJobs: recentJobs.map(summarizeWorkListItem),
|