@wildo-ai/dev-companion 1.1.1 → 1.1.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/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts +12 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts.map +1 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js +11 -0
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js.map +1 -1
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts +153 -1
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts.map +1 -1
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js +419 -41
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
- package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.d.ts +25 -10
- package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.d.ts.map +1 -1
- package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.js +65 -24
- package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.js.map +1 -1
- package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts +86 -0
- package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts.map +1 -0
- package/dist/esm/claude-cli/services/research-evidence-store.companion.js +127 -0
- package/dist/esm/claude-cli/services/research-evidence-store.companion.js.map +1 -0
- package/dist/esm/companion-api/companion-api.schemas.d.ts +59 -2
- package/dist/esm/companion-api/companion-api.schemas.d.ts.map +1 -1
- package/dist/esm/companion-api/companion-api.schemas.js +60 -0
- package/dist/esm/companion-api/companion-api.schemas.js.map +1 -1
- package/dist/esm/companion-api/controllers/companion.controller.d.ts +63 -1
- package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
- package/dist/esm/companion-api/controllers/companion.controller.js +322 -21
- package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
- package/dist/esm/core/inject/models/container.d.ts.map +1 -1
- package/dist/esm/core/inject/models/container.js +11 -0
- package/dist/esm/core/inject/models/container.js.map +1 -1
- package/dist/esm/core/inject/models/service-types.d.ts +5 -0
- package/dist/esm/core/inject/models/service-types.d.ts.map +1 -1
- package/dist/esm/core/inject/models/service-types.js +5 -0
- package/dist/esm/core/inject/models/service-types.js.map +1 -1
- package/dist/esm/core/introspection/behaviors/companion-introspection-behavior-definitions.d.ts.map +1 -1
- package/dist/esm/core/introspection/behaviors/companion-introspection-behavior-definitions.js +81 -0
- package/dist/esm/core/introspection/behaviors/companion-introspection-behavior-definitions.js.map +1 -1
- package/dist/esm/core/introspection/models/companion-introspection.models.d.ts +11 -1
- package/dist/esm/core/introspection/models/companion-introspection.models.d.ts.map +1 -1
- package/dist/esm/core/introspection/models/companion-introspection.models.js +39 -0
- package/dist/esm/core/introspection/models/companion-introspection.models.js.map +1 -1
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.d.ts +8 -0
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.js +317 -0
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.d.ts +45 -0
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js +250 -0
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.d.ts +123 -0
- package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.js +298 -0
- package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.d.ts +78 -1
- package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.js +155 -6
- package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts +131 -2
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.js +259 -9
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.d.ts +243 -0
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.js +417 -0
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts +186 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js +368 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.d.ts +101 -0
- package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.js +278 -0
- package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.d.ts +365 -0
- package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.d.ts.map +1 -0
- package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.js +167 -0
- package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.js.map +1 -0
- package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.d.ts.map +1 -1
- package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js +332 -3
- package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js.map +1 -1
- package/dist/esm/core/introspection/subprocess/family-aspects.behavior.d.ts +19 -0
- package/dist/esm/core/introspection/subprocess/family-aspects.behavior.d.ts.map +1 -0
- package/dist/esm/core/introspection/subprocess/family-aspects.behavior.js +164 -0
- package/dist/esm/core/introspection/subprocess/family-aspects.behavior.js.map +1 -0
- package/dist/esm/core/introspection/subprocess/openapi-generation-input.behavior.d.ts +3 -1
- package/dist/esm/core/introspection/subprocess/openapi-generation-input.behavior.d.ts.map +1 -1
- package/dist/esm/core/introspection/subprocess/openapi-generation-input.behavior.js +36 -23
- package/dist/esm/core/introspection/subprocess/openapi-generation-input.behavior.js.map +1 -1
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.d.ts +51 -0
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.d.ts.map +1 -0
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js +391 -0
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js.map +1 -0
- package/dist/esm/core/runtime/companion-startup-assembly.d.ts.map +1 -1
- package/dist/esm/core/runtime/companion-startup-assembly.js +5 -0
- package/dist/esm/core/runtime/companion-startup-assembly.js.map +1 -1
- package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts +103 -0
- package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts.map +1 -0
- package/dist/esm/core/runtime/dev-compile-quiet.companion.js +124 -0
- package/dist/esm/core/runtime/dev-compile-quiet.companion.js.map +1 -0
- package/dist/esm/core/runtime/services/start-companion-application.service.d.ts +39 -2
- package/dist/esm/core/runtime/services/start-companion-application.service.d.ts.map +1 -1
- package/dist/esm/core/runtime/services/start-companion-application.service.js +122 -11
- package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
- package/dist/esm/core/specifications/non-composite-view-specification-context.shared.d.ts +6 -0
- package/dist/esm/core/specifications/non-composite-view-specification-context.shared.d.ts.map +1 -1
- package/dist/esm/core/specifications/non-composite-view-specification-context.shared.js.map +1 -1
- package/dist/esm/core/specifications/specification-context-factory.shared.d.ts +23 -0
- package/dist/esm/core/specifications/specification-context-factory.shared.d.ts.map +1 -1
- package/dist/esm/core/specifications/specification-context-factory.shared.js +26 -4
- package/dist/esm/core/specifications/specification-context-factory.shared.js.map +1 -1
- package/dist/esm/executions/services/companion-executions.companion.service.d.ts +82 -3
- package/dist/esm/executions/services/companion-executions.companion.service.d.ts.map +1 -1
- package/dist/esm/executions/services/companion-executions.companion.service.js +126 -12
- package/dist/esm/executions/services/companion-executions.companion.service.js.map +1 -1
- package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.d.ts +12 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.d.ts.map +1 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.js +12 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.js.map +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.d.ts +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.js +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.js.map +1 -1
- package/dist/esm/i18n/composite_views/app.creation-board.en.d.ts +13 -0
- package/dist/esm/i18n/composite_views/app.creation-board.en.d.ts.map +1 -0
- package/dist/esm/i18n/composite_views/app.creation-board.en.js +91 -0
- package/dist/esm/i18n/composite_views/app.creation-board.en.js.map +1 -0
- package/dist/esm/i18n/composite_views/app.domain-model.en.d.ts +38 -0
- package/dist/esm/i18n/composite_views/app.domain-model.en.d.ts.map +1 -0
- package/dist/esm/i18n/composite_views/app.domain-model.en.js +41 -0
- package/dist/esm/i18n/composite_views/app.domain-model.en.js.map +1 -0
- package/dist/esm/i18n/index.d.ts +3 -3
- package/dist/esm/i18n/index.js +3 -3
- package/dist/esm/i18n/index.js.map +1 -1
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.d.ts +24 -0
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.js +20 -0
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.js.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.d.ts +31 -0
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.js +27 -0
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.js.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.d.ts +24 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.js +20 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts +28 -0
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js +24 -0
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchDomainResources.en.d.ts +138 -0
- package/dist/esm/i18n/resources/workbenchDomainResources.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchDomainResources.en.js +100 -0
- package/dist/esm/i18n/resources/workbenchDomainResources.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchPlaybooks.en.d.ts +29 -0
- package/dist/esm/i18n/resources/workbenchPlaybooks.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchPlaybooks.en.js +25 -0
- package/dist/esm/i18n/resources/workbenchPlaybooks.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.d.ts +27 -0
- package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.js +23 -0
- package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +806 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +326 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchTraceSessions.en.d.ts +26 -0
- package/dist/esm/i18n/resources/workbenchTraceSessions.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchTraceSessions.en.js +22 -0
- package/dist/esm/i18n/resources/workbenchTraceSessions.en.js.map +1 -0
- package/dist/esm/i18n/system_enums/market.en.d.ts +202 -0
- package/dist/esm/i18n/system_enums/market.en.d.ts.map +1 -0
- package/dist/esm/i18n/system_enums/market.en.js +209 -0
- package/dist/esm/i18n/system_enums/market.en.js.map +1 -0
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts +112 -2
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js +201 -34
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js.map +1 -1
- package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.d.ts +31 -3
- package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.js +48 -12
- package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.js.map +1 -1
- package/dist/esm/meta-workflows/models/brief-adequacy.actors-system.definitions.d.ts +36 -0
- package/dist/esm/meta-workflows/models/brief-adequacy.actors-system.definitions.d.ts.map +1 -0
- package/dist/esm/meta-workflows/models/brief-adequacy.actors-system.definitions.js +75 -0
- package/dist/esm/meta-workflows/models/brief-adequacy.actors-system.definitions.js.map +1 -0
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +105 -7
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +298 -24
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts +46 -3
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js +95 -2
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.d.ts +9 -0
- package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.js +13 -0
- package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts +12 -0
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js +23 -0
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +120 -3
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +636 -81
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.d.ts +40 -0
- package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.js +63 -1
- package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.js.map +1 -1
- package/dist/esm/technical-doc/services/technical-doc.companion.service.d.ts +21 -0
- package/dist/esm/technical-doc/services/technical-doc.companion.service.d.ts.map +1 -1
- package/dist/esm/technical-doc/services/technical-doc.companion.service.js +86 -2
- package/dist/esm/technical-doc/services/technical-doc.companion.service.js.map +1 -1
- package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.d.ts +12 -1
- package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.d.ts.map +1 -1
- package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.js +47 -1
- package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.js.map +1 -1
- package/package.json +17 -17
- package/dist/esm/.builder.pid +0 -9
- package/dist/esm/i18n/resources/workbenchApplicationModules.en.d.ts +0 -36
- package/dist/esm/i18n/resources/workbenchApplicationModules.en.d.ts.map +0 -1
- package/dist/esm/i18n/resources/workbenchApplicationModules.en.js +0 -32
- package/dist/esm/i18n/resources/workbenchApplicationModules.en.js.map +0 -1
- package/dist/esm/i18n/resources/workbenchResourceRelationships.en.d.ts +0 -29
- package/dist/esm/i18n/resources/workbenchResourceRelationships.en.d.ts.map +0 -1
- package/dist/esm/i18n/resources/workbenchResourceRelationships.en.js +0 -25
- package/dist/esm/i18n/resources/workbenchResourceRelationships.en.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Research dispatch — the evidence half of the ACP lane. Read-only toward the workspace, except
|
|
3
|
+
* for its own evidence store.
|
|
3
4
|
*
|
|
4
5
|
* ## Why this is a SECOND WRAPPER and not a mode on the coding one
|
|
5
6
|
*
|
|
@@ -10,15 +11,19 @@
|
|
|
10
11
|
* nothing and returns text. So research is a sibling over the same runner rather than a branch
|
|
11
12
|
* inside a service whose every other line is about attributing writes.
|
|
12
13
|
*
|
|
13
|
-
* ##
|
|
14
|
+
* ## The confinement, and it is TWO independent things
|
|
14
15
|
*
|
|
15
|
-
* 1. The `claude-code-acp-research` profile's `
|
|
16
|
-
* non-mutating tool kinds (`read`, `search`, `fetch`, `think`) — never `
|
|
17
|
-
* never
|
|
18
|
-
*
|
|
16
|
+
* 1. The `claude-code-acp-research` profile's `AUTO_ACCEPT_EDITS` ceiling admits the protocol's
|
|
17
|
+
* non-mutating tool kinds (`read`, `search`, `fetch`, `think`) plus `edit` — never `execute`,
|
|
18
|
+
* never the unclassified `other`. (It was `AUTO_ACCEPT_READS` until 2026-09-04, when three lost
|
|
19
|
+
* compliance runs showed evidence living only in run memory cannot be leveraged or recovered;
|
|
20
|
+
* the edit admission exists solely so findings persist as they are gathered.)
|
|
21
|
+
* 2. This dispatch supplies a location predicate that admits ONLY the evidence store
|
|
22
|
+
* (`specifications/research-evidence/`) and refuses every other path — built by the same
|
|
23
|
+
* `buildApplicationCodingTaskLocationPredicate` the coding lane trusts. The runner applies it to
|
|
19
24
|
* any permission request declaring locations, whatever its kind, and separately gates the
|
|
20
|
-
* client-side write RPC. So a web read (which declares no location) passes
|
|
21
|
-
* or write does not.
|
|
25
|
+
* client-side write RPC. So a web read (which declares no location) passes, an evidence-store
|
|
26
|
+
* write passes, and any other filesystem read or write does not.
|
|
22
27
|
*
|
|
23
28
|
* Neither alone is the guarantee. The ceiling stops the kinds; the predicate stops the paths.
|
|
24
29
|
*
|
|
@@ -42,6 +47,14 @@ export interface ResearchTaskRequest {
|
|
|
42
47
|
* and not a search API. Code gates the KIND of work and its bounds; it never gates the content.
|
|
43
48
|
*/
|
|
44
49
|
readonly objective: string;
|
|
50
|
+
/**
|
|
51
|
+
* Which investigation this task belongs to — normally the composite playbook ref. Names the
|
|
52
|
+
* evidence-store directory every round of that investigation consolidates into. Absent for an
|
|
53
|
+
* operator's ad-hoc question, which lands under `adhoc`.
|
|
54
|
+
*/
|
|
55
|
+
readonly evidenceScope?: string;
|
|
56
|
+
/** The playbook that asked, recorded in the persisted evidence frontmatter. */
|
|
57
|
+
readonly playbookRef?: string;
|
|
45
58
|
}
|
|
46
59
|
export interface ResearchTaskResult {
|
|
47
60
|
/** The agent's final message — the evidence, in prose, with the sources it says it read. */
|
|
@@ -58,11 +71,13 @@ export interface ResearchTaskResult {
|
|
|
58
71
|
readonly deniedPermissionCount?: number;
|
|
59
72
|
readonly permissionDecisions?: CodingAgent_RunTaskOutput['permissionDecisions'];
|
|
60
73
|
/**
|
|
61
|
-
* Paths the agent reported touching.
|
|
62
|
-
* fact in the record rather than an assumption about the configuration.
|
|
74
|
+
* Paths the agent reported touching. Every entry must sit inside the evidence store — carried so
|
|
75
|
+
* that claim is an observed fact in the record rather than an assumption about the configuration.
|
|
63
76
|
*/
|
|
64
77
|
readonly reportedFileLocations: readonly string[];
|
|
65
78
|
readonly elapsedMs: number;
|
|
79
|
+
/** Where the final brief was persisted — the companion-side backstop write, always present. */
|
|
80
|
+
readonly persistedEvidencePath: string;
|
|
66
81
|
}
|
|
67
82
|
/** The research agent is not registered, or the profile it names is absent. Named so a transport answers 409 rather than 500. */
|
|
68
83
|
export declare class ResearchAgentUnavailableError extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"research-agent-dispatch.companion.service.d.ts","sourceRoot":"","sources":["../../../../../src/claude-cli/services/research-agent-dispatch.companion.service.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"research-agent-dispatch.companion.service.d.ts","sourceRoot":"","sources":["../../../../../src/claude-cli/services/research-agent-dispatch.companion.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EACL,0BAA0B,EAC1B,aAAa,EAEb,KAAK,oBAAoB,EAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAIL,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACvB,MAAM,sCAAsC,CAAC;AAI9C,OAAO,KAAK,E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G,OAAO,CAAC,kBAAkB,CAAC;CAiHxF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Research dispatch — the evidence half of the ACP lane. Read-only toward the workspace, except
|
|
3
|
+
* for its own evidence store.
|
|
3
4
|
*
|
|
4
5
|
* ## Why this is a SECOND WRAPPER and not a mode on the coding one
|
|
5
6
|
*
|
|
@@ -10,15 +11,19 @@
|
|
|
10
11
|
* nothing and returns text. So research is a sibling over the same runner rather than a branch
|
|
11
12
|
* inside a service whose every other line is about attributing writes.
|
|
12
13
|
*
|
|
13
|
-
* ##
|
|
14
|
+
* ## The confinement, and it is TWO independent things
|
|
14
15
|
*
|
|
15
|
-
* 1. The `claude-code-acp-research` profile's `
|
|
16
|
-
* non-mutating tool kinds (`read`, `search`, `fetch`, `think`) — never `
|
|
17
|
-
* never
|
|
18
|
-
*
|
|
16
|
+
* 1. The `claude-code-acp-research` profile's `AUTO_ACCEPT_EDITS` ceiling admits the protocol's
|
|
17
|
+
* non-mutating tool kinds (`read`, `search`, `fetch`, `think`) plus `edit` — never `execute`,
|
|
18
|
+
* never the unclassified `other`. (It was `AUTO_ACCEPT_READS` until 2026-09-04, when three lost
|
|
19
|
+
* compliance runs showed evidence living only in run memory cannot be leveraged or recovered;
|
|
20
|
+
* the edit admission exists solely so findings persist as they are gathered.)
|
|
21
|
+
* 2. This dispatch supplies a location predicate that admits ONLY the evidence store
|
|
22
|
+
* (`specifications/research-evidence/`) and refuses every other path — built by the same
|
|
23
|
+
* `buildApplicationCodingTaskLocationPredicate` the coding lane trusts. The runner applies it to
|
|
19
24
|
* any permission request declaring locations, whatever its kind, and separately gates the
|
|
20
|
-
* client-side write RPC. So a web read (which declares no location) passes
|
|
21
|
-
* or write does not.
|
|
25
|
+
* client-side write RPC. So a web read (which declares no location) passes, an evidence-store
|
|
26
|
+
* write passes, and any other filesystem read or write does not.
|
|
22
27
|
*
|
|
23
28
|
* Neither alone is the guarantee. The ceiling stops the kinds; the predicate stops the paths.
|
|
24
29
|
*
|
|
@@ -47,6 +52,8 @@ import { CodingAgent_StopReason, } from '@wildo-ai/external-connectors-models';
|
|
|
47
52
|
import { ErrorCustomMessageReference, ErrorType } from '@wildo-ai/saas-models';
|
|
48
53
|
import { COMPANION_SERVICE_TYPES } from '../../core/inject/models/service-types.js';
|
|
49
54
|
import { APPLICATION_RESEARCH_AGENT_REF } from '../../meta-workflows/models/application-research-agent.actors-system.definitions.js';
|
|
55
|
+
import { buildApplicationCodingTaskLocationPredicate } from './coding-agent-dispatch.companion.service.js';
|
|
56
|
+
import { RESEARCH_EVIDENCE_RELATIVE_ROOT, composeEvidenceStoreInstruction, resolveResearchEvidenceDirectory, writeFinalEvidenceRecord, } from './research-evidence-store.companion.js';
|
|
50
57
|
/** The research agent is not registered, or the profile it names is absent. Named so a transport answers 409 rather than 500. */
|
|
51
58
|
export class ResearchAgentUnavailableError extends Error {
|
|
52
59
|
}
|
|
@@ -83,29 +90,69 @@ let ResearchAgentDispatchCompanionService = class ResearchAgentDispatchCompanion
|
|
|
83
90
|
throw new ResearchAgentUnavailableError(`The research agent "${APPLICATION_RESEARCH_AGENT_REF}" is not registered. It is registered at companion startup; `
|
|
84
91
|
+ 'a companion started before it existed needs a restart.');
|
|
85
92
|
}
|
|
93
|
+
const evidenceDirectory = resolveResearchEvidenceDirectory(this.companionContext.saasRoot, request.evidenceScope ?? 'adhoc');
|
|
94
|
+
const promptWithStore = [objective, '', composeEvidenceStoreInstruction(evidenceDirectory)].join('\n');
|
|
86
95
|
const invocation = {
|
|
87
96
|
agentRef: APPLICATION_RESEARCH_AGENT_REF,
|
|
88
97
|
initiator: {},
|
|
89
98
|
invocationContext: [],
|
|
90
|
-
input: { prompt:
|
|
99
|
+
input: { prompt: promptWithStore },
|
|
91
100
|
output: { finalMessage: '', stopReason: CodingAgent_StopReason.END_TURN },
|
|
92
101
|
executionContext: { callTimestamp: new Date().toISOString() },
|
|
93
102
|
artifactBindings: [],
|
|
94
103
|
};
|
|
95
104
|
const startedAtMs = Date.now();
|
|
96
|
-
|
|
105
|
+
const startedAtIso = new Date(startedAtMs).toISOString();
|
|
106
|
+
this.logDebug('Research task starting', { objectiveLength: objective.length, evidenceScope: request.evidenceScope });
|
|
97
107
|
const response = await this.agentsService.invokeAgent(invocation, undefined, {
|
|
98
108
|
workspaceRootPath: this.companionContext.saasRoot,
|
|
99
109
|
/*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
110
|
+
* ONE writable island: the evidence store. The predicate is the SAME builder the coding lane
|
|
111
|
+
* trusts (symlink-aware, boundary-matched), scoped to `specifications/research-evidence/` and
|
|
112
|
+
* nothing else — so the agent can consolidate findings to disk as it researches (evidence
|
|
113
|
+
* that survives an interrupted turn) and read prior rounds' files, while the rest of the
|
|
114
|
+
* workspace stays refused. A web fetch declares no location and is unaffected. This replaced
|
|
115
|
+
* the original refuse-every-path predicate on 2026-09-04, when three lost compliance runs
|
|
116
|
+
* showed that evidence living only in run memory cannot be leveraged or recovered.
|
|
103
117
|
*/
|
|
104
|
-
isPermittedCodingLocation: (
|
|
118
|
+
isPermittedCodingLocation: buildApplicationCodingTaskLocationPredicate(this.companionContext.saasRoot, [RESEARCH_EVIDENCE_RELATIVE_ROOT], []),
|
|
105
119
|
});
|
|
106
120
|
const output = response.output;
|
|
107
121
|
const evidence = typeof output?.finalMessage === 'string' ? output.finalMessage : '';
|
|
108
122
|
const stopReason = output?.stopReason ?? CodingAgent_StopReason.UNRECOGNISED;
|
|
123
|
+
const elapsedMs = Date.now() - startedAtMs;
|
|
124
|
+
/*
|
|
125
|
+
* A CANCELLED turn is not a completed one and its partial prose is not evidence — the same
|
|
126
|
+
* refusal the coding lane makes, for the same reason: a truncated answer reads exactly like a
|
|
127
|
+
* short one. Checked BEFORE the backstop write, so a cancelled turn's partial FINAL MESSAGE is
|
|
128
|
+
* never persisted as a completed record — whatever the agent already consolidated to the store
|
|
129
|
+
* during the turn stands on its own, file by file, and is exactly what incremental persistence
|
|
130
|
+
* is for.
|
|
131
|
+
*/
|
|
132
|
+
if (stopReason === CodingAgent_StopReason.CANCELLED) {
|
|
133
|
+
throw new Error(`Research task was cancelled after ${elapsedMs}ms; its partial answer is not evidence.`);
|
|
134
|
+
}
|
|
135
|
+
// The companion-side backstop: the completed brief lands on disk with its provenance even when
|
|
136
|
+
// the agent consolidated nothing itself. Best-effort by construction — a store write failing
|
|
137
|
+
// must not turn a completed research turn into a failed one.
|
|
138
|
+
let persistedEvidencePath = '';
|
|
139
|
+
try {
|
|
140
|
+
persistedEvidencePath = writeFinalEvidenceRecord({
|
|
141
|
+
evidenceDirectoryAbsolutePath: evidenceDirectory,
|
|
142
|
+
objective,
|
|
143
|
+
evidence,
|
|
144
|
+
stopReason,
|
|
145
|
+
startedAtIso,
|
|
146
|
+
elapsedMs,
|
|
147
|
+
...(request.playbookRef ? { playbookRef: request.playbookRef } : {}),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
catch (persistError) {
|
|
151
|
+
this.logger.warn('Research evidence backstop write failed; the returned brief is the only copy', {
|
|
152
|
+
evidenceDirectory,
|
|
153
|
+
failure: persistError instanceof Error ? persistError.message : String(persistError),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
109
156
|
const result = {
|
|
110
157
|
evidence,
|
|
111
158
|
stopReason,
|
|
@@ -115,22 +162,16 @@ let ResearchAgentDispatchCompanionService = class ResearchAgentDispatchCompanion
|
|
|
115
162
|
...(output?.deniedPermissionCount !== undefined ? { deniedPermissionCount: output.deniedPermissionCount } : {}),
|
|
116
163
|
...(output?.permissionDecisions !== undefined ? { permissionDecisions: output.permissionDecisions } : {}),
|
|
117
164
|
reportedFileLocations: output?.reportedFileLocations ?? [],
|
|
118
|
-
elapsedMs
|
|
165
|
+
elapsedMs,
|
|
166
|
+
persistedEvidencePath,
|
|
119
167
|
};
|
|
120
|
-
/*
|
|
121
|
-
* A CANCELLED turn is not a completed one and its partial prose is not evidence — the same
|
|
122
|
-
* refusal the coding lane makes, for the same reason: a truncated answer reads exactly like a
|
|
123
|
-
* short one.
|
|
124
|
-
*/
|
|
125
|
-
if (stopReason === CodingAgent_StopReason.CANCELLED) {
|
|
126
|
-
throw new Error(`Research task was cancelled after ${result.elapsedMs}ms; its partial answer is not evidence.`);
|
|
127
|
-
}
|
|
128
168
|
this.logDebug('Research task finished', {
|
|
129
169
|
stopReason,
|
|
130
|
-
elapsedMs
|
|
170
|
+
elapsedMs,
|
|
131
171
|
evidenceLength: evidence.length,
|
|
132
172
|
deniedPermissionCount: result.deniedPermissionCount,
|
|
133
173
|
reportedFileLocations: result.reportedFileLocations.length,
|
|
174
|
+
persistedEvidencePath,
|
|
134
175
|
});
|
|
135
176
|
return result;
|
|
136
177
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"research-agent-dispatch.companion.service.js","sourceRoot":"","sources":["../../../../../src/claude-cli/services/research-agent-dispatch.companion.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAIL,sBAAsB,GAGvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,SAAS,EAAqC,MAAM,uBAAuB,CAAC;AAElH,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,kFAAkF,CAAC;AAoClI,iIAAiI;AACjI,MAAM,OAAO,6BAA8B,SAAQ,KAAK;CAAG;AAGpD,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAIM;IACa;IACC;IACC;IANpD,QAAQ,CAA+D;IAExF,YACsD,MAAqB,EACR,YAAwC,EACvC,aAAmC,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AAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW;SACpC,CAAC;QAEF;;;;WAIG;QACH,IAAI,UAAU,KAAK,sBAAsB,CAAC,SAAS,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,SAAS,yCAAyC,CAAC,CAAC;QAClH,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,wBAAwB,EAAE;YACtC,UAAU;YACV,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,cAAc,EAAE,QAAQ,CAAC,MAAM;YAC/B,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;YACnD,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,CAAC,MAAM;SAC3D,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AA7FY,qCAAqC;IADjD,UAAU,EAAE;IAKR,WAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACjC,WAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAC9C,WAAA,MAAM,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAA;IAC/C,WAAA,MAAM,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAA;qCAHW,aAAa;QACM,0BAA0B;GALhG,qCAAqC,CA6FjD","sourcesContent":["/**\n * Read-only research dispatch — the evidence half of the ACP lane.\n *\n * ## Why this is a SECOND WRAPPER and not a mode on the coding one\n *\n * The generic session runner (`runACPCodingSession`, engine) is already task-agnostic: command, cwd,\n * prompt, permission ceiling, a location predicate, an event sink. Everything that makes the coding\n * dispatch a CODING dispatch — the typed task contract, the git change-set capture, the mutation\n * scope, the single-flight lock — sits in that wrapper, and none of it applies to a run that mutates\n * nothing and returns text. So research is a sibling over the same runner rather than a branch\n * inside a service whose every other line is about attributing writes.\n *\n * ## What makes it read-only, and it is TWO independent things\n *\n * 1. The `claude-code-acp-research` profile's `AUTO_ACCEPT_READS` ceiling admits only the protocol's\n * non-mutating tool kinds (`read`, `search`, `fetch`, `think`) — never `edit`/`delete`/`move`,\n * never `execute`, never the unclassified `other`.\n * 2. This dispatch supplies a location predicate that refuses EVERY path. The runner applies it to\n * any permission request declaring locations, whatever its kind, and separately gates the\n * client-side write RPC. So a web read (which declares no location) passes and a filesystem read\n * or write does not.\n *\n * Neither alone is the guarantee. The ceiling stops the kinds; the predicate stops the paths.\n *\n * ## Measured before it was built (2026-08-29)\n *\n * Under `PROMPT_ALWAYS` with every location refused, a live probe asking a public-web pricing\n * question had both `WebFetch` and `WebSearch` arrive as `toolKind: 'fetch'` and be refused; the\n * agent ended its turn declining to guess from memory. Re-run under `AUTO_ACCEPT_READS`, the same\n * probe fetched the page and returned the figure with its source URL, `reportedFileLocations: []`.\n */\n\nimport { inject, injectable } from 'inversify';\nimport {\n ErrorBuilderBackendService,\n LoggerService,\n SAAS_SERVICE_TYPES,\n type AgentsBackendService,\n} from '@wildo-ai/saas-backend-lib';\nimport {\n CodingAgent_OperationContext_BaseSchema,\n CodingAgent_RunTaskInputSchema,\n CodingAgent_RunTaskOutputSchema,\n CodingAgent_StopReason,\n type CodingAgent_RunTaskOutput,\n type CodingAgent_Usage,\n} from '@wildo-ai/external-connectors-models';\nimport { ErrorCustomMessageReference, ErrorType, type FlowsActors_Agent_Invocation } from '@wildo-ai/saas-models';\n\nimport { COMPANION_SERVICE_TYPES } from '../../core/inject/models/service-types';\nimport type { CompanionContext } from '../../core/context/companion-context';\nimport { APPLICATION_RESEARCH_AGENT_REF } from '../../meta-workflows/models/application-research-agent.actors-system.definitions';\n\n/** One research objective, composed by whatever is asking — a playbook, a choreography, an operator. */\nexport interface ResearchTaskRequest {\n /**\n * What to find out, in the requester's own words.\n *\n * Deliberately free text rather than a structured query: the objective is INVENTED per run and\n * adapted to what an earlier round found, which is the whole reason a research step is an agent\n * and not a search API. Code gates the KIND of work and its bounds; it never gates the content.\n */\n readonly objective: string;\n}\n\nexport interface ResearchTaskResult {\n /** The agent's final message — the evidence, in prose, with the sources it says it read. */\n readonly evidence: string;\n readonly stopReason: CodingAgent_StopReason;\n readonly usage?: CodingAgent_Usage;\n /**\n * Permission requests the runner refused, with the reason.\n *\n * Carried because a research answer that looks thin has two very different causes — the agent\n * found little, or the ceiling refused the tool it needed — and they are indistinguishable from\n * the prose alone.\n */\n readonly deniedPermissionCount?: number;\n readonly permissionDecisions?: CodingAgent_RunTaskOutput['permissionDecisions'];\n /**\n * Paths the agent reported touching. MUST be empty; carried so that \"it was empty\" is an observed\n * fact in the record rather than an assumption about the configuration.\n */\n readonly reportedFileLocations: readonly string[];\n readonly elapsedMs: number;\n}\n\n/** The research agent is not registered, or the profile it names is absent. Named so a transport answers 409 rather than 500. */\nexport class ResearchAgentUnavailableError extends Error {}\n\n@injectable()\nexport class ResearchAgentDispatchCompanionService {\n private readonly logDebug: (message: string, context?: Record<string, unknown>) => void;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.ErrorBuilderService) private readonly errorBuilder: ErrorBuilderBackendService,\n @inject(SAAS_SERVICE_TYPES.AgentsBackendService) private readonly agentsService: AgentsBackendService,\n @inject(COMPANION_SERVICE_TYPES.CompanionContext) private readonly companionContext: CompanionContext,\n ) {\n this.logDebug = this.logger.debugByType('ResearchAgentDispatchCompanionService');\n this.logger.setDebugTypeLogging('ResearchAgentDispatchCompanionService', true);\n }\n\n /**\n * Run one research objective and return what the agent found.\n *\n * No lock, no change set, no reconciliation — a run that cannot mutate has nothing to attribute and\n * nothing to recover. Several research lanes may therefore run concurrently, which is what makes a\n * breadth-first fan-out possible at all.\n */\n public async runResearchTask(request: ResearchTaskRequest): Promise<ResearchTaskResult> {\n const objective = request.objective.trim();\n if (objective.length === 0) {\n throw this.errorBuilder.buildError(ErrorType.VALIDATION, undefined, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: 'A research task needs an objective; an empty one would spend a turn to learn nothing.' },\n });\n }\n if (this.agentsService.getAgent(APPLICATION_RESEARCH_AGENT_REF) === undefined) {\n throw new ResearchAgentUnavailableError(\n `The research agent \"${APPLICATION_RESEARCH_AGENT_REF}\" is not registered. It is registered at companion startup; `\n + 'a companion started before it existed needs a restart.',\n );\n }\n\n const invocation: FlowsActors_Agent_Invocation<\n typeof CodingAgent_RunTaskInputSchema,\n typeof CodingAgent_RunTaskOutputSchema,\n typeof CodingAgent_OperationContext_BaseSchema\n > = {\n agentRef: APPLICATION_RESEARCH_AGENT_REF,\n initiator: {},\n invocationContext: [],\n input: { prompt: objective },\n output: { finalMessage: '', stopReason: CodingAgent_StopReason.END_TURN },\n executionContext: { callTimestamp: new Date().toISOString() },\n artifactBindings: [],\n };\n\n const startedAtMs = Date.now();\n this.logDebug('Research task starting', { objectiveLength: objective.length });\n const response = await this.agentsService.invokeAgent(invocation, undefined, {\n workspaceRootPath: this.companionContext.saasRoot,\n /*\n * EVERY path refused. The second of the two independent guarantees (see the file header): the\n * ceiling decides which tool KINDS may run, this decides which PATHS they may name, and a\n * research run authorises none. A web fetch declares no location and is unaffected.\n */\n isPermittedCodingLocation: () => false,\n });\n\n const output = response.output as Partial<CodingAgent_RunTaskOutput> | undefined;\n const evidence = typeof output?.finalMessage === 'string' ? output.finalMessage : '';\n const stopReason = output?.stopReason ?? CodingAgent_StopReason.UNRECOGNISED;\n const result: ResearchTaskResult = {\n evidence,\n stopReason,\n ...(((response.executionContext as { usage?: CodingAgent_Usage } | undefined)?.usage)\n ? { usage: (response.executionContext as { usage?: CodingAgent_Usage }).usage }\n : {}),\n ...(output?.deniedPermissionCount !== undefined ? { deniedPermissionCount: output.deniedPermissionCount } : {}),\n ...(output?.permissionDecisions !== undefined ? { permissionDecisions: output.permissionDecisions } : {}),\n reportedFileLocations: output?.reportedFileLocations ?? [],\n elapsedMs: Date.now() - startedAtMs,\n };\n\n /*\n * A CANCELLED turn is not a completed one and its partial prose is not evidence — the same\n * refusal the coding lane makes, for the same reason: a truncated answer reads exactly like a\n * short one.\n */\n if (stopReason === CodingAgent_StopReason.CANCELLED) {\n throw new Error(`Research task was cancelled after ${result.elapsedMs}ms; its partial answer is not evidence.`);\n }\n this.logDebug('Research task finished', {\n stopReason,\n elapsedMs: result.elapsedMs,\n evidenceLength: evidence.length,\n deniedPermissionCount: result.deniedPermissionCount,\n reportedFileLocations: result.reportedFileLocations.length,\n });\n return result;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"research-agent-dispatch.companion.service.js","sourceRoot":"","sources":["../../../../../src/claude-cli/services/research-agent-dispatch.companion.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;;;;;;;;;;;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAIL,sBAAsB,GAGvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,SAAS,EAAqC,MAAM,uBAAuB,CAAC;AAElH,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,kFAAkF,CAAC;AAClI,OAAO,EAAE,2CAA2C,EAAE,MAAM,2CAA2C,CAAC;AACxG,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,EAC/B,gCAAgC,EAChC,wBAAwB,GACzB,MAAM,qCAAqC,CAAC;AA8C7C,iIAAiI;AACjI,MAAM,OAAO,6BAA8B,SAAQ,KAAK;CAAG;AAGpD,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAIM;IACa;IACC;IACC;IANpD,QAAQ,CAA+D;IAExF,YACsD,MAAqB,EACR,YAAwC,EACvC,aAAmC,EAClC,gBAAkC;QAHjD,WAAM,GAAN,MAAM,CAAe;QACR,iBAAY,GAAZ,YAAY,CAA4B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tB,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,wBAAwB,EAAE;YACtC,UAAU;YACV,SAAS;YACT,cAAc,EAAE,QAAQ,CAAC,MAAM;YAC/B,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;YACnD,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,CAAC,MAAM;YAC1D,qBAAqB;SACtB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AArIY,qCAAqC;IADjD,UAAU,EAAE;IAKR,WAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACjC,WAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAC9C,WAAA,MAAM,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,CAAA;IAC/C,WAAA,MAAM,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAA;qCAHW,aAAa;QACM,0BAA0B;GALhG,qCAAqC,CAqIjD","sourcesContent":["/**\n * Research dispatch — the evidence half of the ACP lane. Read-only toward the workspace, except\n * for its own evidence store.\n *\n * ## Why this is a SECOND WRAPPER and not a mode on the coding one\n *\n * The generic session runner (`runACPCodingSession`, engine) is already task-agnostic: command, cwd,\n * prompt, permission ceiling, a location predicate, an event sink. Everything that makes the coding\n * dispatch a CODING dispatch — the typed task contract, the git change-set capture, the mutation\n * scope, the single-flight lock — sits in that wrapper, and none of it applies to a run that mutates\n * nothing and returns text. So research is a sibling over the same runner rather than a branch\n * inside a service whose every other line is about attributing writes.\n *\n * ## The confinement, and it is TWO independent things\n *\n * 1. The `claude-code-acp-research` profile's `AUTO_ACCEPT_EDITS` ceiling admits the protocol's\n * non-mutating tool kinds (`read`, `search`, `fetch`, `think`) plus `edit` — never `execute`,\n * never the unclassified `other`. (It was `AUTO_ACCEPT_READS` until 2026-09-04, when three lost\n * compliance runs showed evidence living only in run memory cannot be leveraged or recovered;\n * the edit admission exists solely so findings persist as they are gathered.)\n * 2. This dispatch supplies a location predicate that admits ONLY the evidence store\n * (`specifications/research-evidence/`) and refuses every other path — built by the same\n * `buildApplicationCodingTaskLocationPredicate` the coding lane trusts. The runner applies it to\n * any permission request declaring locations, whatever its kind, and separately gates the\n * client-side write RPC. So a web read (which declares no location) passes, an evidence-store\n * write passes, and any other filesystem read or write does not.\n *\n * Neither alone is the guarantee. The ceiling stops the kinds; the predicate stops the paths.\n *\n * ## Measured before it was built (2026-08-29)\n *\n * Under `PROMPT_ALWAYS` with every location refused, a live probe asking a public-web pricing\n * question had both `WebFetch` and `WebSearch` arrive as `toolKind: 'fetch'` and be refused; the\n * agent ended its turn declining to guess from memory. Re-run under `AUTO_ACCEPT_READS`, the same\n * probe fetched the page and returned the figure with its source URL, `reportedFileLocations: []`.\n */\n\nimport { inject, injectable } from 'inversify';\nimport {\n ErrorBuilderBackendService,\n LoggerService,\n SAAS_SERVICE_TYPES,\n type AgentsBackendService,\n} from '@wildo-ai/saas-backend-lib';\nimport {\n CodingAgent_OperationContext_BaseSchema,\n CodingAgent_RunTaskInputSchema,\n CodingAgent_RunTaskOutputSchema,\n CodingAgent_StopReason,\n type CodingAgent_RunTaskOutput,\n type CodingAgent_Usage,\n} from '@wildo-ai/external-connectors-models';\nimport { ErrorCustomMessageReference, ErrorType, type FlowsActors_Agent_Invocation } from '@wildo-ai/saas-models';\n\nimport { COMPANION_SERVICE_TYPES } from '../../core/inject/models/service-types';\nimport type { CompanionContext } from '../../core/context/companion-context';\nimport { APPLICATION_RESEARCH_AGENT_REF } from '../../meta-workflows/models/application-research-agent.actors-system.definitions';\nimport { buildApplicationCodingTaskLocationPredicate } from './coding-agent-dispatch.companion.service';\nimport {\n RESEARCH_EVIDENCE_RELATIVE_ROOT,\n composeEvidenceStoreInstruction,\n resolveResearchEvidenceDirectory,\n writeFinalEvidenceRecord,\n} from './research-evidence-store.companion';\n\n/** One research objective, composed by whatever is asking — a playbook, a choreography, an operator. */\nexport interface ResearchTaskRequest {\n /**\n * What to find out, in the requester's own words.\n *\n * Deliberately free text rather than a structured query: the objective is INVENTED per run and\n * adapted to what an earlier round found, which is the whole reason a research step is an agent\n * and not a search API. Code gates the KIND of work and its bounds; it never gates the content.\n */\n readonly objective: string;\n /**\n * Which investigation this task belongs to — normally the composite playbook ref. Names the\n * evidence-store directory every round of that investigation consolidates into. Absent for an\n * operator's ad-hoc question, which lands under `adhoc`.\n */\n readonly evidenceScope?: string;\n /** The playbook that asked, recorded in the persisted evidence frontmatter. */\n readonly playbookRef?: string;\n}\n\nexport interface ResearchTaskResult {\n /** The agent's final message — the evidence, in prose, with the sources it says it read. */\n readonly evidence: string;\n readonly stopReason: CodingAgent_StopReason;\n readonly usage?: CodingAgent_Usage;\n /**\n * Permission requests the runner refused, with the reason.\n *\n * Carried because a research answer that looks thin has two very different causes — the agent\n * found little, or the ceiling refused the tool it needed — and they are indistinguishable from\n * the prose alone.\n */\n readonly deniedPermissionCount?: number;\n readonly permissionDecisions?: CodingAgent_RunTaskOutput['permissionDecisions'];\n /**\n * Paths the agent reported touching. Every entry must sit inside the evidence store — carried so\n * that claim is an observed fact in the record rather than an assumption about the configuration.\n */\n readonly reportedFileLocations: readonly string[];\n readonly elapsedMs: number;\n /** Where the final brief was persisted — the companion-side backstop write, always present. */\n readonly persistedEvidencePath: string;\n}\n\n/** The research agent is not registered, or the profile it names is absent. Named so a transport answers 409 rather than 500. */\nexport class ResearchAgentUnavailableError extends Error {}\n\n@injectable()\nexport class ResearchAgentDispatchCompanionService {\n private readonly logDebug: (message: string, context?: Record<string, unknown>) => void;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.ErrorBuilderService) private readonly errorBuilder: ErrorBuilderBackendService,\n @inject(SAAS_SERVICE_TYPES.AgentsBackendService) private readonly agentsService: AgentsBackendService,\n @inject(COMPANION_SERVICE_TYPES.CompanionContext) private readonly companionContext: CompanionContext,\n ) {\n this.logDebug = this.logger.debugByType('ResearchAgentDispatchCompanionService');\n this.logger.setDebugTypeLogging('ResearchAgentDispatchCompanionService', true);\n }\n\n /**\n * Run one research objective and return what the agent found.\n *\n * No lock, no change set, no reconciliation — a run that cannot mutate has nothing to attribute and\n * nothing to recover. Several research lanes may therefore run concurrently, which is what makes a\n * breadth-first fan-out possible at all.\n */\n public async runResearchTask(request: ResearchTaskRequest): Promise<ResearchTaskResult> {\n const objective = request.objective.trim();\n if (objective.length === 0) {\n throw this.errorBuilder.buildError(ErrorType.VALIDATION, undefined, {\n customMessageReference: ErrorCustomMessageReference.VALIDATION,\n context: { message: 'A research task needs an objective; an empty one would spend a turn to learn nothing.' },\n });\n }\n if (this.agentsService.getAgent(APPLICATION_RESEARCH_AGENT_REF) === undefined) {\n throw new ResearchAgentUnavailableError(\n `The research agent \"${APPLICATION_RESEARCH_AGENT_REF}\" is not registered. It is registered at companion startup; `\n + 'a companion started before it existed needs a restart.',\n );\n }\n\n const evidenceDirectory = resolveResearchEvidenceDirectory(this.companionContext.saasRoot, request.evidenceScope ?? 'adhoc');\n const promptWithStore = [objective, '', composeEvidenceStoreInstruction(evidenceDirectory)].join('\\n');\n\n const invocation: FlowsActors_Agent_Invocation<\n typeof CodingAgent_RunTaskInputSchema,\n typeof CodingAgent_RunTaskOutputSchema,\n typeof CodingAgent_OperationContext_BaseSchema\n > = {\n agentRef: APPLICATION_RESEARCH_AGENT_REF,\n initiator: {},\n invocationContext: [],\n input: { prompt: promptWithStore },\n output: { finalMessage: '', stopReason: CodingAgent_StopReason.END_TURN },\n executionContext: { callTimestamp: new Date().toISOString() },\n artifactBindings: [],\n };\n\n const startedAtMs = Date.now();\n const startedAtIso = new Date(startedAtMs).toISOString();\n this.logDebug('Research task starting', { objectiveLength: objective.length, evidenceScope: request.evidenceScope });\n const response = await this.agentsService.invokeAgent(invocation, undefined, {\n workspaceRootPath: this.companionContext.saasRoot,\n /*\n * ONE writable island: the evidence store. The predicate is the SAME builder the coding lane\n * trusts (symlink-aware, boundary-matched), scoped to `specifications/research-evidence/` and\n * nothing else — so the agent can consolidate findings to disk as it researches (evidence\n * that survives an interrupted turn) and read prior rounds' files, while the rest of the\n * workspace stays refused. A web fetch declares no location and is unaffected. This replaced\n * the original refuse-every-path predicate on 2026-09-04, when three lost compliance runs\n * showed that evidence living only in run memory cannot be leveraged or recovered.\n */\n isPermittedCodingLocation: buildApplicationCodingTaskLocationPredicate(\n this.companionContext.saasRoot,\n [RESEARCH_EVIDENCE_RELATIVE_ROOT],\n [],\n ),\n });\n\n const output = response.output as Partial<CodingAgent_RunTaskOutput> | undefined;\n const evidence = typeof output?.finalMessage === 'string' ? output.finalMessage : '';\n const stopReason = output?.stopReason ?? CodingAgent_StopReason.UNRECOGNISED;\n const elapsedMs = Date.now() - startedAtMs;\n\n /*\n * A CANCELLED turn is not a completed one and its partial prose is not evidence — the same\n * refusal the coding lane makes, for the same reason: a truncated answer reads exactly like a\n * short one. Checked BEFORE the backstop write, so a cancelled turn's partial FINAL MESSAGE is\n * never persisted as a completed record — whatever the agent already consolidated to the store\n * during the turn stands on its own, file by file, and is exactly what incremental persistence\n * is for.\n */\n if (stopReason === CodingAgent_StopReason.CANCELLED) {\n throw new Error(`Research task was cancelled after ${elapsedMs}ms; its partial answer is not evidence.`);\n }\n\n // The companion-side backstop: the completed brief lands on disk with its provenance even when\n // the agent consolidated nothing itself. Best-effort by construction — a store write failing\n // must not turn a completed research turn into a failed one.\n let persistedEvidencePath = '';\n try {\n persistedEvidencePath = writeFinalEvidenceRecord({\n evidenceDirectoryAbsolutePath: evidenceDirectory,\n objective,\n evidence,\n stopReason,\n startedAtIso,\n elapsedMs,\n ...(request.playbookRef ? { playbookRef: request.playbookRef } : {}),\n });\n } catch (persistError) {\n this.logger.warn('Research evidence backstop write failed; the returned brief is the only copy', {\n evidenceDirectory,\n failure: persistError instanceof Error ? persistError.message : String(persistError),\n });\n }\n\n const result: ResearchTaskResult = {\n evidence,\n stopReason,\n ...(((response.executionContext as { usage?: CodingAgent_Usage } | undefined)?.usage)\n ? { usage: (response.executionContext as { usage?: CodingAgent_Usage }).usage }\n : {}),\n ...(output?.deniedPermissionCount !== undefined ? { deniedPermissionCount: output.deniedPermissionCount } : {}),\n ...(output?.permissionDecisions !== undefined ? { permissionDecisions: output.permissionDecisions } : {}),\n reportedFileLocations: output?.reportedFileLocations ?? [],\n elapsedMs,\n persistedEvidencePath,\n };\n this.logDebug('Research task finished', {\n stopReason,\n elapsedMs,\n evidenceLength: evidence.length,\n deniedPermissionCount: result.deniedPermissionCount,\n reportedFileLocations: result.reportedFileLocations.length,\n persistedEvidencePath,\n });\n return result;\n }\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The research evidence store — where a research agent's findings become FILES.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists (2026-09-04)
|
|
5
|
+
*
|
|
6
|
+
* Research evidence used to live in exactly one place: the run's in-memory step results, feeding
|
|
7
|
+
* the next child's brief and dying with the run. Three consecutive compliance runs proved what that
|
|
8
|
+
* costs — a 56-minute, 14-children evidence body lost to a quota cut, then two relaunches lost to
|
|
9
|
+
* an expired login — and the run-level checkpoint only protects the SCHEDULING state, not the
|
|
10
|
+
* knowledge. The store is the knowledge half: evidence lands on disk as it is gathered, survives
|
|
11
|
+
* any death, and is READ BACK by later runs so they extend prior research instead of re-buying it.
|
|
12
|
+
*
|
|
13
|
+
* ## Where, and why it is COMMITTABLE
|
|
14
|
+
*
|
|
15
|
+
* `<application>/specifications/research-evidence/<scope>/` — inside the application repository,
|
|
16
|
+
* outside `specifications/src/`, so it enters no TypeScript program and no family classification.
|
|
17
|
+
* Committable on purpose: source-attributed research is knowledge the posture artifacts cite, and
|
|
18
|
+
* "delete it and re-run" costs hours and a quota window — git is where things that must survive a
|
|
19
|
+
* re-clone live (`one-source-of-truth.md`). Acceptance stays a human commit, like every other
|
|
20
|
+
* working edit an agent lands.
|
|
21
|
+
*
|
|
22
|
+
* ## Who writes
|
|
23
|
+
*
|
|
24
|
+
* TWO writers, layered:
|
|
25
|
+
* 1. The research AGENT, incrementally, during its turn — the profile's location predicate admits
|
|
26
|
+
* exactly this directory (built by the same `buildApplicationCodingTaskLocationPredicate` the
|
|
27
|
+
* coding lane trusts), so a mid-turn death still leaves everything already consolidated.
|
|
28
|
+
* 2. The COMPANION, once per completed task — `writeFinalEvidenceRecord` persists the returned
|
|
29
|
+
* brief with its provenance frontmatter, so a completed turn is on disk even if the agent wrote
|
|
30
|
+
* nothing itself.
|
|
31
|
+
*/
|
|
32
|
+
/** Application-relative root of the store. Also the ONLY path prefix the research predicate admits. */
|
|
33
|
+
export declare const RESEARCH_EVIDENCE_RELATIVE_ROOT = "specifications/research-evidence";
|
|
34
|
+
/**
|
|
35
|
+
* A scope names the investigation a set of evidence files belongs to — normally the composite
|
|
36
|
+
* playbook ref (`top_down.compliance-analysis`), so every child of one choreography, across every
|
|
37
|
+
* run of it, consolidates into one directory.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveResearchEvidenceDirectory(saasRoot: string, scope: string): string;
|
|
40
|
+
/** Directory-safe scope: lowercase, dots and separators to hyphens, nothing traversal-shaped. */
|
|
41
|
+
export declare function slugifyEvidenceScope(scope: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* The prompt block that turns "you may write here" into "you consolidate here".
|
|
44
|
+
*
|
|
45
|
+
* Appended to every research objective by the dispatch, never authored per playbook: the store is a
|
|
46
|
+
* property of the LANE, and a convention restated per method drifts. The instruction is explicit
|
|
47
|
+
* that the directory is the ONLY writable location — the predicate enforces it, but an agent told
|
|
48
|
+
* the boundary spends its turn researching instead of discovering refusals.
|
|
49
|
+
*
|
|
50
|
+
* ## Why it also carries a SOURCE-NEUTRALITY clause (2026-09-05)
|
|
51
|
+
*
|
|
52
|
+
* A compliance researcher enumerating "which regimes apply" reaches for proprietary security
|
|
53
|
+
* certification and attestation standards unprompted, alongside the public law that is the actual
|
|
54
|
+
* subject. Public law is fine — statutes and regulations are quotable. The proprietary standards are
|
|
55
|
+
* not: their control catalogues and identifiers are licensed material, and `CLAUDE.md` confines every
|
|
56
|
+
* external framework name, identifier and mapping to a rights-classified boundary that this store is
|
|
57
|
+
* not. `pnpm check:assurance-control-boundary` refuses them repository-wide against a baseline drained
|
|
58
|
+
* to zero, so a dogfood application's committed store is a surface where they land in FRAMEWORK git.
|
|
59
|
+
*
|
|
60
|
+
* That is not hypothetical: Wonder CRM's first accepted evidence population carried six such names —
|
|
61
|
+
* every one of them merely listing the standard as "voluntary, not a legal obligation, never
|
|
62
|
+
* researched" — and reddened the gate on the shared branch. The finding survives its neutral phrasing
|
|
63
|
+
* intact, which is why the instruction asks for the CATEGORY rather than forbidding the conclusion:
|
|
64
|
+
* an agent told only "do not name X" tends to drop the finding along with the name.
|
|
65
|
+
*/
|
|
66
|
+
export declare function composeEvidenceStoreInstruction(evidenceDirectoryAbsolutePath: string): string;
|
|
67
|
+
/** What the companion persists about one COMPLETED research task, beside whatever the agent wrote. */
|
|
68
|
+
export interface FinalEvidenceRecordInput {
|
|
69
|
+
readonly evidenceDirectoryAbsolutePath: string;
|
|
70
|
+
readonly objective: string;
|
|
71
|
+
readonly evidence: string;
|
|
72
|
+
readonly stopReason: string;
|
|
73
|
+
readonly startedAtIso: string;
|
|
74
|
+
readonly elapsedMs: number;
|
|
75
|
+
/** The playbook that asked, when one did — an operator's ad-hoc `/research` has none. */
|
|
76
|
+
readonly playbookRef?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Persist the final returned brief as a dated, provenance-stamped markdown record.
|
|
80
|
+
*
|
|
81
|
+
* Filename is `<yyyy-mm-dd>-round-<n>.md` where `n` disambiguates within a day — deliberately NOT
|
|
82
|
+
* derived from the objective, whose first words are near-identical across rounds of one
|
|
83
|
+
* investigation. Returns the absolute path written, so the caller can report it.
|
|
84
|
+
*/
|
|
85
|
+
export declare function writeFinalEvidenceRecord(input: FinalEvidenceRecordInput): string;
|
|
86
|
+
//# sourceMappingURL=research-evidence-store.companion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"research-evidence-store.companion.d.ts","sourceRoot":"","sources":["../../../../../src/claude-cli/services/research-evidence-store.companion.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,uGAAuG;AACvG,eAAO,MAAM,+BAA+B,qCAAqC,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExF;AAED,iGAAiG;AACjG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO1D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,+BAA+B,CAAC,6BAA6B,EAAE,MAAM,GAAG,MAAM,CAS7F;AAED,sGAAsG;AACtG,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,6BAA6B,EAAE,MAAM,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,yFAAyF;IACzF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM,CAgChF"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync, existsSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* The research evidence store — where a research agent's findings become FILES.
|
|
5
|
+
*
|
|
6
|
+
* ## Why this exists (2026-09-04)
|
|
7
|
+
*
|
|
8
|
+
* Research evidence used to live in exactly one place: the run's in-memory step results, feeding
|
|
9
|
+
* the next child's brief and dying with the run. Three consecutive compliance runs proved what that
|
|
10
|
+
* costs — a 56-minute, 14-children evidence body lost to a quota cut, then two relaunches lost to
|
|
11
|
+
* an expired login — and the run-level checkpoint only protects the SCHEDULING state, not the
|
|
12
|
+
* knowledge. The store is the knowledge half: evidence lands on disk as it is gathered, survives
|
|
13
|
+
* any death, and is READ BACK by later runs so they extend prior research instead of re-buying it.
|
|
14
|
+
*
|
|
15
|
+
* ## Where, and why it is COMMITTABLE
|
|
16
|
+
*
|
|
17
|
+
* `<application>/specifications/research-evidence/<scope>/` — inside the application repository,
|
|
18
|
+
* outside `specifications/src/`, so it enters no TypeScript program and no family classification.
|
|
19
|
+
* Committable on purpose: source-attributed research is knowledge the posture artifacts cite, and
|
|
20
|
+
* "delete it and re-run" costs hours and a quota window — git is where things that must survive a
|
|
21
|
+
* re-clone live (`one-source-of-truth.md`). Acceptance stays a human commit, like every other
|
|
22
|
+
* working edit an agent lands.
|
|
23
|
+
*
|
|
24
|
+
* ## Who writes
|
|
25
|
+
*
|
|
26
|
+
* TWO writers, layered:
|
|
27
|
+
* 1. The research AGENT, incrementally, during its turn — the profile's location predicate admits
|
|
28
|
+
* exactly this directory (built by the same `buildApplicationCodingTaskLocationPredicate` the
|
|
29
|
+
* coding lane trusts), so a mid-turn death still leaves everything already consolidated.
|
|
30
|
+
* 2. The COMPANION, once per completed task — `writeFinalEvidenceRecord` persists the returned
|
|
31
|
+
* brief with its provenance frontmatter, so a completed turn is on disk even if the agent wrote
|
|
32
|
+
* nothing itself.
|
|
33
|
+
*/
|
|
34
|
+
/** Application-relative root of the store. Also the ONLY path prefix the research predicate admits. */
|
|
35
|
+
export const RESEARCH_EVIDENCE_RELATIVE_ROOT = 'specifications/research-evidence';
|
|
36
|
+
/**
|
|
37
|
+
* A scope names the investigation a set of evidence files belongs to — normally the composite
|
|
38
|
+
* playbook ref (`top_down.compliance-analysis`), so every child of one choreography, across every
|
|
39
|
+
* run of it, consolidates into one directory.
|
|
40
|
+
*/
|
|
41
|
+
export function resolveResearchEvidenceDirectory(saasRoot, scope) {
|
|
42
|
+
return join(saasRoot, RESEARCH_EVIDENCE_RELATIVE_ROOT, slugifyEvidenceScope(scope));
|
|
43
|
+
}
|
|
44
|
+
/** Directory-safe scope: lowercase, dots and separators to hyphens, nothing traversal-shaped. */
|
|
45
|
+
export function slugifyEvidenceScope(scope) {
|
|
46
|
+
const slug = scope
|
|
47
|
+
.toLowerCase()
|
|
48
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
49
|
+
.replace(/^-+|-+$/g, '')
|
|
50
|
+
.slice(0, 80);
|
|
51
|
+
return slug.length > 0 ? slug : 'adhoc';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The prompt block that turns "you may write here" into "you consolidate here".
|
|
55
|
+
*
|
|
56
|
+
* Appended to every research objective by the dispatch, never authored per playbook: the store is a
|
|
57
|
+
* property of the LANE, and a convention restated per method drifts. The instruction is explicit
|
|
58
|
+
* that the directory is the ONLY writable location — the predicate enforces it, but an agent told
|
|
59
|
+
* the boundary spends its turn researching instead of discovering refusals.
|
|
60
|
+
*
|
|
61
|
+
* ## Why it also carries a SOURCE-NEUTRALITY clause (2026-09-05)
|
|
62
|
+
*
|
|
63
|
+
* A compliance researcher enumerating "which regimes apply" reaches for proprietary security
|
|
64
|
+
* certification and attestation standards unprompted, alongside the public law that is the actual
|
|
65
|
+
* subject. Public law is fine — statutes and regulations are quotable. The proprietary standards are
|
|
66
|
+
* not: their control catalogues and identifiers are licensed material, and `CLAUDE.md` confines every
|
|
67
|
+
* external framework name, identifier and mapping to a rights-classified boundary that this store is
|
|
68
|
+
* not. `pnpm check:assurance-control-boundary` refuses them repository-wide against a baseline drained
|
|
69
|
+
* to zero, so a dogfood application's committed store is a surface where they land in FRAMEWORK git.
|
|
70
|
+
*
|
|
71
|
+
* That is not hypothetical: Wonder CRM's first accepted evidence population carried six such names —
|
|
72
|
+
* every one of them merely listing the standard as "voluntary, not a legal obligation, never
|
|
73
|
+
* researched" — and reddened the gate on the shared branch. The finding survives its neutral phrasing
|
|
74
|
+
* intact, which is why the instruction asks for the CATEGORY rather than forbidding the conclusion:
|
|
75
|
+
* an agent told only "do not name X" tends to drop the finding along with the name.
|
|
76
|
+
*/
|
|
77
|
+
export function composeEvidenceStoreInstruction(evidenceDirectoryAbsolutePath) {
|
|
78
|
+
return [
|
|
79
|
+
'# Evidence store (persist as you go)',
|
|
80
|
+
`The directory \`${evidenceDirectoryAbsolutePath}\` is your evidence store — the ONLY location you may write to (every other path is refused).`,
|
|
81
|
+
'FIRST read what it already contains: earlier rounds consolidated their findings there. Extend that record; do not re-research or restate what a prior file already establishes with sources.',
|
|
82
|
+
'AS YOU RESEARCH, persist your findings into markdown files in that directory — one file per coherent topic, named `<topic-slug>.md`, updated in place as your understanding sharpens. Each finding carries its source URL beside it. Write incrementally: evidence on disk survives an interrupted turn; evidence only in your final message does not.',
|
|
83
|
+
'SOURCE NEUTRALITY: name public law freely (statutes, regulations, regulator guidance — quote and cite them). Do NOT name a proprietary security certification or attestation standard, or any of its control identifiers, in a file or in your final message: their catalogues are licensed material this store is not a rights-classified boundary for. Refer to that whole class as "voluntary security-certification and attestation frameworks" and state your finding about it in full — the conclusion is wanted, the proprietary name is not.',
|
|
84
|
+
'Your final message still reports the answer in full — the store is the durable record, not a substitute for answering.',
|
|
85
|
+
].join('\n');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Persist the final returned brief as a dated, provenance-stamped markdown record.
|
|
89
|
+
*
|
|
90
|
+
* Filename is `<yyyy-mm-dd>-round-<n>.md` where `n` disambiguates within a day — deliberately NOT
|
|
91
|
+
* derived from the objective, whose first words are near-identical across rounds of one
|
|
92
|
+
* investigation. Returns the absolute path written, so the caller can report it.
|
|
93
|
+
*/
|
|
94
|
+
export function writeFinalEvidenceRecord(input) {
|
|
95
|
+
mkdirSync(input.evidenceDirectoryAbsolutePath, { recursive: true });
|
|
96
|
+
const day = input.startedAtIso.slice(0, 10);
|
|
97
|
+
const existing = readdirSync(input.evidenceDirectoryAbsolutePath).filter((name) => name.startsWith(`${day}-round-`));
|
|
98
|
+
let round = existing.length + 1;
|
|
99
|
+
let filePath = join(input.evidenceDirectoryAbsolutePath, `${day}-round-${round}.md`);
|
|
100
|
+
while (existsSync(filePath)) {
|
|
101
|
+
round += 1;
|
|
102
|
+
filePath = join(input.evidenceDirectoryAbsolutePath, `${day}-round-${round}.md`);
|
|
103
|
+
}
|
|
104
|
+
const frontmatter = [
|
|
105
|
+
'---',
|
|
106
|
+
`startedAt: ${input.startedAtIso}`,
|
|
107
|
+
`elapsedMs: ${input.elapsedMs}`,
|
|
108
|
+
`stopReason: ${input.stopReason}`,
|
|
109
|
+
...(input.playbookRef ? [`playbookRef: ${input.playbookRef}`] : []),
|
|
110
|
+
'---',
|
|
111
|
+
].join('\n');
|
|
112
|
+
const body = [
|
|
113
|
+
frontmatter,
|
|
114
|
+
'',
|
|
115
|
+
'## Objective',
|
|
116
|
+
'',
|
|
117
|
+
input.objective,
|
|
118
|
+
'',
|
|
119
|
+
'## Evidence',
|
|
120
|
+
'',
|
|
121
|
+
input.evidence,
|
|
122
|
+
'',
|
|
123
|
+
].join('\n');
|
|
124
|
+
writeFileSync(filePath, body, 'utf8');
|
|
125
|
+
return filePath;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=research-evidence-store.companion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"research-evidence-store.companion.js","sourceRoot":"","sources":["../../../../../src/claude-cli/services/research-evidence-store.companion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,uGA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I,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAChC,IAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,GAAG,UAAU,KAAK,KAAK,CAAC,CAAC;IACrF,OAAO,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,KAAK,IAAI,CAAC,CAAC;QACX,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,GAAG,UAAU,KAAK,KAAK,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,WAAW,GAAG;QAClB,KAAK;QACL,cAAc,KAAK,CAAC,YAAY,EAAE;QAClC,cAAc,KAAK,CAAC,SAAS,EAAE;QAC/B,eAAe,KAAK,CAAC,UAAU,EAAE;QACjC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,gBAAgB,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,KAAK;KACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,MAAM,IAAI,GAAG;QACX,WAAW;QACX,EAAE;QACF,cAAc;QACd,EAAE;QACF,KAAK,CAAC,SAAS;QACf,EAAE;QACF,aAAa;QACb,EAAE;QACF,KAAK,CAAC,QAAQ;QACd,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { mkdirSync, writeFileSync, existsSync, readdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * The research evidence store — where a research agent's findings become FILES.\n *\n * ## Why this exists (2026-09-04)\n *\n * Research evidence used to live in exactly one place: the run's in-memory step results, feeding\n * the next child's brief and dying with the run. Three consecutive compliance runs proved what that\n * costs — a 56-minute, 14-children evidence body lost to a quota cut, then two relaunches lost to\n * an expired login — and the run-level checkpoint only protects the SCHEDULING state, not the\n * knowledge. The store is the knowledge half: evidence lands on disk as it is gathered, survives\n * any death, and is READ BACK by later runs so they extend prior research instead of re-buying it.\n *\n * ## Where, and why it is COMMITTABLE\n *\n * `<application>/specifications/research-evidence/<scope>/` — inside the application repository,\n * outside `specifications/src/`, so it enters no TypeScript program and no family classification.\n * Committable on purpose: source-attributed research is knowledge the posture artifacts cite, and\n * \"delete it and re-run\" costs hours and a quota window — git is where things that must survive a\n * re-clone live (`one-source-of-truth.md`). Acceptance stays a human commit, like every other\n * working edit an agent lands.\n *\n * ## Who writes\n *\n * TWO writers, layered:\n * 1. The research AGENT, incrementally, during its turn — the profile's location predicate admits\n * exactly this directory (built by the same `buildApplicationCodingTaskLocationPredicate` the\n * coding lane trusts), so a mid-turn death still leaves everything already consolidated.\n * 2. The COMPANION, once per completed task — `writeFinalEvidenceRecord` persists the returned\n * brief with its provenance frontmatter, so a completed turn is on disk even if the agent wrote\n * nothing itself.\n */\n\n/** Application-relative root of the store. Also the ONLY path prefix the research predicate admits. */\nexport const RESEARCH_EVIDENCE_RELATIVE_ROOT = 'specifications/research-evidence';\n\n/**\n * A scope names the investigation a set of evidence files belongs to — normally the composite\n * playbook ref (`top_down.compliance-analysis`), so every child of one choreography, across every\n * run of it, consolidates into one directory.\n */\nexport function resolveResearchEvidenceDirectory(saasRoot: string, scope: string): string {\n return join(saasRoot, RESEARCH_EVIDENCE_RELATIVE_ROOT, slugifyEvidenceScope(scope));\n}\n\n/** Directory-safe scope: lowercase, dots and separators to hyphens, nothing traversal-shaped. */\nexport function slugifyEvidenceScope(scope: string): string {\n const slug = scope\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 80);\n return slug.length > 0 ? slug : 'adhoc';\n}\n\n/**\n * The prompt block that turns \"you may write here\" into \"you consolidate here\".\n *\n * Appended to every research objective by the dispatch, never authored per playbook: the store is a\n * property of the LANE, and a convention restated per method drifts. The instruction is explicit\n * that the directory is the ONLY writable location — the predicate enforces it, but an agent told\n * the boundary spends its turn researching instead of discovering refusals.\n *\n * ## Why it also carries a SOURCE-NEUTRALITY clause (2026-09-05)\n *\n * A compliance researcher enumerating \"which regimes apply\" reaches for proprietary security\n * certification and attestation standards unprompted, alongside the public law that is the actual\n * subject. Public law is fine — statutes and regulations are quotable. The proprietary standards are\n * not: their control catalogues and identifiers are licensed material, and `CLAUDE.md` confines every\n * external framework name, identifier and mapping to a rights-classified boundary that this store is\n * not. `pnpm check:assurance-control-boundary` refuses them repository-wide against a baseline drained\n * to zero, so a dogfood application's committed store is a surface where they land in FRAMEWORK git.\n *\n * That is not hypothetical: Wonder CRM's first accepted evidence population carried six such names —\n * every one of them merely listing the standard as \"voluntary, not a legal obligation, never\n * researched\" — and reddened the gate on the shared branch. The finding survives its neutral phrasing\n * intact, which is why the instruction asks for the CATEGORY rather than forbidding the conclusion:\n * an agent told only \"do not name X\" tends to drop the finding along with the name.\n */\nexport function composeEvidenceStoreInstruction(evidenceDirectoryAbsolutePath: string): string {\n return [\n '# Evidence store (persist as you go)',\n `The directory \\`${evidenceDirectoryAbsolutePath}\\` is your evidence store — the ONLY location you may write to (every other path is refused).`,\n 'FIRST read what it already contains: earlier rounds consolidated their findings there. Extend that record; do not re-research or restate what a prior file already establishes with sources.',\n 'AS YOU RESEARCH, persist your findings into markdown files in that directory — one file per coherent topic, named `<topic-slug>.md`, updated in place as your understanding sharpens. Each finding carries its source URL beside it. Write incrementally: evidence on disk survives an interrupted turn; evidence only in your final message does not.',\n 'SOURCE NEUTRALITY: name public law freely (statutes, regulations, regulator guidance — quote and cite them). Do NOT name a proprietary security certification or attestation standard, or any of its control identifiers, in a file or in your final message: their catalogues are licensed material this store is not a rights-classified boundary for. Refer to that whole class as \"voluntary security-certification and attestation frameworks\" and state your finding about it in full — the conclusion is wanted, the proprietary name is not.',\n 'Your final message still reports the answer in full — the store is the durable record, not a substitute for answering.',\n ].join('\\n');\n}\n\n/** What the companion persists about one COMPLETED research task, beside whatever the agent wrote. */\nexport interface FinalEvidenceRecordInput {\n readonly evidenceDirectoryAbsolutePath: string;\n readonly objective: string;\n readonly evidence: string;\n readonly stopReason: string;\n readonly startedAtIso: string;\n readonly elapsedMs: number;\n /** The playbook that asked, when one did — an operator's ad-hoc `/research` has none. */\n readonly playbookRef?: string;\n}\n\n/**\n * Persist the final returned brief as a dated, provenance-stamped markdown record.\n *\n * Filename is `<yyyy-mm-dd>-round-<n>.md` where `n` disambiguates within a day — deliberately NOT\n * derived from the objective, whose first words are near-identical across rounds of one\n * investigation. Returns the absolute path written, so the caller can report it.\n */\nexport function writeFinalEvidenceRecord(input: FinalEvidenceRecordInput): string {\n mkdirSync(input.evidenceDirectoryAbsolutePath, { recursive: true });\n const day = input.startedAtIso.slice(0, 10);\n const existing = readdirSync(input.evidenceDirectoryAbsolutePath).filter((name) => name.startsWith(`${day}-round-`));\n let round = existing.length + 1;\n let filePath = join(input.evidenceDirectoryAbsolutePath, `${day}-round-${round}.md`);\n while (existsSync(filePath)) {\n round += 1;\n filePath = join(input.evidenceDirectoryAbsolutePath, `${day}-round-${round}.md`);\n }\n const frontmatter = [\n '---',\n `startedAt: ${input.startedAtIso}`,\n `elapsedMs: ${input.elapsedMs}`,\n `stopReason: ${input.stopReason}`,\n ...(input.playbookRef ? [`playbookRef: ${input.playbookRef}`] : []),\n '---',\n ].join('\\n');\n const body = [\n frontmatter,\n '',\n '## Objective',\n '',\n input.objective,\n '',\n '## Evidence',\n '',\n input.evidence,\n '',\n ].join('\\n');\n writeFileSync(filePath, body, 'utf8');\n return filePath;\n}\n"]}
|