Skip to content

The TypeScript port computes effects as the checker does (law 1) - #9

Draft
jithinAB wants to merge 1 commit into
masterfrom
pact-kernel/effect-of-ts
Draft

jithinAB wants to merge 1 commit into
masterfrom
pact-kernel/effect-of-ts

Conversation

@jithinAB

Copy link
Copy Markdown
Contributor

Law 1 in the TypeScript port: adapters/typescript/src/effects.ts computes a part's effect exactly as crates/pact-loader/src/effects.rs does, so a runtime that gates calls by effect: in a when-this, or builds an agent in code with no tree to discover, has the checker's answer without the binary. Bud Meta Harness needs it for its PACT kernel (actor.effect) and for agents written in its SDK; it carries this file as a logged local modification until this merges.

What changes

  • adapters/typescript/src/effects.ts: ofAction, effectOf (a <tool>/<action>, a whole tool, an agent, a workflow; seen ends a circle), ofAgent, ofSteps, ofStage (a stage's own undone-by: makes what it calls undoable), worse, effectIs (reads, writes, spends, cannot-be-undone, as Effect::is) and discovered (what pact discover prints).
  • adapters/typescript/read-effects.mts: prints every agent's and workflow's effect for one shown document.
  • adapters/python/tests/test_both_ports_compute_one_effect.py: runs pact show and pact discover on every example and every tree under tests/trees, and the port on each shown document; every agent discover lists must agree. A second case pins a payment with a refund (undoable, still moves money), a silent action (cannot be undone), and a team (the worst of its members).
  • Counts synced (adapter 3127 → 3129); CHANGELOG entry.

One difference, stated

A tick is read with saidYes (yes-no.ts, the five words coerce.rs::yes_no accepts). workflows.rs::said_yes, which effects.rs uses, takes three (yes, true, on), so reads-only: y, which the checker accepts as a tick, is a lookup to the port and a write to the checker. No document of the corpus writes such a tick, so the corpus comparison passes; the Rust reading is the one that should follow coerce.rs, and a follow-up can make it.

Evidence

  • pytest tests/test_both_ports_compute_one_effect.py: 2 passed (every corpus agent agrees).
  • tsc --noEmit with this package's compiler options over src/effects.ts, src/yes-no.ts and read-effects.mts: clean.
  • No Rust change; cargo test counts unchanged.

adapters/typescript/src/effects.ts ports crates/pact-loader/src/effects.rs
function for function (ofAction, effectOf, ofAgent, ofSteps, ofStage,
effectIs). read-effects.mts prints every agent's and workflow's effect
for one shown document, and test_both_ports_compute_one_effect.py holds
the port to pact discover on every agent of the corpus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant