Decide "before the enable" by the store, batch the expiry, bound receipts

Soul pass 2 findings S1, S2, S3, S4.

- Enabling the sink is the drain's EnableAsync: every intent already in the
  store gets an "expired" receipt and the enable marker is written, all in one
  flush. No decision compares StoredAt with a clock any more, so a fast
  writer clock and the Rust daemon's secs.nanosZ stamps stop mattering.
- The operator's EditorPrefs hold a token, and the sink runs only while the
  store carries the marker with that token. A re-clone or a copied .brokkr has
  no such marker, so a stale "enabled" authorizes nothing and the editor drops
  it. The epoch and agentCommandsEnabledAt (host snapshot key 19) are gone.
- Selection is one pass over the store per tick (Pending), not a copy and sort
  per intent.
- Receipts are capped at the newest 1000, pruned 128 pairs per tick with the
  intent deleted before its receipt.
- A marker that could not be written is withdrawn, so the intent reads as
  never started and is retried, not "interrupted".
- The drain writes through IBrokkrCommandStore; puts stage and one flush makes
  them durable.
- The CLI timeout text no longer says the intent "stays written" without the
  expiry caveat; the check-then-write window on --command-id is documented.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-29 16:56:33 +02:00
commit 9f5e8fbf3c
12 changed files with 476 additions and 173 deletions

View file

@ -107,7 +107,7 @@ internal static class Cli
{
// A command id is single-use, so every invocation is a new act with a new id. --command-id exists for callers
// that need to name their own; one that already has a receipt is refused, because that receipt answered an
// earlier act and would be reported as the answer to this one.
// earlier act and would be reported as the answer to this one. The check and the write are two steps, so two\n // callers naming the same new id in the same instant can still collide; ids are minted, and that is a caller defect.
var named = options.TryGetValue("--command-id", out var commandId) && !string.IsNullOrWhiteSpace(commandId);
if (named)
{
@ -167,7 +167,7 @@ internal static class Cli
if (started)
why = " The editor started this intent and has not recorded a result; it will not run it again.";
throw new TimeoutException(
$"Timed out waiting for Brokkr receipt '{receiptKey.Value}'; the intent stays written.{why}");
$"Timed out waiting for Brokkr receipt '{receiptKey.Value}'; the intent is still in the store: a running editor with the sink on will run it, but if the operator enables the sink after now it expires unrun.{why}");
}
private static BrokkrHostSnapshot? ReadHostSnapshot(CultCache cache) =>