@harness-engineering/orchestrator 0.14.0 → 0.15.1

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/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as _harness_engineering_types from '@harness-engineering/types';
2
2
  import { Issue, WorkflowExecutionPlan, StageRun, AgentEvent, WorkflowConfig, TokenUsage, ConcernSignal, ScopeTier, EscalationConfig, IssueRoutingDecision, Result, WorkflowDefinition, BackendDef, RoutingConfig, RoutingDecision, RoutingUseCase, ContainerConfig, SecretConfig, AgentBackend, RoutingRequest, CapabilityTier, WorkspaceConfig, HooksConfig, SessionStartParams, AgentSession, AgentError, TurnParams, TurnResult, CheckScriptDefinition, OutputRetentionConfig, BackendCapabilityRegistry, RoutingPolicy, ComplexityVerdict, RoutingTelemetry, RoutingStatus, RoutingError, PrivacyClass, BackendCapabilities, AgentConfig, LocalModelStatus, CustomTaskDefinition, MaintenanceConfig, TokenScope, AuthToken, AuthTokenPublic, IndexedFileKind, SessionSearchResult, ReindexStats, SessionSummarizationConfig, SessionSummary, SessionSummaryMeta, SessionsConfig, GatewayEvent, NotificationEnvelope, NotificationDeliveryResult, NotificationSinkConfig, NotificationsConfig } from '@harness-engineering/types';
3
- import { IssueTrackerClient, Issue as Issue$1, CacheMetricsRecorder, TrackerConfig, eventSourcing, ArchiveHooks, SkillProposal, ProposalGateFinding, SkillKind } from '@harness-engineering/core';
4
- import { EnrichedSpec, ComplexityScore, SimulationResult, IntelligencePipeline, WeightedRecommendation, AnalysisProvider } from '@harness-engineering/intelligence';
3
+ import { IssueTrackerClient, Issue as Issue$1, CacheMetricsRecorder, TrackerConfig, eventSourcing, RoadmapStore, ArchiveHooks, SkillProposal, ProposalGateFinding, SkillKind } from '@harness-engineering/core';
4
+ import { EnrichedSpec, ComplexityScore, SimulationResult, IntelligencePipeline, WeightedRecommendation, AnalysisProvider, PrecedentLookup, ProbeConfig, ProbeInput, GraphScope, TriageVerdict, ForkGenerator, BrainstormOutcome, BrainstormInput, SpecDraft, GoNoGoCandidate } from '@harness-engineering/intelligence';
5
+ export { RankableCandidate, TriageVerdict, pilotScore, rankTriageCandidates } from '@harness-engineering/intelligence';
5
6
  import { GraphStore } from '@harness-engineering/graph';
6
7
  import { execFile } from 'node:child_process';
7
8
  import { EventEmitter } from 'node:events';
@@ -653,25 +654,6 @@ interface TriageConfig {
653
654
  * Returns undefined if no prefix is present.
654
655
  */
655
656
  declare function extractTitlePrefix(title: string | null | undefined): string | undefined;
656
- /**
657
- * Decide which skill/agent the orchestrator should dispatch this issue to.
658
- *
659
- * Rule order (first match wins):
660
- * 1. isRollback → debugging (high)
661
- * 2. security prefix or security paths → security-review (high)
662
- * 3. docs prefix or docs-only diff → docs (high)
663
- * 4. hasFailingTests → debugging (medium)
664
- * 5. touchesMigrationPaths → planning (high)
665
- * 6. fix: with small change → code-review (high)
666
- * 7. feat: → planning (medium)
667
- * 8. refactor: → refactoring (medium)
668
- * 9. default → code-review (low)
669
- *
670
- * Triage is meant to run BEFORE `routeIssue()`; the selected skill is
671
- * persisted on the live session so downstream dispatch does not
672
- * re-derive it.
673
- */
674
- declare function triageIssue(issue: Issue, signals: TriageSignals, config?: TriageConfig): TriageDecision;
675
657
 
676
658
  /**
677
659
  * A pending human interaction, typically from an escalation.
@@ -2620,6 +2602,34 @@ declare class Orchestrator extends EventEmitter {
2620
2602
  * evaluator's `execution_outcome` persistence is best-effort and never blocks.
2621
2603
  */
2622
2604
  private deriveAcceptanceEvalVerdict;
2605
+ /**
2606
+ * Roadmap Auto-Triage Phase 4 (SC1–SC3, SC5, SC7): the post-diff routing
2607
+ * retrospective — a SIBLING quality-verdict source to the 4c feeder above,
2608
+ * extending (not replacing) the proven escalation path. On a normal exit, when AMR
2609
+ * is live AND auto-triage is enabled AND this unit carries a stored pre-dispatch
2610
+ * prediction, it classifies the ACTUAL introduced diff at full strength
2611
+ * (phase:'post-diff') and grades it against that prediction:
2612
+ * - MATCH → records the graded outcome + annotates the PR "AI autonomous —
2613
+ * verify" (stage-2 human-verify handling, SC4) → returns `undefined`
2614
+ * (neutral: a match is not an escalation).
2615
+ * - MISMATCH (diff exceeded prediction, or a missing/garbled prediction, or ANY
2616
+ * error) → records the outcome (when a shape is known) + returns
2617
+ * `'quality-fail'`, which climbs the coherence unit's escalation floor
2618
+ * via `recordAmrOutcome`; exhaustion queues `needs-human` (SC3/SC7).
2619
+ *
2620
+ * Fail-safe & guarded (SC7): an error never a silent pass — it takes the MISMATCH
2621
+ * (block+escalate) path. No-op (byte-identical) when AMR is off, auto-triage is
2622
+ * off, or the unit was not dispatched through triage (no stored prediction) — the
2623
+ * last means an ordinary non-triaged run is never graded.
2624
+ */
2625
+ private deriveRoutingRetrospectiveVerdict;
2626
+ /**
2627
+ * v1 stage-2 match handling (SC4): annotate the unit's PR/issue with a "verify this
2628
+ * autonomous change" note so a human reviews every autonomous PR. Best-effort — a
2629
+ * missing tracker config / token / a failed comment never breaks completion (the
2630
+ * grade already recorded above). Mirrors `postLifecycleComment`'s adapter wiring.
2631
+ */
2632
+ private annotateRetrospectiveMatch;
2623
2633
  /**
2624
2634
  * Informs the state machine that an agent worker has exited.
2625
2635
  */
@@ -2906,6 +2916,226 @@ declare function launchTUI(orchestrator: Orchestrator): {
2906
2916
  waitUntilExit: () => Promise<void>;
2907
2917
  };
2908
2918
 
2919
+ /**
2920
+ * Build the pure `ProbeInput` from an `Issue`. Reuses `buildTaskText` for the pre-diff
2921
+ * text-only signals (title+description length, spec/acceptance hints, prompt) and
2922
+ * `extractEntities` for the candidate entity mentions the scope lever will try to resolve.
2923
+ *
2924
+ * Pure over the Issue — unit-testable without instantiating an Orchestrator.
2925
+ */
2926
+ declare function buildProbeInput(issue: Issue): ProbeInput;
2927
+ /**
2928
+ * The concrete `GraphScope` seam over a loaded `GraphStore`. For each candidate it resolves
2929
+ * a node (name → path → file-id) and simulates the blast radius via `CascadeSimulator`
2930
+ * (`summary.totalAffected`). Returns `null` for unresolved candidates — the S3 contract: an
2931
+ * unresolved candidate does NOT count toward scope. Never throws out of `resolve` (the probe
2932
+ * also guards it, but we keep this defensive so one odd node can't sink the lever).
2933
+ */
2934
+ declare function makeGraphScope(store: GraphStore): GraphScope;
2935
+ /** Injected dependencies for the wired triage over a single issue. */
2936
+ interface TriageWiringDeps {
2937
+ /** The SEL analysis provider (from `buildAnalysisProviderForLayer('sel', …)`). */
2938
+ provider?: AnalysisProvider | null;
2939
+ /** The loaded knowledge-graph store. Absent ⇒ scope degrades ⇒ everything holds. */
2940
+ graphStore?: GraphStore | null;
2941
+ /** The precedent lever (Phase 4 wires the real one; absent ⇒ cold-start unknown). */
2942
+ precedent?: PrecedentLookup;
2943
+ /** Gate seeds from `roadmap.autoTriage.thresholds`. */
2944
+ config?: Partial<ProbeConfig>;
2945
+ /** Optional model overrides threaded to the classifier tie-break. */
2946
+ models?: {
2947
+ fast?: string;
2948
+ standard?: string;
2949
+ };
2950
+ }
2951
+ /**
2952
+ * Run the scoping probe over a single `Issue`: build the input, resolve the injected SEL
2953
+ * provider + graph seam, and invoke the pure probe. Returns the `TriageVerdict`. Never
2954
+ * throws — the probe itself is total; the only added surface here is graph-store adaptation,
2955
+ * which `makeGraphScope` keeps defensive.
2956
+ */
2957
+ declare function triageIssue(issue: Issue, deps?: TriageWiringDeps): Promise<TriageVerdict>;
2958
+
2959
+ /** The human-only rubric — named triggers that MUST bias the model to low confidence. */
2960
+ declare const BRAINSTORM_RUBRIC: string;
2961
+ interface SelForkGeneratorOptions {
2962
+ /** Samples per fork for the self-consistency check (default 3; min 2 to detect a flip). */
2963
+ samples?: number;
2964
+ /** Optional model override threaded to the provider. */
2965
+ model?: string;
2966
+ /** Max tokens per sample (default 512). */
2967
+ maxTokens?: number;
2968
+ }
2969
+ /**
2970
+ * Build a real `ForkGenerator` over an `AnalysisProvider`. For each fork index the generator
2971
+ * samples the model N times; it accepts the fork (passing through the model's reported `high`)
2972
+ * only when EVERY sample agrees on the SAME fork identity (`forkId` + normalized `question`)
2973
+ * AND the SAME recommended option, AND that recommendation is non-empty AND is one of the
2974
+ * fork's offered `options`. Any drift, instability, or degenerate/off-menu recommendation
2975
+ * forces `confidence:'low'` (the runner then halts and a human owns the fork). The generator
2976
+ * NEVER throws for a well-formed provider; a provider error propagates and the pure runner maps
2977
+ * it to `halted{ reason:'error' }`.
2978
+ */
2979
+ declare function makeSelForkGenerator(provider: AnalysisProvider, input: BrainstormInput, opts?: SelForkGeneratorOptions): ForkGenerator;
2980
+ interface BrainstormWiringDeps {
2981
+ /**
2982
+ * An explicit `ForkGenerator` to drive the brainstorm. INJECTED in tests (no live model).
2983
+ * When absent, `provider` is required and a real SEL generator is built.
2984
+ */
2985
+ generator?: ForkGenerator;
2986
+ /** The SEL provider used to build the real generator when `generator` is absent. */
2987
+ provider?: AnalysisProvider | null;
2988
+ /** Self-consistency / model options for the built generator. */
2989
+ generatorOptions?: SelForkGeneratorOptions;
2990
+ /**
2991
+ * Docs root under which a completed spec is written (`<docsRoot>/changes/<slug>/proposal.md`).
2992
+ * Absent ⇒ no spec is written (dry run) but the outcome is still returned.
2993
+ */
2994
+ docsRoot?: string;
2995
+ /** Re-score deps threaded to `triageIssue` (SC4). Absent ⇒ re-score is skipped. */
2996
+ rescore?: {
2997
+ graphStore?: GraphStore | null;
2998
+ } & Pick<TriageWiringDeps, 'provider' | 'precedent' | 'config' | 'models'>;
2999
+ }
3000
+ /** The wired result: the pure outcome + (on completion) the written path + the re-score verdict. */
3001
+ interface WiredBrainstormResult {
3002
+ /** The pure decision-core outcome (completed{spec} | halted{fork,reason}). */
3003
+ outcome: BrainstormOutcome;
3004
+ /** Absolute path of the written spec, when a spec was completed AND `docsRoot` was set. */
3005
+ specPath?: string;
3006
+ /** The re-score verdict over the enriched content (SC4), when the brainstorm completed. */
3007
+ rescore?: TriageVerdict;
3008
+ }
3009
+ /**
3010
+ * Build a `BrainstormInput` from an `Issue` + its Phase-1 complexity level. Pure over the Issue.
3011
+ */
3012
+ declare function brainstormInputFromIssue(issue: Issue, level: BrainstormInput['level']): BrainstormInput;
3013
+ /**
3014
+ * Run the autonomous brainstorm for one issue and, on a clean completion, write a
3015
+ * proposal-shaped spec + re-score the enriched item (SC4). The generator is injected (tests)
3016
+ * or built over the SEL provider (production). Never throws — the pure runner is total, and
3017
+ * the doc-write / re-score are guarded.
3018
+ */
3019
+ declare function runBrainstormForIssue(issue: Issue, level: BrainstormInput['level'], deps: BrainstormWiringDeps): Promise<WiredBrainstormResult>;
3020
+ /** Slugify an item identity into a docs directory name. */
3021
+ declare function slugFor(spec: SpecDraft): string;
3022
+ /**
3023
+ * Render a `SpecDraft` as a proposal-shaped markdown spec: a decision record where each
3024
+ * accepted fork becomes an "Approach" section (question → recommended option + rationale).
3025
+ */
3026
+ declare function renderSpecMarkdown(spec: SpecDraft): string;
3027
+ /**
3028
+ * Produce an enriched `Issue` whose description carries the drafted spec's substance, so the
3029
+ * re-score (SC4) reads REAL content — the resolved decisions + rationale — not the original
3030
+ * one-line length proxy. Pure over the inputs.
3031
+ */
3032
+ declare function enrichIssueWithSpec(issue: Issue, spec: SpecDraft): Issue;
3033
+
3034
+ /**
3035
+ * One approved item to mark, bundling everything the two writes need: the go/no-go verdict
3036
+ * (must be `humanApproved`), the roadmap feature name (→ shard slug), the Phase-2 spec path
3037
+ * to attach, and the probe outputs for the prediction slice.
3038
+ */
3039
+ interface TriageMarkItem {
3040
+ /** The go/no-go candidate. Only acted on when `candidate.humanApproved` is true (SC5). */
3041
+ candidate: GoNoGoCandidate;
3042
+ /** The roadmap feature's display name — slugified to resolve its shard. */
3043
+ featureName: string;
3044
+ /** Repo-relative path to the generated spec (Phase 2 output) to attach to the feature. */
3045
+ specPath: string;
3046
+ /** Item labels (for the prediction's shapeKey bucket). */
3047
+ labels: readonly string[];
3048
+ /** The pre-diff complexity verdict from the probe (the prediction being made). */
3049
+ verdict: ComplexityVerdict;
3050
+ /** Predicted blast radius (from the scope lever) — recorded for the retrospective. */
3051
+ scopeEstimate: number;
3052
+ /**
3053
+ * The EVIDENCE-DERIVED autonomy stage this item's SHAPE earned (SC6), resolved
3054
+ * per-shape by the caller (`min(resolveStage(history), configuredCeiling, 2)`).
3055
+ * When present it is stamped onto the prediction INSTEAD of the uniform
3056
+ * `config.ratchetStage`, so the ratchet advances per-shape. Absent ⇒ the marker
3057
+ * falls back to `config.ratchetStage` (the Phase-3 uniform behavior).
3058
+ */
3059
+ effectiveStage?: 1 | 2;
3060
+ }
3061
+ /** The feature-flag + ratchet surface the marker reads (default-off master switch). */
3062
+ interface TriageMarkConfig {
3063
+ /** Master switch. `false` ⇒ complete no-op (SC7). */
3064
+ enabled: boolean;
3065
+ /** Ratchet stage stamped onto the prediction (Phase 3 pins 1). */
3066
+ ratchetStage: 1 | 2 | 3 | 4;
3067
+ }
3068
+ /** Injected prediction writer — the Phase-0 TriageRecord store's append. Fakeable in tests. */
3069
+ type RecordPrediction = (payload: eventSourcing.TriagePredictedInput) => Promise<{
3070
+ ok: boolean;
3071
+ error?: Error;
3072
+ }>;
3073
+ interface TriageMarkDeps {
3074
+ /** The roadmap store to patch (real via `resolveRoadmapStoreForFile`, fake in tests). */
3075
+ store: RoadmapStore;
3076
+ /** Feature-flag + ratchet config. */
3077
+ config: TriageMarkConfig;
3078
+ /** Prediction writer (Phase-0 store). */
3079
+ recordPrediction: RecordPrediction;
3080
+ /**
3081
+ * The orchestrator's self-identity for the assignee gate. When provided, an item assigned
3082
+ * to anyone else is skipped (SC6). When omitted, the gate is inactive (call-sites without
3083
+ * identity — mirrors `candidate-selection.ts`'s `selfAssignee` optionality).
3084
+ */
3085
+ selfAssignee?: string | null;
3086
+ }
3087
+ /** Why an item was skipped rather than marked (legible, closed set). */
3088
+ type MarkSkipReason =
3089
+ /** The candidate was not human-approved (SC5) — should not reach the marker, guarded anyway. */
3090
+ 'not-approved'
3091
+ /** The item is assigned to a non-self assignee (SC6) — never stolen. */
3092
+ | 'assigned-elsewhere'
3093
+ /** The feature was not found in the roadmap (stale externalId / renamed). */
3094
+ | 'feature-not-found';
3095
+ interface MarkSkip {
3096
+ externalId: string;
3097
+ reason: MarkSkipReason;
3098
+ }
3099
+ /** The marker's outcome: which items were made eligible, and which were skipped + why. */
3100
+ interface TriageMarkResult {
3101
+ /** externalIds of items successfully marked eligible (spec attached + prediction recorded). */
3102
+ marked: string[];
3103
+ /** Items intentionally not marked, each with the legible reason. */
3104
+ skipped: MarkSkip[];
3105
+ }
3106
+ /**
3107
+ * Mark human-approved items eligible for the existing orchestrator pickup, and record their
3108
+ * pre-dispatch predictions. Returns `Ok` with the mark/skip partition, or `Err` on the first
3109
+ * store write that fails (so a partial roadmap write surfaces rather than silently dropping).
3110
+ *
3111
+ * NOTE ON DISPATCH: nothing here dispatches. The orchestrator's own pickup loop selects the
3112
+ * now-spec-bearing, active-status item on its next tick and runs it through unchanged gating.
3113
+ */
3114
+ declare function markApprovedForDispatch(items: readonly TriageMarkItem[], deps: TriageMarkDeps): Promise<{
3115
+ ok: true;
3116
+ value: TriageMarkResult;
3117
+ } | {
3118
+ ok: false;
3119
+ error: Error;
3120
+ }>;
3121
+
3122
+ /** The minimal stored-record shape the precedent aggregation reads (structural mirror). */
3123
+ interface StoredOutcomeRecord {
3124
+ shapeKey: string;
3125
+ outcome?: {
3126
+ matched: boolean;
3127
+ };
3128
+ }
3129
+ /**
3130
+ * The REAL `PrecedentLookup` (SC5) — closes the Phase-1 degrade-empty stub. Aggregates
3131
+ * the autonomous-success base-rate over recorded outcomes sharing a `shapeKey` via the
3132
+ * pure `aggregatePrecedent`. Bridges core's `StoredTriageRecord` (whose `outcome` slice
3133
+ * is structurally `{ matched }` for aggregation purposes) into the intelligence
3134
+ * aggregation. With no outcome-bearing records for a shape it returns `unknown` — the
3135
+ * exact Phase-1 cold-start behavior, now real once outcomes accrue.
3136
+ */
3137
+ declare function precedentLookupFromStored(records: readonly StoredOutcomeRecord[]): PrecedentLookup;
3138
+
2909
3139
  /**
2910
3140
  * Fail-closed signal: privacy floor / allowlist emptied the candidate set (S4-001).
2911
3141
  * Distinguishable from a tier/cost-only exclusion, which returns `undefined`.
@@ -4898,4 +5128,4 @@ declare function emitProposalCreated(bus: EventEmitter, proposal: SkillProposal)
4898
5128
  declare function emitProposalApproved(bus: EventEmitter, proposal: SkillProposal): void;
4899
5129
  declare function emitProposalRejected(bus: EventEmitter, proposal: SkillProposal): void;
4900
5130
 
4901
- export { AdaptiveRouter, type AdaptiveRouterDeps, type AgentDispatchResult, type AgentDispatcher, type AgentDispatcherDeps, type AgentUpdateEvent, AnalysisArchive, type AnalysisRecord, type ApplyEventResult, type ArtifactPresence, type AttemptStats, BUILT_IN_TASKS, BackendDefSchema, type BackendResolver, BackendRouter, type BackendRouterOptions, type BaseRefFallbackEvent, type BuildArchiveHooksOptions, type BuildWorkflowContextDeps, type CheckCommandResult, type CheckCommandRunner, type CheckFailureClassification, type CheckFailureKind, CheckScriptRunner, ClaimManager, type ClaimManagerConfig, type CleanWorkspaceEffect, type CommandExecResult, type CommandExecutor, type CreateTokenInput, type CreateTokenResult, type CustomTaskValidationError, type DispatchEffect, type EmitLogEffect, type EscalateEffect, EscalationState, type ExecFileAsyncFn, type ExecFileError, type ExecFileFn$1 as ExecFileFn, type FromConfigOptions, GateNotReadyError, type GateResult, GateRunError, type HarnessSpawn, type Highlight, type HighlightsInfo, type IndexedDoc, InteractionQueue, LinearGraphQLClient, type LinearGraphQLClientOptions, type LinearGraphQLExtension, LinearGraphQLStub, type LiveSession, LocalModelResolver, type LocalModelResolverOptions, MAINTENANCE_CHECK_MAX_BUFFER, MAINTENANCE_CHECK_TIMEOUT_MS, MAX_ATTEMPTS, MaintenanceReporter, type MaintenanceReporterOptions, type MigrationResult, MockBackend, type NotificationSink, type NotificationSinkDeliverInput, ORCHESTRATOR_IDENTITY_FILE, Orchestrator, OrchestratorBackendFactory, type OrchestratorBackendFactoryOptions, type OrchestratorContext, type OrchestratorEvent, type OrchestratorState, PRDetector, type PRDetectorLogger, type PRLifecycleManager, type PendingInteraction, type PersistedOutputEntry, PrivacyNoMatch, PromotionError, type PromotionResult, PromptRenderer, type ProposalApprovedData, type ProposalCreatedData, type ProposalRejectedData, type PublishedIndex, type QueueInsertInput, type QueueRow, type QueueStats, RETRY_DELAYS_MS, type RateLimitSnapshot as RateLimitComputeSnapshot, type RateLimitConfig, type RateLimitSnapshot$1 as RateLimitSnapshot, type RegistryEntry, type ReleaseClaimEffect, type ResolverLogger, type RetryEntry, type RetryFiredEvent, RoadmapTrackerAdapter, RoutingConfigSchema, RoutingValueSchema, type RunAttemptPhase, type RunHarnessCheckOptions, type RunMode, type RunOrigin, type RunResult, type RunningEntry, type ScheduleRetryEffect, type SearchOptions, type SelectConstraints, type SideEffect, SinkConfigError, SinkRegistry, type SkillCatalogEntry, SlackSink, type SlackSinkOptions, SqliteSearchIndex, type StallDetectedEvent, type StopEffect, type StreamManifest, StreamRecorder, type SummarizeContext, type SummarizeResult, type SyncMainOptions, type SyncMainResult, type SyncSkipReason, type TaskDefinition, TaskOutputStore, TaskRunner, type TaskRunnerOptions, type TaskSelectionFilter, type TaskType, type TickEvent, TokenStore, type TokenTotals, type TriageConfig, type TriageDecision, type TriageSignals, type TriageSkill, type UpdateTokensEffect, type ValidateWorkflowConfigOptions, type ValidatedWorkflowConfig, WebhookQueue, type WorkerExitEvent, WorkflowLoader, type WorkflowRouterDep, WorkspaceHooks, WorkspaceManager, type WorkspaceManagerOptions, applyEvent, artifactPresenceFromIssue, buildArchiveHooks, buildCapabilityRegistry, buildWorkflowContext, calculateRetryDelay, canDispatch, classifyCheckExecutionFailure, computeRateLimitDelay, createAgentDispatcher, createBackend, createEmptyState, crossFieldRoutingIssues, defaultFetchModels, defaultPoolCapabilities, deriveSeedPaths, detectScopeTier, discoverSkillCatalog, discoverSkillCatalogNames, emitProposalApproved, emitProposalCreated, emitProposalRejected, estimateCost, explicitFindingsCount, extractHighlights, extractTitlePrefix, getAvailableSlots, getDefaultConfig, getPerStateCount, indexSessionDirectory, isCheckTimeoutError, isEligible, isSummaryEnabled, launchTUI, loadPublishedIndex, makeBackendResolver, migrateAgentConfig, normalizeFts5Query, normalizeHarnessCommand, normalizeLocalModel, openSearchIndex, promote, reconcile, recoverFindingsCount, reindexFromArchive, renderAnalysisComment, renderLlmSummaryMarkdown, renderPRComment, resolveEscalationConfig, resolveOrchestratorId, routeIssue, routingWarnings, runGate, runHarnessCheck, savePublishedIndex, searchIndexPath, selectCandidates, selectCheapestQualifying, selectTasks, sortCandidates, summarizeArchivedSession, syncMain, triageIssue, truncateForBudget, validateCustomTasks, validateWorkflowConfig, wireNotificationSinks, workflowFor, wrapAsEnvelope };
5131
+ export { AdaptiveRouter, type AdaptiveRouterDeps, type AgentDispatchResult, type AgentDispatcher, type AgentDispatcherDeps, type AgentUpdateEvent, AnalysisArchive, type AnalysisRecord, type ApplyEventResult, type ArtifactPresence, type AttemptStats, BRAINSTORM_RUBRIC, BUILT_IN_TASKS, BackendDefSchema, type BackendResolver, BackendRouter, type BackendRouterOptions, type BaseRefFallbackEvent, type BrainstormWiringDeps, type BuildArchiveHooksOptions, type BuildWorkflowContextDeps, type CheckCommandResult, type CheckCommandRunner, type CheckFailureClassification, type CheckFailureKind, CheckScriptRunner, ClaimManager, type ClaimManagerConfig, type CleanWorkspaceEffect, type CommandExecResult, type CommandExecutor, type CreateTokenInput, type CreateTokenResult, type CustomTaskValidationError, type DispatchEffect, type EmitLogEffect, type EscalateEffect, EscalationState, type ExecFileAsyncFn, type ExecFileError, type ExecFileFn$1 as ExecFileFn, type FromConfigOptions, GateNotReadyError, type GateResult, GateRunError, type HarnessSpawn, type Highlight, type HighlightsInfo, type IndexedDoc, InteractionQueue, LinearGraphQLClient, type LinearGraphQLClientOptions, type LinearGraphQLExtension, LinearGraphQLStub, type LiveSession, LocalModelResolver, type LocalModelResolverOptions, MAINTENANCE_CHECK_MAX_BUFFER, MAINTENANCE_CHECK_TIMEOUT_MS, MAX_ATTEMPTS, MaintenanceReporter, type MaintenanceReporterOptions, type MarkSkip, type MarkSkipReason, type MigrationResult, MockBackend, type NotificationSink, type NotificationSinkDeliverInput, ORCHESTRATOR_IDENTITY_FILE, Orchestrator, OrchestratorBackendFactory, type OrchestratorBackendFactoryOptions, type OrchestratorContext, type OrchestratorEvent, type OrchestratorState, PRDetector, type PRDetectorLogger, type PRLifecycleManager, type PendingInteraction, type PersistedOutputEntry, PrivacyNoMatch, PromotionError, type PromotionResult, PromptRenderer, type ProposalApprovedData, type ProposalCreatedData, type ProposalRejectedData, type PublishedIndex, type QueueInsertInput, type QueueRow, type QueueStats, RETRY_DELAYS_MS, type RateLimitSnapshot as RateLimitComputeSnapshot, type RateLimitConfig, type RateLimitSnapshot$1 as RateLimitSnapshot, type RecordPrediction, type RegistryEntry, type ReleaseClaimEffect, type ResolverLogger, type RetryEntry, type RetryFiredEvent, RoadmapTrackerAdapter, RoutingConfigSchema, RoutingValueSchema, type RunAttemptPhase, type RunHarnessCheckOptions, type RunMode, type RunOrigin, type RunResult, type RunningEntry, type ScheduleRetryEffect, type SearchOptions, type SelForkGeneratorOptions, type SelectConstraints, type SideEffect, SinkConfigError, SinkRegistry, type SkillCatalogEntry, SlackSink, type SlackSinkOptions, SqliteSearchIndex, type StallDetectedEvent, type StopEffect, type StoredOutcomeRecord, type StreamManifest, StreamRecorder, type SummarizeContext, type SummarizeResult, type SyncMainOptions, type SyncMainResult, type SyncSkipReason, type TaskDefinition, TaskOutputStore, TaskRunner, type TaskRunnerOptions, type TaskSelectionFilter, type TaskType, type TickEvent, TokenStore, type TokenTotals, type TriageConfig, type TriageDecision, type TriageMarkConfig, type TriageMarkDeps, type TriageMarkItem, type TriageMarkResult, type TriageSignals, type TriageSkill, type TriageWiringDeps, type UpdateTokensEffect, type ValidateWorkflowConfigOptions, type ValidatedWorkflowConfig, WebhookQueue, type WiredBrainstormResult, type WorkerExitEvent, WorkflowLoader, type WorkflowRouterDep, WorkspaceHooks, WorkspaceManager, type WorkspaceManagerOptions, applyEvent, artifactPresenceFromIssue, brainstormInputFromIssue, buildArchiveHooks, buildCapabilityRegistry, buildProbeInput, buildWorkflowContext, calculateRetryDelay, canDispatch, classifyCheckExecutionFailure, computeRateLimitDelay, createAgentDispatcher, createBackend, createEmptyState, crossFieldRoutingIssues, defaultFetchModels, defaultPoolCapabilities, deriveSeedPaths, detectScopeTier, discoverSkillCatalog, discoverSkillCatalogNames, emitProposalApproved, emitProposalCreated, emitProposalRejected, enrichIssueWithSpec, estimateCost, explicitFindingsCount, extractHighlights, extractTitlePrefix, getAvailableSlots, getDefaultConfig, getPerStateCount, indexSessionDirectory, isCheckTimeoutError, isEligible, isSummaryEnabled, launchTUI, loadPublishedIndex, makeBackendResolver, makeGraphScope, makeSelForkGenerator, markApprovedForDispatch, migrateAgentConfig, normalizeFts5Query, normalizeHarnessCommand, normalizeLocalModel, openSearchIndex, precedentLookupFromStored, promote, reconcile, recoverFindingsCount, reindexFromArchive, renderAnalysisComment, renderLlmSummaryMarkdown, renderPRComment, renderSpecMarkdown, resolveEscalationConfig, resolveOrchestratorId, routeIssue, routingWarnings, runBrainstormForIssue, runGate, runHarnessCheck, savePublishedIndex, searchIndexPath, selectCandidates, selectCheapestQualifying, selectTasks, slugFor, sortCandidates, summarizeArchivedSession, syncMain, triageIssue, truncateForBudget, validateCustomTasks, validateWorkflowConfig, wireNotificationSinks, workflowFor, wrapAsEnvelope };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as _harness_engineering_types from '@harness-engineering/types';
2
2
  import { Issue, WorkflowExecutionPlan, StageRun, AgentEvent, WorkflowConfig, TokenUsage, ConcernSignal, ScopeTier, EscalationConfig, IssueRoutingDecision, Result, WorkflowDefinition, BackendDef, RoutingConfig, RoutingDecision, RoutingUseCase, ContainerConfig, SecretConfig, AgentBackend, RoutingRequest, CapabilityTier, WorkspaceConfig, HooksConfig, SessionStartParams, AgentSession, AgentError, TurnParams, TurnResult, CheckScriptDefinition, OutputRetentionConfig, BackendCapabilityRegistry, RoutingPolicy, ComplexityVerdict, RoutingTelemetry, RoutingStatus, RoutingError, PrivacyClass, BackendCapabilities, AgentConfig, LocalModelStatus, CustomTaskDefinition, MaintenanceConfig, TokenScope, AuthToken, AuthTokenPublic, IndexedFileKind, SessionSearchResult, ReindexStats, SessionSummarizationConfig, SessionSummary, SessionSummaryMeta, SessionsConfig, GatewayEvent, NotificationEnvelope, NotificationDeliveryResult, NotificationSinkConfig, NotificationsConfig } from '@harness-engineering/types';
3
- import { IssueTrackerClient, Issue as Issue$1, CacheMetricsRecorder, TrackerConfig, eventSourcing, ArchiveHooks, SkillProposal, ProposalGateFinding, SkillKind } from '@harness-engineering/core';
4
- import { EnrichedSpec, ComplexityScore, SimulationResult, IntelligencePipeline, WeightedRecommendation, AnalysisProvider } from '@harness-engineering/intelligence';
3
+ import { IssueTrackerClient, Issue as Issue$1, CacheMetricsRecorder, TrackerConfig, eventSourcing, RoadmapStore, ArchiveHooks, SkillProposal, ProposalGateFinding, SkillKind } from '@harness-engineering/core';
4
+ import { EnrichedSpec, ComplexityScore, SimulationResult, IntelligencePipeline, WeightedRecommendation, AnalysisProvider, PrecedentLookup, ProbeConfig, ProbeInput, GraphScope, TriageVerdict, ForkGenerator, BrainstormOutcome, BrainstormInput, SpecDraft, GoNoGoCandidate } from '@harness-engineering/intelligence';
5
+ export { RankableCandidate, TriageVerdict, pilotScore, rankTriageCandidates } from '@harness-engineering/intelligence';
5
6
  import { GraphStore } from '@harness-engineering/graph';
6
7
  import { execFile } from 'node:child_process';
7
8
  import { EventEmitter } from 'node:events';
@@ -653,25 +654,6 @@ interface TriageConfig {
653
654
  * Returns undefined if no prefix is present.
654
655
  */
655
656
  declare function extractTitlePrefix(title: string | null | undefined): string | undefined;
656
- /**
657
- * Decide which skill/agent the orchestrator should dispatch this issue to.
658
- *
659
- * Rule order (first match wins):
660
- * 1. isRollback → debugging (high)
661
- * 2. security prefix or security paths → security-review (high)
662
- * 3. docs prefix or docs-only diff → docs (high)
663
- * 4. hasFailingTests → debugging (medium)
664
- * 5. touchesMigrationPaths → planning (high)
665
- * 6. fix: with small change → code-review (high)
666
- * 7. feat: → planning (medium)
667
- * 8. refactor: → refactoring (medium)
668
- * 9. default → code-review (low)
669
- *
670
- * Triage is meant to run BEFORE `routeIssue()`; the selected skill is
671
- * persisted on the live session so downstream dispatch does not
672
- * re-derive it.
673
- */
674
- declare function triageIssue(issue: Issue, signals: TriageSignals, config?: TriageConfig): TriageDecision;
675
657
 
676
658
  /**
677
659
  * A pending human interaction, typically from an escalation.
@@ -2620,6 +2602,34 @@ declare class Orchestrator extends EventEmitter {
2620
2602
  * evaluator's `execution_outcome` persistence is best-effort and never blocks.
2621
2603
  */
2622
2604
  private deriveAcceptanceEvalVerdict;
2605
+ /**
2606
+ * Roadmap Auto-Triage Phase 4 (SC1–SC3, SC5, SC7): the post-diff routing
2607
+ * retrospective — a SIBLING quality-verdict source to the 4c feeder above,
2608
+ * extending (not replacing) the proven escalation path. On a normal exit, when AMR
2609
+ * is live AND auto-triage is enabled AND this unit carries a stored pre-dispatch
2610
+ * prediction, it classifies the ACTUAL introduced diff at full strength
2611
+ * (phase:'post-diff') and grades it against that prediction:
2612
+ * - MATCH → records the graded outcome + annotates the PR "AI autonomous —
2613
+ * verify" (stage-2 human-verify handling, SC4) → returns `undefined`
2614
+ * (neutral: a match is not an escalation).
2615
+ * - MISMATCH (diff exceeded prediction, or a missing/garbled prediction, or ANY
2616
+ * error) → records the outcome (when a shape is known) + returns
2617
+ * `'quality-fail'`, which climbs the coherence unit's escalation floor
2618
+ * via `recordAmrOutcome`; exhaustion queues `needs-human` (SC3/SC7).
2619
+ *
2620
+ * Fail-safe & guarded (SC7): an error never a silent pass — it takes the MISMATCH
2621
+ * (block+escalate) path. No-op (byte-identical) when AMR is off, auto-triage is
2622
+ * off, or the unit was not dispatched through triage (no stored prediction) — the
2623
+ * last means an ordinary non-triaged run is never graded.
2624
+ */
2625
+ private deriveRoutingRetrospectiveVerdict;
2626
+ /**
2627
+ * v1 stage-2 match handling (SC4): annotate the unit's PR/issue with a "verify this
2628
+ * autonomous change" note so a human reviews every autonomous PR. Best-effort — a
2629
+ * missing tracker config / token / a failed comment never breaks completion (the
2630
+ * grade already recorded above). Mirrors `postLifecycleComment`'s adapter wiring.
2631
+ */
2632
+ private annotateRetrospectiveMatch;
2623
2633
  /**
2624
2634
  * Informs the state machine that an agent worker has exited.
2625
2635
  */
@@ -2906,6 +2916,226 @@ declare function launchTUI(orchestrator: Orchestrator): {
2906
2916
  waitUntilExit: () => Promise<void>;
2907
2917
  };
2908
2918
 
2919
+ /**
2920
+ * Build the pure `ProbeInput` from an `Issue`. Reuses `buildTaskText` for the pre-diff
2921
+ * text-only signals (title+description length, spec/acceptance hints, prompt) and
2922
+ * `extractEntities` for the candidate entity mentions the scope lever will try to resolve.
2923
+ *
2924
+ * Pure over the Issue — unit-testable without instantiating an Orchestrator.
2925
+ */
2926
+ declare function buildProbeInput(issue: Issue): ProbeInput;
2927
+ /**
2928
+ * The concrete `GraphScope` seam over a loaded `GraphStore`. For each candidate it resolves
2929
+ * a node (name → path → file-id) and simulates the blast radius via `CascadeSimulator`
2930
+ * (`summary.totalAffected`). Returns `null` for unresolved candidates — the S3 contract: an
2931
+ * unresolved candidate does NOT count toward scope. Never throws out of `resolve` (the probe
2932
+ * also guards it, but we keep this defensive so one odd node can't sink the lever).
2933
+ */
2934
+ declare function makeGraphScope(store: GraphStore): GraphScope;
2935
+ /** Injected dependencies for the wired triage over a single issue. */
2936
+ interface TriageWiringDeps {
2937
+ /** The SEL analysis provider (from `buildAnalysisProviderForLayer('sel', …)`). */
2938
+ provider?: AnalysisProvider | null;
2939
+ /** The loaded knowledge-graph store. Absent ⇒ scope degrades ⇒ everything holds. */
2940
+ graphStore?: GraphStore | null;
2941
+ /** The precedent lever (Phase 4 wires the real one; absent ⇒ cold-start unknown). */
2942
+ precedent?: PrecedentLookup;
2943
+ /** Gate seeds from `roadmap.autoTriage.thresholds`. */
2944
+ config?: Partial<ProbeConfig>;
2945
+ /** Optional model overrides threaded to the classifier tie-break. */
2946
+ models?: {
2947
+ fast?: string;
2948
+ standard?: string;
2949
+ };
2950
+ }
2951
+ /**
2952
+ * Run the scoping probe over a single `Issue`: build the input, resolve the injected SEL
2953
+ * provider + graph seam, and invoke the pure probe. Returns the `TriageVerdict`. Never
2954
+ * throws — the probe itself is total; the only added surface here is graph-store adaptation,
2955
+ * which `makeGraphScope` keeps defensive.
2956
+ */
2957
+ declare function triageIssue(issue: Issue, deps?: TriageWiringDeps): Promise<TriageVerdict>;
2958
+
2959
+ /** The human-only rubric — named triggers that MUST bias the model to low confidence. */
2960
+ declare const BRAINSTORM_RUBRIC: string;
2961
+ interface SelForkGeneratorOptions {
2962
+ /** Samples per fork for the self-consistency check (default 3; min 2 to detect a flip). */
2963
+ samples?: number;
2964
+ /** Optional model override threaded to the provider. */
2965
+ model?: string;
2966
+ /** Max tokens per sample (default 512). */
2967
+ maxTokens?: number;
2968
+ }
2969
+ /**
2970
+ * Build a real `ForkGenerator` over an `AnalysisProvider`. For each fork index the generator
2971
+ * samples the model N times; it accepts the fork (passing through the model's reported `high`)
2972
+ * only when EVERY sample agrees on the SAME fork identity (`forkId` + normalized `question`)
2973
+ * AND the SAME recommended option, AND that recommendation is non-empty AND is one of the
2974
+ * fork's offered `options`. Any drift, instability, or degenerate/off-menu recommendation
2975
+ * forces `confidence:'low'` (the runner then halts and a human owns the fork). The generator
2976
+ * NEVER throws for a well-formed provider; a provider error propagates and the pure runner maps
2977
+ * it to `halted{ reason:'error' }`.
2978
+ */
2979
+ declare function makeSelForkGenerator(provider: AnalysisProvider, input: BrainstormInput, opts?: SelForkGeneratorOptions): ForkGenerator;
2980
+ interface BrainstormWiringDeps {
2981
+ /**
2982
+ * An explicit `ForkGenerator` to drive the brainstorm. INJECTED in tests (no live model).
2983
+ * When absent, `provider` is required and a real SEL generator is built.
2984
+ */
2985
+ generator?: ForkGenerator;
2986
+ /** The SEL provider used to build the real generator when `generator` is absent. */
2987
+ provider?: AnalysisProvider | null;
2988
+ /** Self-consistency / model options for the built generator. */
2989
+ generatorOptions?: SelForkGeneratorOptions;
2990
+ /**
2991
+ * Docs root under which a completed spec is written (`<docsRoot>/changes/<slug>/proposal.md`).
2992
+ * Absent ⇒ no spec is written (dry run) but the outcome is still returned.
2993
+ */
2994
+ docsRoot?: string;
2995
+ /** Re-score deps threaded to `triageIssue` (SC4). Absent ⇒ re-score is skipped. */
2996
+ rescore?: {
2997
+ graphStore?: GraphStore | null;
2998
+ } & Pick<TriageWiringDeps, 'provider' | 'precedent' | 'config' | 'models'>;
2999
+ }
3000
+ /** The wired result: the pure outcome + (on completion) the written path + the re-score verdict. */
3001
+ interface WiredBrainstormResult {
3002
+ /** The pure decision-core outcome (completed{spec} | halted{fork,reason}). */
3003
+ outcome: BrainstormOutcome;
3004
+ /** Absolute path of the written spec, when a spec was completed AND `docsRoot` was set. */
3005
+ specPath?: string;
3006
+ /** The re-score verdict over the enriched content (SC4), when the brainstorm completed. */
3007
+ rescore?: TriageVerdict;
3008
+ }
3009
+ /**
3010
+ * Build a `BrainstormInput` from an `Issue` + its Phase-1 complexity level. Pure over the Issue.
3011
+ */
3012
+ declare function brainstormInputFromIssue(issue: Issue, level: BrainstormInput['level']): BrainstormInput;
3013
+ /**
3014
+ * Run the autonomous brainstorm for one issue and, on a clean completion, write a
3015
+ * proposal-shaped spec + re-score the enriched item (SC4). The generator is injected (tests)
3016
+ * or built over the SEL provider (production). Never throws — the pure runner is total, and
3017
+ * the doc-write / re-score are guarded.
3018
+ */
3019
+ declare function runBrainstormForIssue(issue: Issue, level: BrainstormInput['level'], deps: BrainstormWiringDeps): Promise<WiredBrainstormResult>;
3020
+ /** Slugify an item identity into a docs directory name. */
3021
+ declare function slugFor(spec: SpecDraft): string;
3022
+ /**
3023
+ * Render a `SpecDraft` as a proposal-shaped markdown spec: a decision record where each
3024
+ * accepted fork becomes an "Approach" section (question → recommended option + rationale).
3025
+ */
3026
+ declare function renderSpecMarkdown(spec: SpecDraft): string;
3027
+ /**
3028
+ * Produce an enriched `Issue` whose description carries the drafted spec's substance, so the
3029
+ * re-score (SC4) reads REAL content — the resolved decisions + rationale — not the original
3030
+ * one-line length proxy. Pure over the inputs.
3031
+ */
3032
+ declare function enrichIssueWithSpec(issue: Issue, spec: SpecDraft): Issue;
3033
+
3034
+ /**
3035
+ * One approved item to mark, bundling everything the two writes need: the go/no-go verdict
3036
+ * (must be `humanApproved`), the roadmap feature name (→ shard slug), the Phase-2 spec path
3037
+ * to attach, and the probe outputs for the prediction slice.
3038
+ */
3039
+ interface TriageMarkItem {
3040
+ /** The go/no-go candidate. Only acted on when `candidate.humanApproved` is true (SC5). */
3041
+ candidate: GoNoGoCandidate;
3042
+ /** The roadmap feature's display name — slugified to resolve its shard. */
3043
+ featureName: string;
3044
+ /** Repo-relative path to the generated spec (Phase 2 output) to attach to the feature. */
3045
+ specPath: string;
3046
+ /** Item labels (for the prediction's shapeKey bucket). */
3047
+ labels: readonly string[];
3048
+ /** The pre-diff complexity verdict from the probe (the prediction being made). */
3049
+ verdict: ComplexityVerdict;
3050
+ /** Predicted blast radius (from the scope lever) — recorded for the retrospective. */
3051
+ scopeEstimate: number;
3052
+ /**
3053
+ * The EVIDENCE-DERIVED autonomy stage this item's SHAPE earned (SC6), resolved
3054
+ * per-shape by the caller (`min(resolveStage(history), configuredCeiling, 2)`).
3055
+ * When present it is stamped onto the prediction INSTEAD of the uniform
3056
+ * `config.ratchetStage`, so the ratchet advances per-shape. Absent ⇒ the marker
3057
+ * falls back to `config.ratchetStage` (the Phase-3 uniform behavior).
3058
+ */
3059
+ effectiveStage?: 1 | 2;
3060
+ }
3061
+ /** The feature-flag + ratchet surface the marker reads (default-off master switch). */
3062
+ interface TriageMarkConfig {
3063
+ /** Master switch. `false` ⇒ complete no-op (SC7). */
3064
+ enabled: boolean;
3065
+ /** Ratchet stage stamped onto the prediction (Phase 3 pins 1). */
3066
+ ratchetStage: 1 | 2 | 3 | 4;
3067
+ }
3068
+ /** Injected prediction writer — the Phase-0 TriageRecord store's append. Fakeable in tests. */
3069
+ type RecordPrediction = (payload: eventSourcing.TriagePredictedInput) => Promise<{
3070
+ ok: boolean;
3071
+ error?: Error;
3072
+ }>;
3073
+ interface TriageMarkDeps {
3074
+ /** The roadmap store to patch (real via `resolveRoadmapStoreForFile`, fake in tests). */
3075
+ store: RoadmapStore;
3076
+ /** Feature-flag + ratchet config. */
3077
+ config: TriageMarkConfig;
3078
+ /** Prediction writer (Phase-0 store). */
3079
+ recordPrediction: RecordPrediction;
3080
+ /**
3081
+ * The orchestrator's self-identity for the assignee gate. When provided, an item assigned
3082
+ * to anyone else is skipped (SC6). When omitted, the gate is inactive (call-sites without
3083
+ * identity — mirrors `candidate-selection.ts`'s `selfAssignee` optionality).
3084
+ */
3085
+ selfAssignee?: string | null;
3086
+ }
3087
+ /** Why an item was skipped rather than marked (legible, closed set). */
3088
+ type MarkSkipReason =
3089
+ /** The candidate was not human-approved (SC5) — should not reach the marker, guarded anyway. */
3090
+ 'not-approved'
3091
+ /** The item is assigned to a non-self assignee (SC6) — never stolen. */
3092
+ | 'assigned-elsewhere'
3093
+ /** The feature was not found in the roadmap (stale externalId / renamed). */
3094
+ | 'feature-not-found';
3095
+ interface MarkSkip {
3096
+ externalId: string;
3097
+ reason: MarkSkipReason;
3098
+ }
3099
+ /** The marker's outcome: which items were made eligible, and which were skipped + why. */
3100
+ interface TriageMarkResult {
3101
+ /** externalIds of items successfully marked eligible (spec attached + prediction recorded). */
3102
+ marked: string[];
3103
+ /** Items intentionally not marked, each with the legible reason. */
3104
+ skipped: MarkSkip[];
3105
+ }
3106
+ /**
3107
+ * Mark human-approved items eligible for the existing orchestrator pickup, and record their
3108
+ * pre-dispatch predictions. Returns `Ok` with the mark/skip partition, or `Err` on the first
3109
+ * store write that fails (so a partial roadmap write surfaces rather than silently dropping).
3110
+ *
3111
+ * NOTE ON DISPATCH: nothing here dispatches. The orchestrator's own pickup loop selects the
3112
+ * now-spec-bearing, active-status item on its next tick and runs it through unchanged gating.
3113
+ */
3114
+ declare function markApprovedForDispatch(items: readonly TriageMarkItem[], deps: TriageMarkDeps): Promise<{
3115
+ ok: true;
3116
+ value: TriageMarkResult;
3117
+ } | {
3118
+ ok: false;
3119
+ error: Error;
3120
+ }>;
3121
+
3122
+ /** The minimal stored-record shape the precedent aggregation reads (structural mirror). */
3123
+ interface StoredOutcomeRecord {
3124
+ shapeKey: string;
3125
+ outcome?: {
3126
+ matched: boolean;
3127
+ };
3128
+ }
3129
+ /**
3130
+ * The REAL `PrecedentLookup` (SC5) — closes the Phase-1 degrade-empty stub. Aggregates
3131
+ * the autonomous-success base-rate over recorded outcomes sharing a `shapeKey` via the
3132
+ * pure `aggregatePrecedent`. Bridges core's `StoredTriageRecord` (whose `outcome` slice
3133
+ * is structurally `{ matched }` for aggregation purposes) into the intelligence
3134
+ * aggregation. With no outcome-bearing records for a shape it returns `unknown` — the
3135
+ * exact Phase-1 cold-start behavior, now real once outcomes accrue.
3136
+ */
3137
+ declare function precedentLookupFromStored(records: readonly StoredOutcomeRecord[]): PrecedentLookup;
3138
+
2909
3139
  /**
2910
3140
  * Fail-closed signal: privacy floor / allowlist emptied the candidate set (S4-001).
2911
3141
  * Distinguishable from a tier/cost-only exclusion, which returns `undefined`.
@@ -4898,4 +5128,4 @@ declare function emitProposalCreated(bus: EventEmitter, proposal: SkillProposal)
4898
5128
  declare function emitProposalApproved(bus: EventEmitter, proposal: SkillProposal): void;
4899
5129
  declare function emitProposalRejected(bus: EventEmitter, proposal: SkillProposal): void;
4900
5130
 
4901
- export { AdaptiveRouter, type AdaptiveRouterDeps, type AgentDispatchResult, type AgentDispatcher, type AgentDispatcherDeps, type AgentUpdateEvent, AnalysisArchive, type AnalysisRecord, type ApplyEventResult, type ArtifactPresence, type AttemptStats, BUILT_IN_TASKS, BackendDefSchema, type BackendResolver, BackendRouter, type BackendRouterOptions, type BaseRefFallbackEvent, type BuildArchiveHooksOptions, type BuildWorkflowContextDeps, type CheckCommandResult, type CheckCommandRunner, type CheckFailureClassification, type CheckFailureKind, CheckScriptRunner, ClaimManager, type ClaimManagerConfig, type CleanWorkspaceEffect, type CommandExecResult, type CommandExecutor, type CreateTokenInput, type CreateTokenResult, type CustomTaskValidationError, type DispatchEffect, type EmitLogEffect, type EscalateEffect, EscalationState, type ExecFileAsyncFn, type ExecFileError, type ExecFileFn$1 as ExecFileFn, type FromConfigOptions, GateNotReadyError, type GateResult, GateRunError, type HarnessSpawn, type Highlight, type HighlightsInfo, type IndexedDoc, InteractionQueue, LinearGraphQLClient, type LinearGraphQLClientOptions, type LinearGraphQLExtension, LinearGraphQLStub, type LiveSession, LocalModelResolver, type LocalModelResolverOptions, MAINTENANCE_CHECK_MAX_BUFFER, MAINTENANCE_CHECK_TIMEOUT_MS, MAX_ATTEMPTS, MaintenanceReporter, type MaintenanceReporterOptions, type MigrationResult, MockBackend, type NotificationSink, type NotificationSinkDeliverInput, ORCHESTRATOR_IDENTITY_FILE, Orchestrator, OrchestratorBackendFactory, type OrchestratorBackendFactoryOptions, type OrchestratorContext, type OrchestratorEvent, type OrchestratorState, PRDetector, type PRDetectorLogger, type PRLifecycleManager, type PendingInteraction, type PersistedOutputEntry, PrivacyNoMatch, PromotionError, type PromotionResult, PromptRenderer, type ProposalApprovedData, type ProposalCreatedData, type ProposalRejectedData, type PublishedIndex, type QueueInsertInput, type QueueRow, type QueueStats, RETRY_DELAYS_MS, type RateLimitSnapshot as RateLimitComputeSnapshot, type RateLimitConfig, type RateLimitSnapshot$1 as RateLimitSnapshot, type RegistryEntry, type ReleaseClaimEffect, type ResolverLogger, type RetryEntry, type RetryFiredEvent, RoadmapTrackerAdapter, RoutingConfigSchema, RoutingValueSchema, type RunAttemptPhase, type RunHarnessCheckOptions, type RunMode, type RunOrigin, type RunResult, type RunningEntry, type ScheduleRetryEffect, type SearchOptions, type SelectConstraints, type SideEffect, SinkConfigError, SinkRegistry, type SkillCatalogEntry, SlackSink, type SlackSinkOptions, SqliteSearchIndex, type StallDetectedEvent, type StopEffect, type StreamManifest, StreamRecorder, type SummarizeContext, type SummarizeResult, type SyncMainOptions, type SyncMainResult, type SyncSkipReason, type TaskDefinition, TaskOutputStore, TaskRunner, type TaskRunnerOptions, type TaskSelectionFilter, type TaskType, type TickEvent, TokenStore, type TokenTotals, type TriageConfig, type TriageDecision, type TriageSignals, type TriageSkill, type UpdateTokensEffect, type ValidateWorkflowConfigOptions, type ValidatedWorkflowConfig, WebhookQueue, type WorkerExitEvent, WorkflowLoader, type WorkflowRouterDep, WorkspaceHooks, WorkspaceManager, type WorkspaceManagerOptions, applyEvent, artifactPresenceFromIssue, buildArchiveHooks, buildCapabilityRegistry, buildWorkflowContext, calculateRetryDelay, canDispatch, classifyCheckExecutionFailure, computeRateLimitDelay, createAgentDispatcher, createBackend, createEmptyState, crossFieldRoutingIssues, defaultFetchModels, defaultPoolCapabilities, deriveSeedPaths, detectScopeTier, discoverSkillCatalog, discoverSkillCatalogNames, emitProposalApproved, emitProposalCreated, emitProposalRejected, estimateCost, explicitFindingsCount, extractHighlights, extractTitlePrefix, getAvailableSlots, getDefaultConfig, getPerStateCount, indexSessionDirectory, isCheckTimeoutError, isEligible, isSummaryEnabled, launchTUI, loadPublishedIndex, makeBackendResolver, migrateAgentConfig, normalizeFts5Query, normalizeHarnessCommand, normalizeLocalModel, openSearchIndex, promote, reconcile, recoverFindingsCount, reindexFromArchive, renderAnalysisComment, renderLlmSummaryMarkdown, renderPRComment, resolveEscalationConfig, resolveOrchestratorId, routeIssue, routingWarnings, runGate, runHarnessCheck, savePublishedIndex, searchIndexPath, selectCandidates, selectCheapestQualifying, selectTasks, sortCandidates, summarizeArchivedSession, syncMain, triageIssue, truncateForBudget, validateCustomTasks, validateWorkflowConfig, wireNotificationSinks, workflowFor, wrapAsEnvelope };
5131
+ export { AdaptiveRouter, type AdaptiveRouterDeps, type AgentDispatchResult, type AgentDispatcher, type AgentDispatcherDeps, type AgentUpdateEvent, AnalysisArchive, type AnalysisRecord, type ApplyEventResult, type ArtifactPresence, type AttemptStats, BRAINSTORM_RUBRIC, BUILT_IN_TASKS, BackendDefSchema, type BackendResolver, BackendRouter, type BackendRouterOptions, type BaseRefFallbackEvent, type BrainstormWiringDeps, type BuildArchiveHooksOptions, type BuildWorkflowContextDeps, type CheckCommandResult, type CheckCommandRunner, type CheckFailureClassification, type CheckFailureKind, CheckScriptRunner, ClaimManager, type ClaimManagerConfig, type CleanWorkspaceEffect, type CommandExecResult, type CommandExecutor, type CreateTokenInput, type CreateTokenResult, type CustomTaskValidationError, type DispatchEffect, type EmitLogEffect, type EscalateEffect, EscalationState, type ExecFileAsyncFn, type ExecFileError, type ExecFileFn$1 as ExecFileFn, type FromConfigOptions, GateNotReadyError, type GateResult, GateRunError, type HarnessSpawn, type Highlight, type HighlightsInfo, type IndexedDoc, InteractionQueue, LinearGraphQLClient, type LinearGraphQLClientOptions, type LinearGraphQLExtension, LinearGraphQLStub, type LiveSession, LocalModelResolver, type LocalModelResolverOptions, MAINTENANCE_CHECK_MAX_BUFFER, MAINTENANCE_CHECK_TIMEOUT_MS, MAX_ATTEMPTS, MaintenanceReporter, type MaintenanceReporterOptions, type MarkSkip, type MarkSkipReason, type MigrationResult, MockBackend, type NotificationSink, type NotificationSinkDeliverInput, ORCHESTRATOR_IDENTITY_FILE, Orchestrator, OrchestratorBackendFactory, type OrchestratorBackendFactoryOptions, type OrchestratorContext, type OrchestratorEvent, type OrchestratorState, PRDetector, type PRDetectorLogger, type PRLifecycleManager, type PendingInteraction, type PersistedOutputEntry, PrivacyNoMatch, PromotionError, type PromotionResult, PromptRenderer, type ProposalApprovedData, type ProposalCreatedData, type ProposalRejectedData, type PublishedIndex, type QueueInsertInput, type QueueRow, type QueueStats, RETRY_DELAYS_MS, type RateLimitSnapshot as RateLimitComputeSnapshot, type RateLimitConfig, type RateLimitSnapshot$1 as RateLimitSnapshot, type RecordPrediction, type RegistryEntry, type ReleaseClaimEffect, type ResolverLogger, type RetryEntry, type RetryFiredEvent, RoadmapTrackerAdapter, RoutingConfigSchema, RoutingValueSchema, type RunAttemptPhase, type RunHarnessCheckOptions, type RunMode, type RunOrigin, type RunResult, type RunningEntry, type ScheduleRetryEffect, type SearchOptions, type SelForkGeneratorOptions, type SelectConstraints, type SideEffect, SinkConfigError, SinkRegistry, type SkillCatalogEntry, SlackSink, type SlackSinkOptions, SqliteSearchIndex, type StallDetectedEvent, type StopEffect, type StoredOutcomeRecord, type StreamManifest, StreamRecorder, type SummarizeContext, type SummarizeResult, type SyncMainOptions, type SyncMainResult, type SyncSkipReason, type TaskDefinition, TaskOutputStore, TaskRunner, type TaskRunnerOptions, type TaskSelectionFilter, type TaskType, type TickEvent, TokenStore, type TokenTotals, type TriageConfig, type TriageDecision, type TriageMarkConfig, type TriageMarkDeps, type TriageMarkItem, type TriageMarkResult, type TriageSignals, type TriageSkill, type TriageWiringDeps, type UpdateTokensEffect, type ValidateWorkflowConfigOptions, type ValidatedWorkflowConfig, WebhookQueue, type WiredBrainstormResult, type WorkerExitEvent, WorkflowLoader, type WorkflowRouterDep, WorkspaceHooks, WorkspaceManager, type WorkspaceManagerOptions, applyEvent, artifactPresenceFromIssue, brainstormInputFromIssue, buildArchiveHooks, buildCapabilityRegistry, buildProbeInput, buildWorkflowContext, calculateRetryDelay, canDispatch, classifyCheckExecutionFailure, computeRateLimitDelay, createAgentDispatcher, createBackend, createEmptyState, crossFieldRoutingIssues, defaultFetchModels, defaultPoolCapabilities, deriveSeedPaths, detectScopeTier, discoverSkillCatalog, discoverSkillCatalogNames, emitProposalApproved, emitProposalCreated, emitProposalRejected, enrichIssueWithSpec, estimateCost, explicitFindingsCount, extractHighlights, extractTitlePrefix, getAvailableSlots, getDefaultConfig, getPerStateCount, indexSessionDirectory, isCheckTimeoutError, isEligible, isSummaryEnabled, launchTUI, loadPublishedIndex, makeBackendResolver, makeGraphScope, makeSelForkGenerator, markApprovedForDispatch, migrateAgentConfig, normalizeFts5Query, normalizeHarnessCommand, normalizeLocalModel, openSearchIndex, precedentLookupFromStored, promote, reconcile, recoverFindingsCount, reindexFromArchive, renderAnalysisComment, renderLlmSummaryMarkdown, renderPRComment, renderSpecMarkdown, resolveEscalationConfig, resolveOrchestratorId, routeIssue, routingWarnings, runBrainstormForIssue, runGate, runHarnessCheck, savePublishedIndex, searchIndexPath, selectCandidates, selectCheapestQualifying, selectTasks, slugFor, sortCandidates, summarizeArchivedSession, syncMain, triageIssue, truncateForBudget, validateCustomTasks, validateWorkflowConfig, wireNotificationSinks, workflowFor, wrapAsEnvelope };