Skip to content

feat(ops): effect() read-compare-run-write, gated effects on ApplyOp, WatchOp staleness (#1834) - #1880

Merged
lex00 merged 1 commit into
mainfrom
feat/1834-effect-step
Aug 24, 2026
Merged

lex00 merged 1 commit into
mainfrom
feat/1834-effect-step

Conversation

@lex00

@lex00 lex00 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Third leg of the effect-receipts epic #1703 (decisions 3 and 6): the effect() op step is the sole writer of a receipt — on success of its nested steps, last — and effects: "gated" lands beside delete: "gated" on the temporal ApplyOp.

effect(receipt, steps, opts?) step builder (core)

  • Wraps nested steps in read-compare-run-write: read the live receipt, skip the nested steps on a match ("effect already applied"), otherwise run them in authored order and write the receipt only when every one succeeded, last. A nested-step failure leaves the receipt untouched (stale), so the next run re-proposes the effect.
  • receipt is typed to the EffectReceiptDeclaration shape — no string overloads; a string receipt name does not compile (type-level test under core tsc) and is refused at runtime.
  • A fully static receipt's expectation is stamped at synthesis via core: EffectReceipt factory + recognition marker + resolution split #1831's receiptExpectation; a hash receipt with reference inputs carries placeholder inputs and resolves at run (decision 5), never by hashing placeholders.
  • A gate(...) authored inside the nested steps pauses only when the effect will fire.

Injectable ReceiptStore seam (packages/core/src/op/receipt-store.ts)

ReceiptStore = { read(receipt) -> current | absent, write(receipt, expectation) } over an EffectReceiptRef ({ name, effect, flavor, inputs }). receiptActivities(store, opts?) binds the three activities — receiptRead, receiptWrite, receiptStaleness — that the receipt row's lexicon exports from its op/activities module (#1835 implements the store over SSM; tests bind a mock), registered by name through the activity registry exactly like ensureSecret (#1829/#1830). The local executor runs effect steps through the same activity names; receiptStaleness is read-only by construction.

Serializer

The op codegen emits the read-compare-run-write as workflow code with the receipt identity and expectation as data: one receiptRead call carrying the receipt (and static expectation) as JSON, the compare in workflow code, the nested steps inside the mismatch branch, and the single receiptWrite last. Authored order is preserved and receiptRead/receiptWrite get one proxy binding at the fastIdempotent profile (#1698 rules).

effects: "gated" on ApplyOp

Beside delete: "gated", same durable-signal shape: the run pauses at the Approve gate so the Plan phase's effect-will-fire rows (#1832) are reviewed before any effect runs. The generic apply never writes a receipt regardless.

WatchOp staleness

receipts: [...] (typed EffectReceipt references) adds a read-only Receipts phase: reads each receipt via the store seam, reports absent/differing values as findings and a StaleReceipts search attribute, runs nothing, writes nothing.

Testing

  • npx tsc --noEmit -p packages/core/tsconfig.json clean (includes the type-level no-string-receipt test)
  • npx vitest run packages/core/src/op lexicons/temporal/src — 527 passed
  • npx vitest run packages/core/src/cli packages/core/src/components — all passed
  • npm run build -w @intentius/chant-lexicon-temporal clean
  • just lint, just docs-check clean

Closes #1834

@lex00
lex00 merged commit 6243971 into main Aug 24, 2026
6 checks passed
@lex00
lex00 deleted the feat/1834-effect-step branch August 24, 2026 21:44
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.

ops: effect() step builder, effects: gated on ApplyOp, WatchOp stale reporting

1 participant