LearnNewsExamplesServices
Frontmatter
id13784
titlekb-sync child-outcome propagation: emit + capture deferred outcomes (C.2 sibling of #13777, sub of #13755)
stateClosed
labels[]
assigneesneo-opus-grace
createdAtJun 21, 2026, 6:15 PM
updatedAtJun 21, 2026, 7:27 PM
githubUrlhttps://github.com/neomjs/neo/issues/13784
authorneo-opus-grace
commentsCount0
parentIssue13755
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtJun 21, 2026, 7:27 PM

kb-sync child-outcome propagation: emit + capture deferred outcomes (C.2 sibling of #13777, sub of #13755)

neo-opus-grace
neo-opus-grace commented on Jun 21, 2026, 6:15 PM

Context

Sub of #13755 (orchestrator heavy-lease: deferred/held runs log as 'completed'). GPT's #13755 epic-review flagged the kb-sync / PrimaryRepoSyncService child-outcome propagation surface as needing an explicit native sub rather than remaining comment-only. This is that sub — the C.2 (child→orchestrator outcome channel) pattern applied to kbSync, the sibling of #13777/#13778 (miniSummary).

The Problem

kbSync spawns ai/scripts/maintenance/syncKnowledgeBase.mjs, which runs the sync under withHeavyMaintenanceLease. When the lease is held by another task, withHeavyMaintenanceLease returns a deferred outcome (previousStatus: 'held' / the inherited-token-stale marker), and the child exits 0 — but it prints only human-readable console.log status lines, NOT a structured outcome JSON. ProcessSupervisorService therefore records completed + refreshes lastSuccessAt for a run that did NO embedding. This is the documented #13755 root: kb-sync deferred 502× with a 4-day embedding gap (06-17→06-20), every "completed successfully" line a deferral-masked-as-completion.

Same false-green class #13778 fixed for memory-summary-backfill — but kbSync needs BOTH halves (miniSummary's child already emitted structured JSON; kbSync's does not).

The Architectural Reality

  • ai/scripts/maintenance/syncKnowledgeBase.mjs — runs KB_DatabaseService.syncDatabase() under withHeavyMaintenanceLease; captures outcome locally but does not emit it as JSON.
  • withHeavyMaintenanceLease (HeavyMaintenanceLeaseService.mjs) returns previousStatus on deferral (the #13764 marker) + the task result on success.
  • ProcessSupervisorService.classifySuccessfulChildOutcome (#13778) already maps a child's structured outcome → completed/skipped, but only memory-summary-backfill opts in (captureStdoutJson).

The Fix (2 halves, mirroring #13777/#13778)

  1. Child-emit: syncKnowledgeBase.mjs prints a structured outcome JSON on stdout — {deferred: true, reason: <previousStatus>} when the lease was held / inherited-token-stale; {embedded, deleted, ...} on real work.
  2. Supervisor-capture: add captureStdoutJson: true to the kbSync task definition + extend classifySuccessfulChildOutcome so a deferred/no-embedding kbSync outcome records skipped (does NOT refresh lastSuccessAt), not completed.

Acceptance Criteria

  • A lease-held kbSync run emits a deferred outcome + records skipped (not completed); lastSuccessAt not refreshed.
  • A real-embedding kbSync run records completed + the embedded/deleted counts.
  • Malformed/oversized stdout fails soft (per the #13778 bounded-capture contract).
  • Unit coverage mirroring #13778's spec (deferred→skipped, embedded→completed).

Out of Scope

  • The PrimaryRepoSyncService child-outcome (GPT named it alongside kb-sync; if it has the same surface, a separate sibling sub).
  • The within-day fairness reducing kbSync deferrals (#13780) + the time-of-day batching (#13782) — those reduce the deferrals; this makes the deferrals OBSERVABLE.

Related

  • Parent: #13755 (heavy-lease deferred-as-completed epic)
  • Pattern siblings: #13777 / #13778 (miniSummary child-outcome)
  • Lease marker: #13764 (withHeavyMaintenanceLease previousStatus)

Live latest-open sweep: checked latest 30 open issues 2026-06-21; no existing kb-sync child-outcome capture sub.

Origin Session ID: 80932414-00dc-4d2e-96e6-d0bcf1529733

Retrieval Hint: "kb-sync child-outcome capture deferred skipped syncKnowledgeBase false-green C.2"

tobiu referenced in commit 1e5f89e - "fix(orchestrator): propagate kbSync child outcomes — lease-held deferrals record skipped, not false-green completed (#13784) (#13785) on Jun 21, 2026, 7:27 PM
tobiu closed this issue on Jun 21, 2026, 7:27 PM