@principles/workbuddy-adapter 0.11.2 → 0.11.4

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.
@@ -17,7 +17,7 @@ export interface WorkbuddyWorkerCycleStepReport {
17
17
  readonly downstream: InternalizationConsumerCycleOutcome | null;
18
18
  /** PRI-1296: bounded exact-target evidence reconcile, before candidate picking. */
19
19
  readonly targetEvidenceReconcile?: TargetEvidenceReconcileReport;
20
- /** Phase B Stage-2 review step (always last, ≤2 candidates / ≤60s aggregate). */
20
+ /** Phase B Stage-2 review step (after downstream, ≤2 candidates / ≤60s aggregate). */
21
21
  readonly stage2?: Stage2CorrectionCycleReport;
22
22
  readonly idleAudit?: RunIdleTurnAuditCycleReport;
23
23
  }
@@ -44,6 +44,9 @@ export interface WorkbuddyWorkerCycleOptions {
44
44
  /** Stage-2 classifier injection (tests); undefined = resolve from config. */
45
45
  readonly stage2Classifier?: SignalLlmClassifier | null;
46
46
  readonly stage2AggregateBudgetMs?: number;
47
+ /** Test seams for the bounded, consent-gated correction optimization tail. */
48
+ readonly correctionObserverMinIntervalMs?: number;
49
+ readonly correctionObserverTimeoutMs?: number;
47
50
  /** Test seam: undefined = production auditor resolution; null = explicitly unavailable. */
48
51
  readonly idleTurnAuditor?: IdleTurnAuditor | null;
49
52
  }
@@ -33,7 +33,7 @@
33
33
  import fs from 'node:fs';
34
34
  import path from 'node:path';
35
35
  import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, pickDiagnosticianCandidate, reconcileWaitingTargetEvidenceTasks, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, } from '@principles/core/runtime';
36
- import { loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, executeQueuedDiagnosisWithInboxRecovery, runInternalizationConsumerCycle, runStage2CorrectionCycle, runIdleTurnAuditCycle, createIdleTurnAuditorForWorkspace, createSignalClassifierForWorkspace, resolveWorkspacePipelineHostDeps, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
36
+ import { loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, executeQueuedDiagnosisWithInboxRecovery, runInternalizationConsumerCycle, runStage2CorrectionCycle, runCorrectionObserverOptimizationCycle, openGovernanceCorrectionTrajectory, updateSignalHealth, runIdleTurnAuditCycle, createIdleTurnAuditorForWorkspace, createSignalClassifierForWorkspace, createConsentLedgerSourceMaterialAuthorization, resolveWorkspacePipelineHostDeps, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
37
37
  import { WORKBUDDY_TOOL_SEMANTICS, WORKBUDDY_TOOL_SEMANTIC_MAPPINGS } from '../tool-semantics.js';
38
38
  import { catchUpWorkbuddyIngestion } from '../ingestion/catch-up.js';
39
39
  import { readWorkbuddyTargetTurnEvidence } from '../ingestion/pain-receipt-fallback.js';
@@ -220,6 +220,7 @@ export async function runWorkbuddyWorkspaceWorkerCycle(options) {
220
220
  stageDeadline: new Date(cycleStartedAt.getTime() + LIVENESS_STAGE_DEADLINE_MS.catch_up).toISOString(),
221
221
  lastCycleDriver: workbuddyWorkerCycleDriver(),
222
222
  });
223
+ const sourceMaterialAuthorization = createConsentLedgerSourceMaterialAuthorization(workspaceDir);
223
224
  const consumerFlag = loadFeatureFlagFromConfig(workspaceDir, 'internalization_auto_consumer', { info: (m) => logger.info(m), warn: (m) => logger.warn(m) });
224
225
  // The Diagnostician capability gate resolves from the same canonical
225
226
  // authority as the runtime factory. An Owner-disabled agent is an
@@ -315,6 +316,7 @@ export async function runWorkbuddyWorkspaceWorkerCycle(options) {
315
316
  const hostDeps = resolveWorkspacePipelineHostDeps({
316
317
  workspaceDir,
317
318
  effectiveConfig: config.effective,
319
+ sourceMaterialAuthorization,
318
320
  telemetryPersistenceFailureHandler: (detail) => {
319
321
  try {
320
322
  emitEvent('WORKBUDDY_WORKER_CRITICAL_TELEMETRY_PERSIST_FAILED', detail);
@@ -439,7 +441,7 @@ export async function runWorkbuddyWorkspaceWorkerCycle(options) {
439
441
  toolSemantics: WORKBUDDY_TOOL_SEMANTICS,
440
442
  hostKinds: ['workbuddy'],
441
443
  });
442
- // Step 7 (SPEC v0.3.1 §2) — Stage-2 correction review, ALWAYS last.
444
+ // Step 7 (SPEC v0.3.1 §2) — Stage-2 correction review, after downstream.
443
445
  const stage2Resolution = options.stage2Classifier === undefined
444
446
  ? createSignalClassifierForWorkspace(workspaceDir)
445
447
  : null;
@@ -494,6 +496,31 @@ export async function runWorkbuddyWorkspaceWorkerCycle(options) {
494
496
  ...(degradedReason !== undefined ? { lastDegradedReason: degradedReason } : {}),
495
497
  ...invocationIdLivenessPatch(),
496
498
  });
499
+ // Optional optimization is outside the outcome/heartbeat calculation.
500
+ // An eligible one-shot worker awaits only its bounded tail, so a late model
501
+ // response cannot strand the main cycle or degrade liveness.
502
+ if (flags.correction_observer?.enabled === true) {
503
+ const stateDir = path.join(workspaceDir, '.state');
504
+ try {
505
+ await runCorrectionObserverOptimizationCycle({
506
+ workspaceDir,
507
+ stateDir,
508
+ hostKind: 'workbuddy',
509
+ logger,
510
+ openTrajectory: () => openGovernanceCorrectionTrajectory({
511
+ workspaceDir, hostKind: 'workbuddy', sourceMaterialAuthorization,
512
+ }),
513
+ minIntervalMs: options.correctionObserverMinIntervalMs ?? 15 * 60_000,
514
+ timeoutMs: options.correctionObserverTimeoutMs ?? 10_000,
515
+ ...(options.now === undefined ? {} : { now: () => options.now ?? new Date() }),
516
+ });
517
+ }
518
+ catch {
519
+ // Shared cycle owns ordinary failures; also isolate an unexpected
520
+ // exception (including a failed optional diagnostic logger).
521
+ updateSignalHealth(stateDir, (health) => { health.observerConsecutiveFailures += 1; });
522
+ }
523
+ }
497
524
  return {
498
525
  ...base,
499
526
  mode: degradedReason !== undefined ? 'degraded' : 'ready',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/workbuddy-adapter",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "WorkBuddy host adapter for Principles Disciple — implements the HostAdapter interface for WorkBuddy's Git Bash command-hook model (ADR-0020 third host, SPEC workbuddy-host-adapter v0.3.0).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -42,8 +42,8 @@
42
42
  "lint": "eslint \"src/**/*.ts\""
43
43
  },
44
44
  "dependencies": {
45
- "@principles/core": "^10.0.0",
46
- "@principles/host-runtime": "^5.0.0",
45
+ "@principles/core": "^11.0.0",
46
+ "@principles/host-runtime": "^5.2.0",
47
47
  "@principles/install-layout": "^0.12.0"
48
48
  },
49
49
  "devDependencies": {
@@ -61,5 +61,5 @@
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "gitHead": "293825348a6f4a40cc561f6a59fc42c64d532766"
64
+ "gitHead": "549a73b98fcbf19100938c24c3163f811bbf50bd"
65
65
  }
@@ -37,7 +37,6 @@ description: 当需要只读检查 PD 运行健康、查询痛苦/任务/运行/
37
37
 
38
38
  - 健康检查:`pd health --workspace "<用户主目录>/.workbuddy/pd-workspace" --json`
39
39
  - Runtime 探针:`pd runtime probe --runtime pi-ai --workspace "<用户主目录>/.workbuddy/pd-workspace" --json`
40
- - 流程策略:`pd runtime flow show --workspace "<用户主目录>/.workbuddy/pd-workspace" --json`
41
40
  - 痛苦列表与准入证据:`pd pain list --workspace "<用户主目录>/.workbuddy/pd-workspace" --json`、`pd pain evidence --workspace "<用户主目录>/.workbuddy/pd-workspace" --json`
42
41
  - 痛苦到原则的追踪:`pd runtime trace show --pain-id "<painId>" --workspace "<用户主目录>/.workbuddy/pd-workspace" --json`
43
42
  - 任务与运行:`pd task show "<taskId>" --workspace "<用户主目录>/.workbuddy/pd-workspace" --json`、`pd run show "<runId>" --workspace "<用户主目录>/.workbuddy/pd-workspace"`