Spec: specs/128-discovery. User guide:
docs/guides/discovery.md.
tsp/domain/entities/discovery.tsp adds DiscoveryRun (space, status Running /
Succeeded / Failed, agent type, signals read, proposed, dropped, finished at, error).
Opportunity gains source (OpportunitySource: Manual, Theme, Discovery) and brief;
OpportunityWeights gains discoveryEveryHours. Migration 161-create-discovery.
RunDiscoveryUseCase (application/use-cases/discovery/):
isAgentAllowedInSpace; the first allowed agent when
none is named) and environment (spaceEnvironment);DISCOVERY_STALE_MS is Running, and marks an older one
Failed;MAX_DISCOVERY_SIGNALS unlinked signals, their themes, open opportunity titles
and up to MAX_DISCOVERY_DOCUMENTS knowledge document titles;IStructuredAgentCaller with discoveryPrompt and
DISCOVERY_SCHEMA — no tools, MCP off, DISCOVERY_TIMEOUT_MS;checkProposals (domain/shared/discovery-proposals.ts): cited ids
must be loose signals of the space, titles new, numbers clamped, at most
MAX_DISCOVERY_PROPOSALS;ManageOpportunitiesUseCase (source Discovery), links
their signals through ManageSignalsUseCase, and finishes the run.A failed agent call finishes the run as Failed with the error.
ManageOpportunityWeightsUseCase.setDiscovery sets or clears a space’s interval
(MIN_DISCOVERY_EVERY_HOURS–MAX_DISCOVERY_EVERY_HOURS). SyncDiscoveryUseCase.runDue
checks each scheduled space with isIntervalDue against its latest run and runs the due ones in
turn; startBackgroundSync ticks it every minute through the due-work watcher.
| Surface | Entry point |
|---|---|
| CLI | shep discovery run / ls / schedule |
| Web | Discovery panel and Discovered badge on /opportunities |
| DI | infrastructure/di/modules/register-discovery.ts |