@openclawbrain/openclaw 0.1.0 → 0.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.
@@ -1,5 +1,10 @@
1
- import { type ActivationPointerRecordV1, type FeedbackEventKind, type NormalizedEventExportV1, type RouteMode, type RuntimeCompileResponseV1 } from "@openclawbrain/contracts";
2
- import { type ActivationSlotInspection } from "@openclawbrain/pack-format";
1
+ import { CONTRACT_IDS, type ArtifactManifestV1, type ActivationPointerRecordV1, type ActivationPointerSlot, type ContextCompactionMode, type FeedbackEventKind, type FeedbackEventV1, type KernelSurfaceValidationResultV1, type LearningBootProfile, type InteractionEventV1, type NormalizedEventExportV1, type RouteMode, type RuntimeCompileResponseV1, type RuntimeCompileTargetV1, type RuntimeGraphPlasticityStateV1, type RuntimePlasticitySourceV1, type SparseFeedbackPolicyV1, type TeacherSupervisionArtifactV1, type WorkspaceInjectionSurfaceV1 } from "@openclawbrain/contracts";
2
+ import { type AdvanceAlwaysOnLearningRuntimeInput, type AlwaysOnLearningCadenceV1, type AlwaysOnLearningMaterializationJobV1, type AlwaysOnLearningRuntimePlanV1, type AlwaysOnLearningRuntimeStateV1 } from "@openclawbrain/learner";
3
+ import { type ActivationInspection, type ActivationObservabilityReport, type ActivationSlotInspection, type InitHandoffState } from "@openclawbrain/pack-format";
4
+ export declare const DEFAULT_ASYNC_TEACHER_QUEUE_CAPACITY = 8;
5
+ declare const RECORDED_SESSION_TRACE_CONTRACT: "recorded_session_trace.v1";
6
+ declare const RECORDED_SESSION_FIXTURE_CONTRACT: "recorded_session_replay_fixture.v1";
7
+ declare const RECORDED_SESSION_BUNDLE_CONTRACT: "recorded_session_replay_bundle.v1";
3
8
  declare const RUNTIME_EVENT_EXPORT_BUNDLE_CONTRACT: "normalized_event_export_bundle.v1";
4
9
  export declare const RUNTIME_EVENT_EXPORT_BUNDLE_LAYOUT: {
5
10
  readonly manifest: "manifest.json";
@@ -35,7 +40,9 @@ export interface CompileRuntimeContextInput {
35
40
  message: string;
36
41
  agentId?: string;
37
42
  maxContextBlocks?: number;
43
+ maxContextChars?: number;
38
44
  mode?: RouteMode;
45
+ compactionMode?: ContextCompactionMode;
39
46
  runtimeHints?: readonly string[];
40
47
  }
41
48
  export interface ActiveCompileTarget {
@@ -46,20 +53,161 @@ export interface ActiveCompileTarget {
46
53
  export interface RuntimeCompileSuccess {
47
54
  ok: true;
48
55
  fallbackToStaticContext: false;
56
+ hardRequirementViolated: false;
49
57
  activationRoot: string;
50
58
  activePackId: string;
51
59
  packRootDir: string;
52
60
  compileResponse: RuntimeCompileResponseV1;
53
61
  brainContext: string;
54
62
  }
55
- export interface RuntimeCompileFailure {
63
+ export interface RuntimeCompileFailOpenFailure {
56
64
  ok: false;
57
65
  fallbackToStaticContext: true;
66
+ hardRequirementViolated: false;
58
67
  activationRoot: string;
59
68
  error: string;
60
69
  brainContext: string;
61
70
  }
71
+ export interface RuntimeCompileHardFailure {
72
+ ok: false;
73
+ fallbackToStaticContext: false;
74
+ hardRequirementViolated: true;
75
+ activationRoot: string;
76
+ error: string;
77
+ brainContext: string;
78
+ }
79
+ export type RuntimeCompileFailure = RuntimeCompileFailOpenFailure | RuntimeCompileHardFailure;
62
80
  export type RuntimeCompileResult = RuntimeCompileSuccess | RuntimeCompileFailure;
81
+ export interface AttachStatusInput {
82
+ activationRoot: string;
83
+ compile?: false | Omit<CompileRuntimeContextInput, "activationRoot">;
84
+ }
85
+ export type ContextContributionEvidenceState = "route_fn_and_brain_context" | "brain_context_only" | "route_fn_only" | "stable_kernel_only" | "fail_open_static_context" | "hard_fail" | "unprobed";
86
+ export interface ContextAttributionSummaryV1 {
87
+ selectedContextCount: number;
88
+ stableKernelBlockCount: number;
89
+ brainCompiledBlockCount: number;
90
+ stableKernelSources: string[];
91
+ brainCompiledSources: string[];
92
+ selectionTiers: string | null;
93
+ evidence: ContextContributionEvidenceState;
94
+ detail: string;
95
+ }
96
+ export interface AttachCompileStatusV1 {
97
+ ok: boolean;
98
+ fallbackToStaticContext: boolean;
99
+ hardRequirementViolated: boolean;
100
+ activePackId: string | null;
101
+ usedLearnedRouteFn: boolean | null;
102
+ routerIdentity: string | null;
103
+ initMode: string | null;
104
+ handoffState: string | null;
105
+ seedSources: string[];
106
+ contextAttribution: ContextAttributionSummaryV1;
107
+ notes: string[];
108
+ error: string | null;
109
+ }
110
+ export interface OpenClawCompileBoundaryV1 {
111
+ contract: typeof CONTRACT_IDS.runtimeCompile;
112
+ activationSlot: "active";
113
+ entrypoint: "compileRuntimeContext";
114
+ servedFromCandidateBeforePromotion: false;
115
+ learnedRouteEvidenceRequiredWhenManifestRequiresIt: true;
116
+ }
117
+ export interface OpenClawEventExportBoundaryV1 {
118
+ emittedContracts: readonly [typeof CONTRACT_IDS.interactionEvents, typeof CONTRACT_IDS.feedbackEvents];
119
+ entrypoint: "runRuntimeTurn";
120
+ bundleWriteOptional: true;
121
+ writeFailuresEraseSuccessfulCompile: false;
122
+ learningHandoffStaysOffHotPath: true;
123
+ }
124
+ export interface OpenClawActivePackBoundaryV1 {
125
+ servingSlot: "active";
126
+ inspectableSlots: readonly ActivationPointerSlot[];
127
+ candidateServedBeforePromotion: false;
128
+ previousSlotUsedForRollback: true;
129
+ }
130
+ export interface OpenClawPromotionBoundaryV1 {
131
+ candidateSlot: "candidate";
132
+ activeSlot: "active";
133
+ previousSlot: "previous";
134
+ requiresActivationReadyCandidate: true;
135
+ compileSeesCandidateOnlyAfterPromotion: true;
136
+ promotionHappensOffHotPath: true;
137
+ }
138
+ export interface OpenClawFailOpenSemanticsV1 {
139
+ missingActivePackFallsBackToStaticContext: true;
140
+ learnedRequiredRouteArtifactDriftHardFails: true;
141
+ hardFailuresDisableStaticFallback: true;
142
+ eventExportWriteFailurePreservesCompile: true;
143
+ }
144
+ export interface OpenClawLandingBoundariesV1 {
145
+ compileBoundary: OpenClawCompileBoundaryV1;
146
+ eventExportBoundary: OpenClawEventExportBoundaryV1;
147
+ activePackBoundary: OpenClawActivePackBoundaryV1;
148
+ promotionBoundary: OpenClawPromotionBoundaryV1;
149
+ failOpenSemantics: OpenClawFailOpenSemanticsV1;
150
+ runtimeResponsibilities: string[];
151
+ brainResponsibilities: string[];
152
+ }
153
+ export interface AttachStatusSnapshotV1 {
154
+ runtimeOwner: "openclaw";
155
+ activationRoot: string;
156
+ inspection: ActivationInspection;
157
+ activeObservability: ActivationObservabilityReport | null;
158
+ compile: AttachCompileStatusV1 | null;
159
+ landingBoundaries: OpenClawLandingBoundariesV1;
160
+ successSignals: string[];
161
+ }
162
+ export interface RollbackRuntimeAttachInput {
163
+ activationRoot: string;
164
+ updatedAt?: string;
165
+ dryRun?: boolean;
166
+ }
167
+ export interface RollbackRuntimeAttachResult {
168
+ runtimeOwner: "openclaw";
169
+ activationRoot: string;
170
+ updatedAt: string;
171
+ dryRun: boolean;
172
+ allowed: boolean;
173
+ findings: string[];
174
+ before: {
175
+ activePackId: string | null;
176
+ candidatePackId: string | null;
177
+ previousPackId: string | null;
178
+ };
179
+ after: {
180
+ activePackId: string | null;
181
+ candidatePackId: string | null;
182
+ previousPackId: string | null;
183
+ } | null;
184
+ restoredPackId: string | null;
185
+ parkedCandidatePackId: string | null;
186
+ }
187
+ export interface BootstrapRuntimeAttachInput {
188
+ activationRoot: string;
189
+ packRoot: string;
190
+ packLabel: string;
191
+ workspace: AdvanceAlwaysOnLearningRuntimeInput["workspace"];
192
+ normalizedEventExport?: NormalizedEventExportV1;
193
+ interactionEvents?: readonly InteractionEventV1[];
194
+ feedbackEvents?: readonly FeedbackEventV1[];
195
+ learnedRouting?: boolean;
196
+ builtAt?: string;
197
+ activatedAt?: string;
198
+ offlineArtifacts?: string[];
199
+ structuralOps?: Partial<ArtifactManifestV1["graphDynamics"]["structuralOps"]>;
200
+ sparseFeedback?: Partial<SparseFeedbackPolicyV1>;
201
+ compile?: false | Omit<CompileRuntimeContextInput, "activationRoot">;
202
+ }
203
+ export interface BootstrapRuntimeAttachResult {
204
+ runtimeOwner: "openclaw";
205
+ activationRoot: string;
206
+ packRoot: string;
207
+ packId: string;
208
+ normalizedEventExport: NormalizedEventExportV1;
209
+ status: AttachStatusSnapshotV1;
210
+ }
63
211
  export interface RuntimeTurnCompileInput {
64
212
  createdAt?: string | null;
65
213
  sequence?: number | null;
@@ -130,6 +278,183 @@ export type RuntimeTurnResult = RuntimeCompileResult & {
130
278
  eventExport: RuntimeEventExportResult;
131
279
  warnings: string[];
132
280
  };
281
+ export type TeacherLoopNoOpReason = "none" | "duplicate_export" | "queue_full" | "no_teacher_artifacts";
282
+ export interface AsyncTeacherLiveLoopInput extends Pick<AdvanceAlwaysOnLearningRuntimeInput, "packLabel" | "workspace" | "learnedRouting" | "builtAt" | "offlineArtifacts" | "structuralOps" | "sparseFeedback" | "liveSliceSize" | "backfillSliceSize" | "cadence"> {
283
+ maxQueuedExports?: number;
284
+ staleAfterMs?: number;
285
+ }
286
+ export interface AsyncTeacherQueuedExportJobV1 {
287
+ jobId: string;
288
+ exportDigest: string;
289
+ observedAt: string;
290
+ normalizedEventExport: NormalizedEventExportV1;
291
+ }
292
+ export interface AsyncTeacherLiveLoopDiagnosticsV1 {
293
+ acceptedExportCount: number;
294
+ processedExportCount: number;
295
+ duplicateExportCount: number;
296
+ droppedExportCount: number;
297
+ emittedArtifactCount: number;
298
+ dedupedArtifactCount: number;
299
+ lastProcessedAt: string | null;
300
+ latestFreshness: TeacherSupervisionArtifactV1["freshness"]["status"] | "none";
301
+ lastNoOpReason: TeacherLoopNoOpReason;
302
+ notes: string[];
303
+ }
304
+ export interface AsyncTeacherLiveLoopSnapshotV1 {
305
+ runtimeOwner: "openclaw";
306
+ queue: {
307
+ capacity: number;
308
+ depth: number;
309
+ running: boolean;
310
+ };
311
+ teacher: {
312
+ artifactCount: number;
313
+ artifacts: TeacherSupervisionArtifactV1[];
314
+ latestFreshness: TeacherSupervisionArtifactV1["freshness"]["status"] | "none";
315
+ };
316
+ learner: {
317
+ state: AlwaysOnLearningRuntimeStateV1;
318
+ lastMaterialization: AlwaysOnLearningMaterializationJobV1 | null;
319
+ };
320
+ diagnostics: AsyncTeacherLiveLoopDiagnosticsV1;
321
+ }
322
+ export interface AsyncTeacherEnqueueResultV1 {
323
+ accepted: boolean;
324
+ exportDigest: string;
325
+ queueDepth: number;
326
+ notes: string[];
327
+ reason: Exclude<TeacherLoopNoOpReason, "none"> | null;
328
+ }
329
+ export interface CanonicalSupervisionFeedbackRecordV1 {
330
+ eventId: string;
331
+ kind: FeedbackEventKind;
332
+ sequence: number;
333
+ createdAt: string;
334
+ content: string;
335
+ relatedInteractionId: string | null;
336
+ }
337
+ export interface CanonicalSupervisionV1 {
338
+ runtimeOwner: "openclaw";
339
+ exportDigest: string;
340
+ supervisionDigest: string;
341
+ sessionId: string | null;
342
+ channel: string | null;
343
+ eventRange: Pick<NormalizedEventExportV1["range"], "start" | "end" | "count">;
344
+ sourceStreams: string[];
345
+ humanLabelCount: number;
346
+ selfLabelCount: number;
347
+ feedbackCounts: {
348
+ corrections: number;
349
+ teachings: number;
350
+ approvals: number;
351
+ suppressions: number;
352
+ };
353
+ compilePackIds: string[];
354
+ relatedInteractionIds: string[];
355
+ feedback: CanonicalSupervisionFeedbackRecordV1[];
356
+ }
357
+ export interface ContinuousProductLoopPackVersionV1 {
358
+ version: number;
359
+ packId: string;
360
+ routePolicy: RuntimeCompileTargetV1["routePolicy"];
361
+ routerIdentity: string | null;
362
+ workspaceSnapshot: string;
363
+ workspaceRevision: string | null;
364
+ eventRange: RuntimeCompileTargetV1["eventRange"];
365
+ eventExportDigest: string | null;
366
+ builtAt: string;
367
+ }
368
+ export interface ContinuousProductLoopStateV1 {
369
+ runtimeOwner: "openclaw";
370
+ activationRoot: string;
371
+ loopRoot: string;
372
+ interactionEvents: InteractionEventV1[];
373
+ feedbackEvents: FeedbackEventV1[];
374
+ learner: AlwaysOnLearningRuntimeStateV1;
375
+ runtimePlasticity: RuntimeGraphPlasticityStateV1 | null;
376
+ activePackVersion: number;
377
+ currentActivePack: ContinuousProductLoopPackVersionV1 | null;
378
+ candidatePack: ContinuousProductLoopPackVersionV1 | null;
379
+ packLineage: ContinuousProductLoopPackVersionV1[];
380
+ nextPackVersion: number;
381
+ promotionCount: number;
382
+ lastSupervision: CanonicalSupervisionV1 | null;
383
+ }
384
+ export interface ContinuousProductLoopLearningUpdateV1 {
385
+ warnings: string[];
386
+ supervisionDigest: string | null;
387
+ bridgeDigest: string | null;
388
+ selectedSliceIds: string[];
389
+ materializationJobId: string | null;
390
+ materializationReason: AlwaysOnLearningMaterializationJobV1["reason"] | null;
391
+ materializationLane: AlwaysOnLearningMaterializationJobV1["lane"] | null;
392
+ candidateRootDir: string | null;
393
+ candidatePack: ContinuousProductLoopPackVersionV1 | null;
394
+ runtimePlasticity: RuntimeGraphPlasticityStateV1 | null;
395
+ promotionAllowed: boolean;
396
+ promotionFindings: string[];
397
+ promoted: boolean;
398
+ }
399
+ export interface RunContinuousProductLoopTurnInput {
400
+ activationRoot: string;
401
+ loopRoot: string;
402
+ packLabel: string;
403
+ workspace: AdvanceAlwaysOnLearningRuntimeInput["workspace"];
404
+ turn: OpenClawRuntimeTurnInput;
405
+ state?: ContinuousProductLoopStateV1;
406
+ learnedRouting?: boolean;
407
+ failOpen?: boolean;
408
+ autoPromote?: boolean;
409
+ candidateBuiltAt?: string | null;
410
+ stageUpdatedAt?: string | null;
411
+ promoteUpdatedAt?: string | null;
412
+ offlineArtifacts?: string[];
413
+ structuralOps?: Partial<ArtifactManifestV1["graphDynamics"]["structuralOps"]>;
414
+ sparseFeedback?: Partial<SparseFeedbackPolicyV1>;
415
+ liveSliceSize?: number;
416
+ backfillSliceSize?: number;
417
+ cadence?: Partial<AlwaysOnLearningCadenceV1>;
418
+ }
419
+ export interface ContinuousProductLoopTurnResultV1 {
420
+ runtimeOwner: "openclaw";
421
+ compileActiveVersion: number;
422
+ compileActivePackId: string | null;
423
+ turn: RuntimeTurnResult;
424
+ supervision: CanonicalSupervisionV1 | null;
425
+ learning: ContinuousProductLoopLearningUpdateV1;
426
+ state: ContinuousProductLoopStateV1;
427
+ }
428
+ export declare function buildCanonicalSupervision(normalizedEventExport: NormalizedEventExportV1): CanonicalSupervisionV1;
429
+ export declare function createContinuousProductLoopState(input: {
430
+ activationRoot: string;
431
+ loopRoot: string;
432
+ }): ContinuousProductLoopStateV1;
433
+ export declare class AsyncTeacherLiveLoop {
434
+ private readonly input;
435
+ private readonly queueCapacity;
436
+ private readonly staleAfterMs;
437
+ private readonly queuedExportDigests;
438
+ private readonly seenExportDigests;
439
+ private queue;
440
+ private drainPromise;
441
+ private interactionEvents;
442
+ private feedbackEvents;
443
+ private teacherArtifacts;
444
+ private learnerState;
445
+ private lastMaterialization;
446
+ private diagnostics;
447
+ constructor(input: AsyncTeacherLiveLoopInput);
448
+ enqueueNormalizedEventExport(normalizedEventExport: NormalizedEventExportV1, options?: {
449
+ observedAt?: string;
450
+ }): AsyncTeacherEnqueueResultV1;
451
+ flush(): Promise<AsyncTeacherLiveLoopSnapshotV1>;
452
+ snapshot(): AsyncTeacherLiveLoopSnapshotV1;
453
+ private ensureDrain;
454
+ private drain;
455
+ private refreshNotes;
456
+ }
457
+ export declare function createAsyncTeacherLiveLoop(input: AsyncTeacherLiveLoopInput): AsyncTeacherLiveLoop;
133
458
  export declare function buildRuntimeEventExportBundleManifest(input: {
134
459
  exportName: string;
135
460
  exportedAt: string;
@@ -142,7 +467,370 @@ export declare function classifyFeedbackKind(content: string): FeedbackEventKind
142
467
  export declare function formatPromptContext(compileResponse: RuntimeCompileResponseV1): string;
143
468
  export declare function resolveActivePackForCompile(activationRoot: string): ActiveCompileTarget;
144
469
  export declare function compileRuntimeContext(input: CompileRuntimeContextInput): RuntimeCompileResult;
470
+ export declare function describeAttachStatus(input: AttachStatusInput): AttachStatusSnapshotV1;
471
+ export declare function rollbackRuntimeAttach(input: RollbackRuntimeAttachInput): RollbackRuntimeAttachResult;
472
+ export declare function bootstrapRuntimeAttach(input: BootstrapRuntimeAttachInput): BootstrapRuntimeAttachResult;
145
473
  export declare function buildNormalizedRuntimeEventExport(turn: OpenClawRuntimeTurnInput, compileResult: RuntimeCompileResult): NormalizedEventExportV1;
146
474
  export declare function writeRuntimeEventExportBundle(turn: OpenClawRuntimeTurnInput, normalizedEventExport: NormalizedEventExportV1): RuntimeEventExportNoWrite | RuntimeEventExportWriteSuccess;
147
475
  export declare function runRuntimeTurn(turn: OpenClawRuntimeTurnInput, options?: RunRuntimeTurnOptions): RuntimeTurnResult;
148
- export {};
476
+ export declare function runContinuousProductLoopTurn(input: RunContinuousProductLoopTurnInput): ContinuousProductLoopTurnResultV1;
477
+ export type RecordedSessionReplayMode = "no_brain" | "seed_pack" | "learned_replay";
478
+ export interface RecordedSessionReplayWorkspaceV1 {
479
+ workspaceId: string;
480
+ snapshotId: string;
481
+ capturedAt: string;
482
+ rootDir: string;
483
+ branch?: string;
484
+ revision: string;
485
+ labels?: string[];
486
+ }
487
+ export interface RecordedSessionSeedCueV1 {
488
+ cueId: string;
489
+ createdAt: string;
490
+ content: string;
491
+ kind?: FeedbackEventKind;
492
+ }
493
+ export interface RecordedSessionTraceFeedbackV1 {
494
+ createdAt: string;
495
+ content: string;
496
+ kind?: FeedbackEventKind | null;
497
+ }
498
+ export interface RecordedSessionTraceTurnV1 {
499
+ turnId?: string;
500
+ createdAt: string;
501
+ deliveredAt?: string | null;
502
+ userMessage: string;
503
+ runtimeHints?: readonly string[];
504
+ feedback?: readonly RecordedSessionTraceFeedbackV1[];
505
+ expectedContextPhrases: readonly string[];
506
+ minimumPhraseHits?: number;
507
+ }
508
+ export interface RecordedSessionTraceV1 {
509
+ contract: typeof RECORDED_SESSION_TRACE_CONTRACT;
510
+ traceId: string;
511
+ source: "sanitized_recorded_session";
512
+ recordedAt: string;
513
+ bundleBuiltAt: string;
514
+ agentId?: string | null;
515
+ sessionId: string;
516
+ channel: string;
517
+ sourceStream: string;
518
+ privacy: {
519
+ sanitized: true;
520
+ notes: string[];
521
+ };
522
+ workspace: RecordedSessionReplayWorkspaceV1;
523
+ seedBuiltAt: string;
524
+ seedActivatedAt: string;
525
+ seedCues: readonly RecordedSessionSeedCueV1[];
526
+ turns: readonly RecordedSessionTraceTurnV1[];
527
+ }
528
+ export interface RecordedSessionReplayTurnFixtureV1 {
529
+ turnId: string;
530
+ turn: OpenClawRuntimeTurnInput;
531
+ expectedContextPhrases: string[];
532
+ minimumPhraseHits: number;
533
+ }
534
+ export interface RecordedSessionReplayFixtureV1 {
535
+ contract: typeof RECORDED_SESSION_FIXTURE_CONTRACT;
536
+ traceId: string;
537
+ source: RecordedSessionTraceV1["source"];
538
+ recordedAt: string;
539
+ bundleBuiltAt: string;
540
+ traceHash: string;
541
+ fixtureHash: string;
542
+ privacy: RecordedSessionTraceV1["privacy"];
543
+ workspace: RecordedSessionReplayWorkspaceV1;
544
+ seedBuiltAt: string;
545
+ seedActivatedAt: string;
546
+ seedExport: NormalizedEventExportV1;
547
+ turns: RecordedSessionReplayTurnFixtureV1[];
548
+ }
549
+ export interface RecordedSessionReplayTurnReportV1 {
550
+ turnId: string;
551
+ compileOk: boolean;
552
+ fallbackToStaticContext: boolean;
553
+ hardRequirementViolated: boolean;
554
+ activePackId: string | null;
555
+ usedLearnedRouteFn: boolean;
556
+ routerIdentity: string | null;
557
+ selectionDigest: string | null;
558
+ selectedContextIds: string[];
559
+ selectedContextTexts: string[];
560
+ eventExportDigest: string | null;
561
+ expectedContextPhrases: string[];
562
+ minimumPhraseHits: number;
563
+ phraseHits: string[];
564
+ missedPhrases: string[];
565
+ qualityScore: number;
566
+ compileActiveVersion: number | null;
567
+ promoted: boolean;
568
+ warnings: string[];
569
+ }
570
+ export interface RecordedSessionReplayModeSummaryV1 {
571
+ mode: RecordedSessionReplayMode;
572
+ qualityScore: number;
573
+ compileOkCount: number;
574
+ phraseHitCount: number;
575
+ phraseCount: number;
576
+ usedLearnedRouteTurnCount: number;
577
+ promotionCount: number;
578
+ packIds: string[];
579
+ scoreHash: string;
580
+ }
581
+ export interface RecordedSessionReplayModeReportV1 {
582
+ mode: RecordedSessionReplayMode;
583
+ summary: RecordedSessionReplayModeSummaryV1;
584
+ turns: RecordedSessionReplayTurnReportV1[];
585
+ }
586
+ export interface RecordedSessionReplayBundleV1 {
587
+ contract: typeof RECORDED_SESSION_BUNDLE_CONTRACT;
588
+ traceId: string;
589
+ source: RecordedSessionReplayFixtureV1["source"];
590
+ recordedAt: string;
591
+ generatedAt: string;
592
+ traceHash: string;
593
+ fixtureHash: string;
594
+ scoreHash: string;
595
+ bundleHash: string;
596
+ privacy: RecordedSessionReplayFixtureV1["privacy"];
597
+ modes: RecordedSessionReplayModeReportV1[];
598
+ summary: {
599
+ winnerMode: RecordedSessionReplayMode | null;
600
+ ranking: Array<{
601
+ mode: RecordedSessionReplayMode;
602
+ qualityScore: number;
603
+ }>;
604
+ };
605
+ }
606
+ export interface RecordedSessionReplayRescoreReportV1 {
607
+ scoreHash: string;
608
+ modes: Array<{
609
+ mode: RecordedSessionReplayMode;
610
+ qualityScore: number;
611
+ scoreHash: string;
612
+ }>;
613
+ }
614
+ export interface RecordedSessionReplayBundleHashVerificationV1 {
615
+ bundleHashMatches: boolean;
616
+ scoreHashMatches: boolean;
617
+ }
618
+ export declare function buildRecordedSessionReplayFixture(trace: RecordedSessionTraceV1): RecordedSessionReplayFixtureV1;
619
+ export declare function runRecordedSessionReplay(rootDir: string, fixture: RecordedSessionReplayFixtureV1): RecordedSessionReplayBundleV1;
620
+ export declare function rescoreRecordedSessionReplayBundle(bundle: RecordedSessionReplayBundleV1): RecordedSessionReplayRescoreReportV1;
621
+ export declare function verifyRecordedSessionReplayBundleHashes(bundle: RecordedSessionReplayBundleV1): RecordedSessionReplayBundleHashVerificationV1;
622
+ export type OperatorSurfaceStatus = "ok" | "warn" | "fail";
623
+ export type OperatorFindingSeverity = "pass" | "warn" | "fail";
624
+ export type OperatorLastPromotionConfidence = "proven_from_previous_pointer" | "unknown_from_local_pointers" | "no_active_pack";
625
+ export type OperatorBrainState = InitHandoffState | "no_active_pack";
626
+ export type OperatorServePathState = "serving_active_pack" | "fail_open_static_context" | "hard_fail" | "unprobed";
627
+ export interface OperatorSurfaceInput {
628
+ activationRoot: string;
629
+ updatedAt?: string | null;
630
+ eventExportPath?: string | null;
631
+ teacherSnapshotPath?: string | null;
632
+ }
633
+ export interface OperatorSurfaceSlotSummary {
634
+ slot: ActivationPointerSlot;
635
+ packId: string;
636
+ activationReady: boolean;
637
+ routePolicy: RuntimeCompileTargetV1["routePolicy"];
638
+ routerIdentity: string | null;
639
+ workspaceSnapshot: string;
640
+ workspaceRevision: string | null;
641
+ eventRange: RuntimeCompileTargetV1["eventRange"];
642
+ eventExportDigest: string | null;
643
+ builtAt: string;
644
+ updatedAt: string | null;
645
+ findings: string[];
646
+ }
647
+ export interface OperatorLastPromotionSummary {
648
+ known: boolean;
649
+ at: string | null;
650
+ confidence: OperatorLastPromotionConfidence;
651
+ note: string;
652
+ }
653
+ export interface OperatorBrainStateSummary {
654
+ state: OperatorBrainState;
655
+ initMode: LearningBootProfile | null;
656
+ runtimePlasticitySource: RuntimePlasticitySourceV1 | null;
657
+ seedStateVisible: boolean;
658
+ seedBlockCount: number;
659
+ activePackId: string | null;
660
+ activeWorkspaceSnapshot: string | null;
661
+ activeEventExportDigest: string | null;
662
+ detail: string;
663
+ }
664
+ export interface OperatorServePathSummary {
665
+ state: OperatorServePathState;
666
+ fallbackToStaticContext: boolean;
667
+ hardRequirementViolated: boolean;
668
+ activePackId: string | null;
669
+ usedLearnedRouteFn: boolean | null;
670
+ routerIdentity: string | null;
671
+ selectionMode: string | null;
672
+ refreshStatus: string | null;
673
+ freshnessChecksum: string | null;
674
+ contextAttribution: ContextAttributionSummaryV1;
675
+ error: string | null;
676
+ }
677
+ export interface OperatorDoctorFinding {
678
+ severity: OperatorFindingSeverity;
679
+ code: string;
680
+ summary: string;
681
+ detail: string;
682
+ }
683
+ export interface OperatorSupervisionSummary {
684
+ available: boolean;
685
+ sourcePath: string | null;
686
+ sourceKind: "bundle_root" | "payload" | "missing";
687
+ exportDigest: string | null;
688
+ flowing: boolean | null;
689
+ sourceCount: number;
690
+ freshestSourceStream: string | null;
691
+ freshestCreatedAt: string | null;
692
+ freshestKind: string | null;
693
+ humanLabelCount: number | null;
694
+ sources: string[];
695
+ detail: string;
696
+ }
697
+ export interface OperatorTeacherLoopSummary {
698
+ available: boolean;
699
+ sourcePath: string | null;
700
+ lastNoOpReason: TeacherLoopNoOpReason | "unavailable";
701
+ latestFreshness: AsyncTeacherLiveLoopDiagnosticsV1["latestFreshness"] | "unavailable";
702
+ lastProcessedAt: string | null;
703
+ queueDepth: number | null;
704
+ queueCapacity: number | null;
705
+ running: boolean | null;
706
+ lastMaterializedPackId: string | null;
707
+ notes: string[];
708
+ detail: string;
709
+ }
710
+ export interface OperatorLearningSummary {
711
+ available: boolean;
712
+ sourcePath: string | null;
713
+ bootstrapped: boolean | null;
714
+ mode: AlwaysOnLearningRuntimePlanV1["mode"] | "unavailable";
715
+ nextPriorityLane: AlwaysOnLearningRuntimePlanV1["nextPriorityLane"] | "unavailable";
716
+ pendingLive: number | null;
717
+ pendingBackfill: number | null;
718
+ pendingTotal: number | null;
719
+ freshLivePriority: boolean | null;
720
+ learnedRange: RuntimeCompileTargetV1["eventRange"] | null;
721
+ materializationCount: number | null;
722
+ lastMaterializedAt: string | null;
723
+ lastMaterializationReason: AlwaysOnLearningMaterializationJobV1["reason"] | null;
724
+ lastMaterializationLane: AlwaysOnLearningMaterializationJobV1["lane"] | null;
725
+ lastMaterializationPriority: AlwaysOnLearningMaterializationJobV1["priority"] | null;
726
+ lastMaterializedPackId: string | null;
727
+ detail: string;
728
+ }
729
+ export interface OperatorSurfaceReport {
730
+ generatedAt: string;
731
+ activationRoot: string;
732
+ status: OperatorSurfaceStatus;
733
+ active: OperatorSurfaceSlotSummary | null;
734
+ candidate: OperatorSurfaceSlotSummary | null;
735
+ previous: OperatorSurfaceSlotSummary | null;
736
+ freshness: {
737
+ activeBehindPromotionReadyCandidate: boolean;
738
+ candidateAheadBy: string[];
739
+ };
740
+ brain: OperatorBrainStateSummary;
741
+ learnedRouting: {
742
+ required: boolean;
743
+ available: boolean;
744
+ routerIdentity: string | null;
745
+ routeFnVersion: string | null;
746
+ trainingMethod: string | null;
747
+ routerTrainedAt: string | null;
748
+ objective: string | null;
749
+ pgProfile: ActivationObservabilityReport["learnedRouteFn"]["pgProfile"];
750
+ objectiveChecksum: string | null;
751
+ updateMechanism: string | null;
752
+ updateVersion: string | null;
753
+ updateCount: number | null;
754
+ supervisionCount: number | null;
755
+ collectedLabelsTotal: number | null;
756
+ freshnessChecksum: string | null;
757
+ handoffState: InitHandoffState;
758
+ initMode: LearningBootProfile | null;
759
+ seedStateVisible: boolean;
760
+ };
761
+ servePath: OperatorServePathSummary;
762
+ promotion: {
763
+ allowed: boolean;
764
+ findings: string[];
765
+ lastPromotion: OperatorLastPromotionSummary;
766
+ activeUpdatedAt: string | null;
767
+ candidateUpdatedAt: string | null;
768
+ previousUpdatedAt: string | null;
769
+ };
770
+ rollback: {
771
+ allowed: boolean;
772
+ findings: string[];
773
+ previousPackId: string | null;
774
+ state: "ready" | "blocked" | "unknown";
775
+ };
776
+ supervision: OperatorSupervisionSummary;
777
+ learning: OperatorLearningSummary;
778
+ teacherLoop: OperatorTeacherLoopSummary;
779
+ findings: OperatorDoctorFinding[];
780
+ }
781
+ export declare function buildOperatorSurfaceReport(input: OperatorSurfaceInput): OperatorSurfaceReport;
782
+ export declare function formatOperatorRollbackReport(result: RollbackRuntimeAttachResult): string;
783
+ export declare function formatOperatorStatusReport(report: OperatorSurfaceReport): string;
784
+ export declare function formatOperatorDoctorReport(report: OperatorSurfaceReport): string;
785
+ /**
786
+ * A per-turn summary of what was kernel-injected vs brain-compiled in a given
787
+ * compile response. Useful for operator observability and debugging.
788
+ *
789
+ * "Kernel" content is whatever the operator injected directly in the system
790
+ * prompt — this function cannot observe it, only describe the brain side.
791
+ * The `kernelSurface` field is present only when the caller supplies a surface
792
+ * descriptor (from `WorkspaceInjectionSurfaceV1`) alongside the compile
793
+ * response; otherwise it is null.
794
+ */
795
+ export interface KernelBrainBoundaryDescriptionV1 {
796
+ /**
797
+ * Summary of what the brain compiler contributed to this turn.
798
+ */
799
+ brain: {
800
+ packId: string;
801
+ mode: "learned" | "heuristic";
802
+ selectedBlockCount: number;
803
+ /** Roles of the selected blocks, deduplicated. */
804
+ selectedRoles: string[];
805
+ /** Whether the learned route_fn ran (true means learned routing was used). */
806
+ usedLearnedRouteFn: boolean;
807
+ /** Whether context was compacted due to char budget pressure. */
808
+ compactionApplied: boolean;
809
+ };
810
+ /**
811
+ * Validation result for the operator-supplied kernel surface descriptor.
812
+ * Null when no surface descriptor was supplied.
813
+ */
814
+ kernelValidation: KernelSurfaceValidationResultV1 | null;
815
+ /**
816
+ * Advisory: based on the compile diagnostics, is the brain context likely
817
+ * covering the query well, or should the operator investigate pack freshness?
818
+ *
819
+ * - `"likely_covered"` — learned routing ran and found token-matched blocks.
820
+ * - `"partial"` — some token matches, but mode was heuristic or routing gap.
821
+ * - `"likely_gap"` — no token matches or heuristic-only; pack may need refresh.
822
+ */
823
+ brainCoverageAdvisory: "likely_covered" | "partial" | "likely_gap";
824
+ }
825
+ /**
826
+ * Describes the kernel/brain boundary for a single compile response.
827
+ *
828
+ * Combines:
829
+ * - Brain context summary (from the compile response diagnostics)
830
+ * - Kernel surface validation (if a surface descriptor is supplied)
831
+ * - A coverage advisory based on routing signals
832
+ *
833
+ * See `docs/kernel-brain-boundary.md` for the full decision framework.
834
+ */
835
+ export declare function describeKernelBrainBoundary(compileResponse: RuntimeCompileResponseV1, surface?: WorkspaceInjectionSurfaceV1): KernelBrainBoundaryDescriptionV1;
836
+ export type { BrainEligibleContentKind, KernelContentKind, KernelSurfaceValidationResultV1, WorkspaceInjectionSurfaceV1 } from "@openclawbrain/contracts";