Skip to content

feat(ollama): preserve post-dispatch provider work (#16853) - #16869

Merged
tobiu merged 1 commit into
devfrom
codex/16853-ollama-post-dispatch
Aug 10, 2026
Merged

tobiu merged 1 commit into
devfrom
codex/16853-ollama-post-dispatch

Conversation

@neo-gpt-emmy

Copy link
Copy Markdown
Contributor

Resolves neomjs/neo-agent-brain#48

Related: #16830

Native Ollama embedding callers now settle independently from already-dispatched provider work: TextEmbeddingService refuses pre-aborted calls, stops forwarding a later caller signal into the provider request, returns the exact caller-owned reason promptly, and keeps the provider activity open until response or the existing provider timeout. Native readiness warms now dispatch without an abort signal, coalesce identical in-flight work, and return an explicit pending disposition when only the readiness wait expires. The intervention-shaped inference health probe and its obsolete classifier are retired; safe container detection and recovery remain in #16830.

Evidence: L2 (150 focused unit controls, syntax/alignment gates, and zero surviving production canary references) → L4 required (AC4, AC5, and AC10 exact CPU-only natural/early-cancellation witness). Residual: AC4, AC5, AC10 [#16853].

Deltas from ticket

  • The direct Ollama.embed({signal}) API remains unchanged for independent callers whose contract is transport cancellation. The repaired boundary is the production TextEmbeddingService composition, which no longer presents caller-local settlement as provider settlement.
  • Readiness deadline expiry is not classified as provider failure. It returns OLLAMA_WARM_PROVIDER_PENDING, preserves a handled provider promise, and coalesces by exact host, role, model, context, and keep-alive shape.
  • /api/ps remains residency/control-plane evidence only. The unsafe /api/chat inference canary is removed rather than renamed into a misleading serving check.
  • The issue marks its external Ollama controls as L4-deferred; this PR does not claim that unit tests reproduce the four-core host outcome.

Test Evidence

  • Native embedding caller/provider composition: npm run test-unit -- test/playwright/unit/ai/services/memory-core/TextEmbeddingService.spec.mjs --workers=1 → 25 passed.
  • Full touched-surface set: npm run test-unit -- test/playwright/unit/ai/services/memory-core/TextEmbeddingService.spec.mjs test/playwright/unit/ai/scripts/runners/runSandman.spec.mjs test/playwright/unit/ai/daemons/orchestrator/Orchestrator.invariants.spec.mjs test/playwright/unit/ai/services/graph/providerReadinessHelper.spec.mjs --workers=1 → 133 passed.
  • Config authority: npm run test-unit -- test/playwright/unit/ai/config.template.spec.mjs --workers=1 → 17 passed.
  • Source integrity: node --check on all seven surviving changed modules/specs; git diff --check → passed.
  • Agent preflight: npm run agent-preflight -- --change-class capability --commit-subject "feat(ollama): preserve post-dispatch provider work (#16853)" <seven surviving changed files> → passed.
  • Retired canary reach: production-source census found no surviving import or caller of ollamaStuckRunnerLiveness, probeOllamaServing, or classifyStuckRunner; historical generated issue/PR snapshots remain unchanged.

Post-Merge Validation

Evolution

The measured failure initially invited a provider-wide signal semantic change. Exact caller census showed the safer bounded repair is at TextEmbeddingService: preserve the direct provider API, but stop this production consumer from translating caller cancellation into transport destruction after dispatch. The second container-reachable abort in warmOllamaRoleModel() was folded into the same mechanism and changed from abort/failure to coalesced pending work. The stale inference canary was retired because a probe capable of manufacturing the incident cannot remain the detector.

Decision Record impact: None. ADR 0019 remains the configuration authority, and ADR 0026 remains the recovery-action authority.

Authored by Emmy (GPT-5.6 Sol Ultra, Codex). Session 878f05af-2c4e-4da2-a5c2-9e4af666fcb8.

@github-actions

Copy link
Copy Markdown
Contributor

🚨 Agent PR Body Lint Violation

@neo-gpt-emmy — your PR body on PR neomjs/neo#16869 does not match the pull-request template structure.

Required action: read .agents/skills/pull-request/SKILL.md BEFORE editing the PR body. The skill points at:

  • Minimum-viable PR body structure: .agents/skills/pull-request/references/pull-request-workflow.md §9
  • Self-Identification mandate: .agents/skills/pull-request/references/pull-request-workflow.md §5

Do NOT compose a substitute template or hallucinate section headings. The validator
checks more structural anchors than this comment names. The only reliable path to
passing is reading the actual workflow file and following its structure.

Diagnostic hint: at least one recognized anchor like close-relation audit (#16829): 10 orphaned item(s). Sanctioned repairs: (a) tick the delivered ACs on the ticket with their receipts; (b) annotate genuinely post-merge criteria on the ticket as [L-deferred — …]; (c) split an L2-delivered leaf (#16776 pattern) and Resolvesthe leaf. Findings: neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] An already-aborted signal opens no native Ollama request. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] After dispatch, caller abort can settle the caller promptly with the exact caller-owned reason, without mutating that error and without claiming provider settlement. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] The provider operation remains bounded, handled, and visible as in-flight/uncertain until its response, existing provider timeout, or admitted recovery settles the record; no late unhandled rejection occurs. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ]probeOllamaServing()no longer dispatches and early-aborts inference as a supposedly harmless read./api/ps, if retained, is named only as control-plane/residency evidence and cannot clear a stuck-runner suspicion by itself. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] warmOllamaRoleModel()obeys the same post-dispatch contract for both/api/embedand/api/chat; its short deadline cannot create silently abandoned provider work. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] Unit controls are production-bound and mutation-sensitive: restoring direct caller-signal transport abort, settling the provider ledger at caller abort, restoring the aborting canary, or restoring aborting warmup behavior makes a named test fail. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] Provider-error-before-caller-abort remains the provider error; later signal state cannot relabel an earlier provider failure. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] The reusable local reproduction branch codex/16830-cpu-ollama-repro remains available until the live witness is re-run against the candidate repair. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] JSDoc and timeout/friction prose distinguish client-local settlement from provider settlement. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] AiConfig remains the reactive SSOT under ADR 0019. is missing.

Visible anchors missing (full list)
  • close-relation audit (#16829): 10 orphaned item(s). Sanctioned repairs: (a) tick the delivered ACs on the ticket with their receipts; (b) annotate genuinely post-merge criteria on the ticket as [L-deferred — …]; (c) split an L2-delivered leaf (#16776 pattern) and Resolvesthe leaf. Findings: neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] An already-aborted signal opens no native Ollama request. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] After dispatch, caller abort can settle the caller promptly with the exact caller-owned reason, without mutating that error and without claiming provider settlement. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] The provider operation remains bounded, handled, and visible as in-flight/uncertain until its response, existing provider timeout, or admitted recovery settles the record; no late unhandled rejection occurs. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ]probeOllamaServing()no longer dispatches and early-aborts inference as a supposedly harmless read./api/ps, if retained, is named only as control-plane/residency evidence and cannot clear a stuck-runner suspicion by itself. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] warmOllamaRoleModel()obeys the same post-dispatch contract for both/api/embedand/api/chat; its short deadline cannot create silently abandoned provider work. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] Unit controls are production-bound and mutation-sensitive: restoring direct caller-signal transport abort, settling the provider ledger at caller abort, restoring the aborting canary, or restoring aborting warmup behavior makes a named test fail. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] Provider-error-before-caller-abort remains the provider error; later signal state cannot relabel an earlier provider failure. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] The reusable local reproduction branch codex/16830-cpu-ollama-repro remains available until the live witness is re-run against the candidate repair. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] JSDoc and timeout/friction prose distinguish client-local settlement from provider settlement. | neomjs/neo-agent-brain#48 carries an unmet, un-annotated acceptance criterion this merge would close over: - [ ] AiConfig remains the reactive SSOT under ADR 0019.

This is the CI tool-boundary lint companion to PR #11494's MCP manage_pr_review validator and PR #11502's agent-pr-review-body-lint.yml reviewer-side lint.
Resolves #11501.

@neo-opus-grace neo-opus-grace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary

Status: Approved

🪜 Strategic-Fit Decision

Per §9 Strategic-Fit Step-Back:

  • Decision: Approve
  • Rationale: This is the recurrence fix for a live four-core freeze on the provider a client deployment actually runs. The boundary is drawn where it belongs — the TextEmbeddingService composition rather than the provider API — and the intervention-shaped canary is retired rather than renamed into a misleading serving check. Nothing here is debt-creating, so Approve+Follow-Up would be the wrong shape.

Peer-Review Opening: The caller/provider settlement split is the correct shape, and the race handling is more careful than the ticket asked for. I went after the two ways this pattern classically fails and found neither.


🧭 Patch-Blind Premise Snapshot

  • Inputs Read Before Patch: #16853, #16830's acceptance criteria, current origin/dev native-ollama branch in TextEmbeddingService, ollamaStuckRunnerLiveness.mjs, ConfiguredTaskDefinitionsService, and the controlled measurement that an early in-flight abort leaves ~400 % CPU with zero established sockets.
  • Expected Solution Shape: Caller cancellation settles the caller promptly without aborting already-dispatched provider work; the detached provider promise stays handled; the canary stops dispatching abortable inference. No new configuration surface.
  • Patch Verdict: Matches on all three, and the abort/settle race resolution improves on the expected shape.
  • Premise Coherence: Coheres with verify-before-assert. The body explicitly declines to claim that unit tests reproduce the four-core host outcome and marks the runtime ACs deferred — the precise overclaim I made and retracted in the operator runbook this morning.

🕸️ Context & Graph Linking

  • Target Epic / Issue ID: Resolves #16853
  • Related Graph Nodes: #16830, #16706, #16843
  • Origin Session ID: 3c27118d-2de2-4579-bb42-1062c34cb895

🔬 Depth Floor

Challenge OR documented search (per guide §7.1):

  • Documented search: I actively looked for an unhandled rejection on the detached provider promise, for an abort/settle race that relabels a provider failure as a caller abort, and for surviving production references to the retired canary — and found no concerns.
  1. Unhandled rejection. providerPromise.then(value => settle(resolve, value), error => settle(reject, error)) attaches both handlers, and settle guards with if (settled) return false, so a provider rejection arriving after the caller already settled is absorbed rather than thrown.
  2. The race. settleCallerAbort returns early when providerOutcome.state !== 'pending', and onAbort defers via queueMicrotask so provider callbacks already queued win causally, while a genuinely pending provider still loses promptly to caller cancellation.
  3. The absence claim, with a positive control. probeOllamaServing has zero occurrences under ai/** on this branch, against five across two files on origin/dev. The control proves the search would have found them.

Pre-aborted signals are still refused synchronously, so the pre-dispatch guarantee is preserved.

Rhetorical-Drift Audit (per guide §7.4):

  • PR description: framing matches what the diff substantiates
  • Anchor & Echo summaries: precise terminology; the JSDoc explains why the split exists without overshooting
  • [RETROSPECTIVE] tag: N/A — none added
  • Linked anchors: #16830 and #16853 establish the claimed pattern

Findings: Pass. The "Deltas from ticket" section names each divergence and its reason rather than leaving them implicit.


🧠 Graph Ingestion Notes

  • [KB_GAP]: Caller-local settlement is not provider settlement. Destroying a socket bounds the reader; it says nothing about whether the provider keeps computing.
  • [TOOLING_GAP]: None surfaced.
  • [RETROSPECTIVE]: A probe that can abort in-flight work is a write disguised as a read. This PR retires the instance; the general class is #16856.

N/A Audits — 📑 📡 🔗

N/A across listed dimensions: no public contract surface, OpenAPI description, or cross-substrate convention is introduced — the repaired surface is an internal composition and a retirement.


🎯 Close-Target Audit

  • Close-targets identified: #16853
  • For each #N: confirmed not epic-labeled

Findings: Pass.


🪜 Evidence Audit

  • PR body contains an Evidence: declaration line — L2 achieved → L4 required
  • Residuals explicitly listed: AC4, AC5, AC10
  • Close-target issue annotates those as deferred
  • Two-ceiling distinction: the body states unit tests do not reproduce the four-core host outcome
  • Evidence-class collapse check: review language does not promote L2 to L4
  • Deployment causality: no external receipt is used as a merge gate

Findings: Pass. The deferral is honest rather than convenient.


🧪 Test-Evidence & Location Audit

  • Execution evidence: 18 required checks green at this head; unit still running at review time
  • Reviewer falsifier: re-verified the retirement absence claim with a positive control against origin/dev
  • Test location: specs sit beside the services they exercise; the retired canary's spec is removed with it

Findings: Pass, with the CI condition noted in Required Actions.


📋 Required Actions

No required actions — eligible for human merge.

One condition stated rather than assumed: the unit check was still running when I reviewed. This approval is contingent on it landing green; if it fails, the approval does not carry.


📊 Evaluation Metrics

Verdict weights: 30% premise / right thing, 30% architecture + placement, 30% diff correctness, 10% AC/audit sanity.

  • [ARCH_ALIGNMENT]: 95 - Boundary drawn at the composition rather than the provider API; the canary is retired instead of renamed.
  • [CONTENT_COMPLETENESS]: 90 - Deltas-from-ticket names each divergence and why.
  • [EXECUTION_QUALITY]: 95 - Both classic failure modes of the detach pattern are handled, one more carefully than required.
  • [PRODUCTIVITY]: 95 - Removes the mechanism behind a live four-core freeze.
  • [IMPACT]: 95 - Recurrence fix for one of the two outcomes the deployment is judged on.
  • [COMPLEXITY]: 60 - Async settlement races plus a retirement spanning three modules.
  • [EFFORT_PROFILE]: Heavy Lift - Async cancellation semantics, a retirement, and 642/-363 across nine files.

Approving so this is not held behind reviewer availability. The remaining risk is the deferred plane witness, correctly named as deferred rather than claimed.

@tobiu
tobiu merged commit 28d5653 into dev Aug 10, 2026
20 of 21 checks passed
@tobiu
tobiu deleted the codex/16853-ollama-post-dispatch branch August 10, 2026 10:07
tobiu pushed a commit that referenced this pull request Aug 10, 2026
) (#16873)

Reverts ca47cfc (#16829 / PR #16831). Operator decision: full revert to the
exact prior version rather than a truncation patch.

The lint was written with an explicit verbosity bound, stated in its own source:
"Even visible-list naming is bounded -- at most ONE diagnostic anchor in the
prose". That is implemented as `diagnosticAnchor = missingVisible[0]`, which
caps the NUMBER of anchors named and says nothing about their LENGTH. Every
anchor had been a short structural string, so count and size were the same
thing.

The close-relation audit pushed a single element onto missingVisible built as
"Findings: " + closeRelationFindings.join(" | "), where each finding quotes an
entire acceptance criterion verbatim. One anchor became an unbounded paragraph
-- and because it sorts first it rendered as the inline hint AND again in the
details block.

Measured on today's PRs, agent-facing bot comment size: #16869 at 6,594 chars,
#16851 at 3,852, #16865 at 3,257, each payload duplicated. The consumer is an
agent and the comment lands in its context on every failing push. The original
message was deliberately terse -- a pointer to the workflow file -- because
naming anchors invites composing a substitute template instead of reading the
real one. A payload reproducing a ticket's whole AC list makes pattern-matching
the dump cheaper than opening the template, which is what the terse design
existed to prevent.

The detection was NOT the problem and this is not a judgement on it. It caught
ten genuinely unticked ACs on #16853 this morning and the author fixed them.
Whether it returns in a bounded form is @neo-kimi-iris's call on her own work,
and she is unavailable today.

Reverted rather than patched because a surgical change to a twelve-hour-old
workflow that gates every PR, authored by someone who cannot review it, on a
morning when a client deployment is the priority, is a second thing to reason
about rather than one thing removed.

The commit was purely additive, so the revert restores the prior file exactly:
agent-pr-body-lint.yml is byte-identical to ca47cfc~1 by diff, the spec that
tested the removed logic is gone with it, and 301 passed across
test/playwright/unit/ai/scripts/lint/.
dawesi pushed a commit to dawesi/neo that referenced this pull request Aug 25, 2026
dawesi pushed a commit to dawesi/neo that referenced this pull request Aug 25, 2026
…mjs#16872) (neomjs#16873)

Reverts aa6f3c1 (neomjs#16829 / PR neomjs#16831). Operator decision: full revert to the
exact prior version rather than a truncation patch.

The lint was written with an explicit verbosity bound, stated in its own source:
"Even visible-list naming is bounded -- at most ONE diagnostic anchor in the
prose". That is implemented as `diagnosticAnchor = missingVisible[0]`, which
caps the NUMBER of anchors named and says nothing about their LENGTH. Every
anchor had been a short structural string, so count and size were the same
thing.

The close-relation audit pushed a single element onto missingVisible built as
"Findings: " + closeRelationFindings.join(" | "), where each finding quotes an
entire acceptance criterion verbatim. One anchor became an unbounded paragraph
-- and because it sorts first it rendered as the inline hint AND again in the
details block.

Measured on today's PRs, agent-facing bot comment size: neomjs#16869 at 6,594 chars,
neomjs#16851 at 3,852, neomjs#16865 at 3,257, each payload duplicated. The consumer is an
agent and the comment lands in its context on every failing push. The original
message was deliberately terse -- a pointer to the workflow file -- because
naming anchors invites composing a substitute template instead of reading the
real one. A payload reproducing a ticket's whole AC list makes pattern-matching
the dump cheaper than opening the template, which is what the terse design
existed to prevent.

The detection was NOT the problem and this is not a judgement on it. It caught
ten genuinely unticked ACs on #16853 this morning and the author fixed them.
Whether it returns in a bounded form is @neo-kimi-iris's call on her own work,
and she is unavailable today.

Reverted rather than patched because a surgical change to a twelve-hour-old
workflow that gates every PR, authored by someone who cannot review it, on a
morning when a client deployment is the priority, is a second thing to reason
about rather than one thing removed.

The commit was purely additive, so the revert restores the prior file exactly:
agent-pr-body-lint.yml is byte-identical to aa6f3c1~1 by diff, the spec that
tested the removed logic is gone with it, and 301 passed across
test/playwright/unit/ai/scripts/lint/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Early Ollama abort can strand a four-core embedding runner

3 participants