Skip to content

fix(bin): publish queued procevent results once until consumed - #7764

Closed
niks0501 wants to merge 2 commits into
kunchenguid:mainfrom
niks0501:fm/publish-procevent-results-once-per-queue-74
Closed

niks0501 wants to merge 2 commits into
kunchenguid:mainfrom
niks0501:fm/publish-procevent-results-once-per-queue-74

Conversation

@niks0501

@niks0501 niks0501 commented Oct 26, 2026 •

Copy link
Copy Markdown

What Changed

  • bin/fm-procevent.sh publish path now checks the wake queue under lock and appends a procevent:<source>:<sequence> check only when that key is not already queued, so each result keeps at most one queued wake and is republished after the row is consumed until handled records it.
  • Updated the operating contract in docs/configuration.md, the process-event-sources skill, and verification docs from re-announce-on-every-reconcile to once-per-queued-wake with republish-after-consume.
  • Extended tests/fm-procevent.test.sh to assert no duplicate while queued, single-row republish after consume, and a quiet queue once handled.

Risk Assessment

✅ Low: The change is narrowly scoped and uses the existing queue lock to suppress duplicate publication while preserving re-announcement after consumption.

Testing

Drove the real bin/fm-procevent.sh against disposable isolated homes: stranded lavish result published once, repeat reconciles while queued published 0 with a single unchanged row, drained queue republished once with no duplicate durable copy, handled result stayed quiet with safe repeat, and terminal endnow result followed the same queued-once/drain-republish/handled-quiet cycle. The repo's fm-procevent suite passes all change-related checks (queued-once, race, terminal-once). One unrelated orphan-reparent assertion fails on ppid (environment, no init reparent).

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Unhandled result publishes once while its wake stays queued — second and burst reconciles publish 0 and leave exactly one row ✅ pass live live procevent once-per-queue transcript (24 live assertions)
Consumed (drained) wake is republished while result stays unhandled, with single row and no duplicate durable copy ✅ pass live live procevent once-per-queue transcript (24 live assertions)
Handled result stays quiet after acknowledgement even after queue drain, and repeat acknowledgement is safe ✅ pass live live procevent once-per-queue transcript (24 live assertions)
Terminal adapter result is announced once while queued, republished after drain, then quiet after handled (adversarial duplicate/terminal edge) ✅ pass live live procevent once-per-queue transcript (24 live assertions)
Evidence: live procevent once-per-queue transcript (24 live assertions)

Source: live procevent once-per-queue transcript (24 live assertions)

=== S1: first reconcile publishes ===
reconciled: published=1 started=0 stopped=0 uncertain=0 failed=0
PASS: S1 first reconcile published=1
wake rows after first: 1
PASS: S1 exactly one wake row
1792999780	1	check	procevent:src-cut:7	check: procevent lavish src-cut 7
PASS: S1 payload identity
=== S1b: second reconcile while queued publishes 0, no duplicate ===
reconciled: published=0 started=0 stopped=0 uncertain=0 failed=0
PASS: S1b second reconcile published=0 while queued
PASS: S1b queue unchanged while suppressing duplicate
PASS: S1b still exactly one row
=== S1c: burst of 3 reconciles leaves exactly one row ===
PASS: S1c burst leaves one row
=== S2: drain queue, reconcile republishs ===
reconciled: published=1 started=0 stopped=0 uncertain=0 failed=0
PASS: S2 consumed wake republished published=1
PASS: S2 republished identity preserved
PASS: S2 republication single row
PASS: S2 no duplicate durable copy
=== S3: handled stays quiet ===
handled: src-cut 7
PASS: S3 handled acknowledged
PASS: S3 handled marker durable
reconciled: published=0 started=0 stopped=0 uncertain=0 failed=0
PASS: S3 reconcile after handled published=0
PASS: S3 queue stays absent after handled
already-handled: src-cut 7
PASS: S3 repeat already-handled
PASS: S3 repeat did not re-authorize
=== S4: terminal result queued once ===
not-autohandled: ends-src (left for the handler; still unacknowledged)
retired: ends-src (adapter classified the captured result terminal)
captured: /tmp/fm-procevent-term.FTYlK4/state/procevent-inbox/ends-src.1.result
PASS: S4 terminal captured
PASS: S4 terminal retired
reconciled: published=0 started=0 stopped=0 uncertain=0 failed=0
PASS: S4 queued terminal not republished (published=0)
PASS: S4 terminal exactly one row
reconciled: published=1 started=0 stopped=0 uncertain=0 failed=0
PASS: S4 drained terminal republished
handled: ends-src 1
PASS: S4 terminal handled
reconciled: published=0 started=0 stopped=0 uncertain=0 failed=0
PASS: S4 terminal quiet after handled
=== SUMMARY pass=24 fail=0 ===
Evidence: fm-procevent suite log (change-related ok lines)

Source: fm-procevent suite log (change-related ok lines)

ok - no configured source means no generated state and no process
ok - one blocking completion yields exactly one bounded normalized event
ok - a home reached through a symlinked ancestor runs its sources normally
not-autohandled: direct-src (left for the handler; still unacknowledged)
ok - public start owns the process group recorded by its claim
ok - public start never claims an inherited caller process group
ok - queued wakes publish once, consumed unhandled wakes are restored, and acknowledged results stay quiet
ok - publication cannot race a handled acknowledgement
ok - handled acknowledgement creation is private and fails safely
ok - automatic application waits for durable publication and failed publication remains recoverable
ok - a self-announcing adapter applies quietly and still publishes what it could not apply
not-autohandled: ends-src (left for the handler; still unacknowledged)
ok - an adapter-classified terminal result is captured once, announced once while queued, and retires its source automatically
not-autohandled: open-src (left for the handler; still unacknowledged)
ok - a source stays armed unless its own adapter classifies the result terminal
not-autohandled: replace-src (left for the handler; still unacknowledged)
ok - terminal retirement preserves and releases a concurrently replaced registration
ok - failed terminal retirement is fail-closed and idempotently recoverable
ok - one Send & End yields exactly one captured result, automatic retirement, and no recurring poll
ok - an empty board close is captured and recorded handled without ever waking the captain
ok - worker board replies and recovered listeners derive their server from the board session
ok - worker-owned Lavish rounds deliver to the worker, acknowledge on re-arm, and stop at session end
ok - a capture interrupted before its result commit does not wedge its source
ok - an orphaned capture is not acknowledged by a worker it never reached
ok - a worker-owned board is only armed for an owner its feedback can reach
ok - an acknowledged note is never resurrected and stops ringing across repeated reconciles
ok - acknowledging a terminal round concludes that round only
ok - an interrupted conclude leaves the ended board unpollable and finishes on retry
ok - a re-arm that cannot acknowledge its round leaves the running generation alone
ok - a worker-owned board is armed once and re-armed only to acknowledge an open round
ok - a board close carrying the captain's real answer is still announced
ok - the shipped poll governor bounds an instantly returning source
ok - a transient Lavish poll interruption is retried quietly and never announced
ok - a staged worker reply is handed to the board once across quiet poll retries
ok - a listener whose staged reply is gone polls the board without one
ok - a listener that refuses its own setup leaves the staged reply for the next one
ok - a listener whose artifact vanished leaves the staged reply for the next one
ok - an interruption that outlives the bounded retries is captured and announced
ok - only the exact interruption is retried; an unrelated SERVER_ERROR still surfaces
ok - only the literal two-line interruption enters the quiet retry policy
ok - arm rejects malformed and out-of-range retry delays before registration
ok - poll cleanup safely handles an apostrophe-containing TMPDIR
ok - Lavish classification staging stays bounded while nonmatches stream
ok - a drained-but-unhandled result survives a replacement session and is retired only by explicit handling, never twice
ok - pending results preserve numeric order and distinct wake identity
ok - one owner per canonical source across homes
ok - retiring a never-completing source stops its runner and its blocked child
ok - reconcile reaps a runner whose source registration is gone
not-autohandled: stale-src (left for the handler; still unacknowledged)
ok - stale-owner recovery removes abandoned output without displacing a live owner
not-autohandled: cross-home-src (left for the handler; still unacknowledged)
ok - cross-home stale recovery removes abandoned output from the old state directory
not-autohandled: race-src (left for the handler; still unacknowledged)
not-autohandled: race-src (left for the handler; still unacknowledged)
ok - concurrent stale-claim replacement starts exactly one runner
ok - an ambiguous leaderless group is preserved without replacement
ok - a truly dead generation with no surviving group is still safely reclaimed
ok - reconcile reclaims a dead generation whose state-root identity no longer matches
ok - retire releases a dead generation's claim instead of refusing forever
ok - a live generation is never reclaimed, drifted state root or not
ok - a reused pid never makes its surviving process group reclaimable
ok - start reclaims a reused-pid claim whose leftovers can still be tidied
ok - a launch that cannot confirm is announced once per failure episode
ok - a 64-char source id keeps the launch-failed key within the watcher's marker bound
ok - reconcile reports a launch it could not confirm instead of counting it as a start
ok - a launch that finished before confirmation looked is still reported as started
ok - a zero-padded launch confirm window is honored as base 10
ok - an unusable launch confirm window is refused by name instead of blamed on the sources
ok - a dead generation whose leftovers cannot be tidied never keeps owning its source
ok - claim replacement cannot produce a torn ownership snapshot
ok - retirement and start share one serialized lifecycle boundary
ok - detected PID reuse is refused before signalling
ok - transient identity failure preserves the live source for retry
ok - bounded home sweep preflights then retires every locally owned source
ok - home sweep leaves foreign-home claims and runners untouched
ok - home sweep refuses safely until runner identity is readable
ok - healthy runtime behavior remains registration-only
ok - registration rejects unrepresentable newline arguments
ok - nonzero exit with no output stays armed and silent
ok - oversized output is bounded rather than published whole or dropped
ok - live output stays bounded and retirement reaps the whole source group
ok - stop mismatch evidence preserves the proved-stop boundary
ok - stop unreadable evidence preserves the proved-stop boundary
ok - stop unreadable-pgid evidence preserves the proved-stop boundary
ok - stop nonleader evidence preserves the proved-stop boundary
ok - invalid output bounds fail closed
ok - the adapter derives physical identity without newline path corruption
ok - source-only homes trigger the general supervision guard
ok - the adapter classifies published poll output safely
ok - poll derives host and port from the artifact session, not ambient or configured routing
ok - quiet retries use the board session regardless of configuration changes
ok - missing or unreadable session routing preserves replies and never guesses another server
ok - the adapter owns which Lavish results end a source, and payload text cannot forge one
ok - the adapter owns which Lavish results are silent, and fails closed on everything else
ok - read distinguishes a live captain message from a session-ending message
ok - read names the message count with the same label as the message section
ok - read presents every annotation and a distinct session-ending message
ok - read never certifies rows missing declared fields as complete
ok - read keeps every annotation when the session-ending message is absent
ok - read surfaces a typed comment on an annotated element
ok - read still surfaces a typed comment that matches the element text
ok - read still presents a pure annotation with no comment
ok - read does not present choice context as a comment
ok - read still presents a pure message with no selector
ok - read distinguishes a feedback capture from an ended-with-nothing close
ok - read presents list-form items with nested targets, attachments, and multi-line prompts
ok - read never certifies malformed list-form items as complete
ok - read never reports a declared-but-unparsed block as complete
ok - answers reads list-form choices and refuses a block it cannot account for
ok - an adapter with no silence verdict keeps announcing every result
ok - the published interfaces state the loss limitation and claim no lossless delivery
registered: floor-src (lavish)
ok - an orphaned source command obeys the launch floor during its grace window
ok - a replacement registration starts with one fresh launch floor
ok - a superseded sleeping runner cannot recreate stale pacing state
ok - post-commit pacing cleanup cannot veto registration publication
ok - a pre-reboot monotonic stamp is treated as expired
ok - an expired owner lease stops a self-relaunching source generation
ok - a recreated state path does not preserve the old runner
registered: guard-fail-src (lavish)
ok - a runner fails closed when its owner guard cannot initialize
registered: attached-src (lavish)
ok - a foreground start refreshes its lease while its caller remains attached
ok - wall-clock corrections do not alter owner lease age
registered: detached-attached-src (lavish)
ok - an attached-start keeper stops refreshing after its parent exits
ok - a detected ambiguous reused-PID group is not signalled
not ok - the listener under test was not reparented away from its session (ppid 486)
- Outcome: ⚠️ 1 info across 1 run (20m15s)

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 info
  • ℹ️ Full tests/fm-procevent.test.sh run shows 115 ok and 1 unrelated failure: 'the listener under test was not reparented away from its session (ppid 486)' expects ppid 1. The diff only touches publish_result wake-dedupe and comments and cannot affect daemon reparenting; this is a container/init environment limitation, not this change.
  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Unhandled result publishes once while its wake stays queued — second and burst reconciles publish 0 and leave exactly one row ✅ pass live live procevent once-per-queue transcript (24 live assertions)
Consumed (drained) wake is republished while result stays unhandled, with single row and no duplicate durable copy ✅ pass live live procevent once-per-queue transcript (24 live assertions)
Handled result stays quiet after acknowledgement even after queue drain, and repeat acknowledgement is safe ✅ pass live live procevent once-per-queue transcript (24 live assertions)
Terminal adapter result is announced once while queued, republished after drain, then quiet after handled (adversarial duplicate/terminal edge) ✅ pass live live procevent once-per-queue transcript (24 live assertions)
  • FM_HOME=&lt;disposable-0700-home&gt; bin/fm-procevent.sh reconcile first publish, repeat-while-queued, burst x3, drain-republish, handled-quiet cycle
  • FM_ROOT_OVERRIDE=&lt;endnow-fixture&gt; FM_HOME=&lt;disposable-home&gt; bin/fm-procevent.sh register/start/reconcile/handled terminal queued-once cycle
  • bash tests/fm-procevent.test.sh targeted suite (change-related assertions pass)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thank you @niks0501. This is a real defect, and reusing fm_wake_queued_keys_locked keeps the fix small and in line with how fm-contributions.sh already dedupes.

What I checked on 65e39c96 against main 2b46ed1f. On main, every reconcile re-appends each unhandled process-event result, and every append re-publishes the .watcher-down downtime marker. Your fix checks the queued check keys under the wake-queue lock and skips the append when procevent:<source>:<seq> is already queued. Once the row is consumed, the result can be published again until it's acknowledged. The diff touches bin/fm-procevent.sh and tests/fm-procevent.test.sh only, with no workflow, network, or credential surface. So I approved the first-time fork runs: CI 40272022401 and Require no-mistakes 40272022413. It's MERGEABLE.

Overlap: #7762 from @zestysoft fixes the same thing. Both PRs change the same publish_result block, so only one can land as written. The differences I see:

Which one goes in is Kun's call. I'm not closing either.

Contract class: new-default (my read). The reconcile header on main spells out the current behavior: republish every unhandled result "on every call regardless of any earlier publication." This replaces that specified default with "publish once while queued." It's a sensible fix that aligns with VISION (less noise, and a queued wake is still retired only by its answering record), but it changes a documented default path, so it goes to Kun rather than auto-merge. VISION: one-captain aligns, authority aligns (no new autonomy), scripts aligns (exact lock-held key check), restart aligns (republish after consume, handled ack still the only stop), spine/vendor/scope align.

What this needs from you: the head is a single hand-written commit, and the description doesn't mention a no-mistakes run. The PR must be raised via no-mistakes check is blocking, so if it comes back red, please re-raise through git push no-mistakes so the attestation binds the head. Your note that the full tests/fm-procevent.test.sh stopped at the unmodified reparenting assertion (:4001, PPID 438) locally is fine; CI will run that file in a clean environment.

So this is waiting on you for the no-mistakes attestation while CI runs. Once a head is green with the attestation bound to it, it goes to Kun alongside #7762 as a pick-one decision.

@niks0501
niks0501 force-pushed the fm/publish-procevent-results-once-per-queue-74 branch from 65e39c9 to 01eef7d Compare October 26, 2026 07:51
@niks0501 niks0501 changed the title Publish process-event results once while queued fix(bin): publish queued procevent results once until consumed Oct 26, 2026
@niks0501

Copy link
Copy Markdown
Author

Quick context while this waits on workflow approval:

  • Re-raised through the validation pipeline to bind current head 01eef7d: review, test, document, lint, and push steps all finished. Only CI reporting is still pending approval.
  • The six failing Behavior portable serial runs are pre-existing flakes, not this change. They fail identically on fix(bin): publish queued process-event results once #7762 in paths this diff does not touch: supervision-host delivery, public-followup, contribution repeat, remote-secondmate/fleet-ledger, rex fixture and PR-health/Herdr checks, and the checkpoint timeout comparison. No code fix is warranted.
  • Suite state: 115 passing, 1 unrelated environment failure (the orphan-reparent assertion expects ppid 1; this container has no init reparent).

Ask: approve the workflows so CI can report on the current head.

@niks0501 niks0501 closed this Oct 28, 2026
@niks0501
niks0501 deleted the fm/publish-procevent-results-once-per-queue-74 branch November 2, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants