Skip to content

feat(host): ADR-0022 M1b — prerequisites and bounded publication, inspection, owned and quorum calls, predicted effects - #151

Open
satran004 wants to merge 24 commits into
feat/dev-host-m1a-gradlefrom
feat/dev-host-m1b
Open

satran004 wants to merge 24 commits into
feat/dev-host-m1a-gradlefrom
feat/dev-host-m1b

Conversation

@satran004

@satran004 satran004 commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

ADR-0022 M1b (#142): the rest of the M1 host matrix. Stacked on #150 (M1a-3), which is stacked on #149 and then #145.

Authorship. Codex implemented this commit, because the coordinating session's Claude agents were paused by a usage limit. Codex must therefore not be the only reviewer; design and security (Claude) review it too.

ADR Where What
D14, D13 rule 4, I9 host Prerequisites, Reads, Session; runtime Publication, StateContractHandle, VerifierHandle, TxRunner Deployment and publication. deployment works without a wallet. prerequisites uses the D14 table: script presence comes from the full holder answer, registration is true, false or unknown. publish builds the three disjoint shapes with an exclusive upper bound set before balancing; a standalone registration is a pure kind-0 certificate with the protocol deposit. registered and learning from a confirmed registration are implemented, and prepare refuses with prerequisite while something is missing. The runtime changes are new bounded overloads only; existing signatures keep their old path and their unbounded defaults.
D14, D8 host Reservations, Session Registration evidence is tied to a reservation. It is learned on confirmation and dropped on rollback or rewind.
D15 host ContractDatums, Listings, Session Inspection. view runs named views through ServedContract.view, or returns state. instances and objects page over snapshots held for the session: at most 8, least recently used evicted (listingGone), items sorted, a limit of 500, unrecognized items, and object ownership taken from the datum. decode matches constructors and shapes, and answers ambiguous when more than one fits.
D16, D13 rule 6, I5 host Contracts, Session; julc-state-serve ServedContract (additive overload) Owned and @Quorum calls. Owned calls are served. @Quorum co-signers are 28-byte key hashes turned into address-only WalletAccounts and passed as the generated Account.... The caller is always a required signer, deduplicated by key hash, as the engine does. @SignedBy must equal the caller. authorizedBy, params, unverifiable and keyed calls are still refused with their codes.
D5a host Effects, ContractDatums Predicted effects. State is found by the thread token and objects by token kind and datum variant. Events are decoded from the redeemer. Payouts and sends carry their output index, full ledger value and owed. Change outputs are not attributed.
§8, §9 host ReplayTest, HostVectorsTest, DevKitHostTest; fixtures/host/README.md Replay and vectors. All 34 fixtures/m0/dapp calls replay byte-for-byte over the wire; M1a covered the 23 plain ones and this adds Bank's 11 owned calls. There is a recorder and replay harness for fixtures/host/, and a DevKit end-to-end test on a fresh chain (Dex prerequisites, then the publications, then init and addLiquidity).
D5 docs/protocol/dev-host-1.md, schemas Wire forms and codes for the new methods, and the I1–I14 coverage table.

Tests

  • Coordinating session, real Gradle: ./gradlew --no-watch-fs build -PnoDevnet --continue gives BUILD SUCCESSFUL, 1,604 tests, 0 failures, 0 errors, 4 skipped. Of the skips, 3 are the usual ones. (At the time of the first round; fixtures/host/ has since been recorded, see below.)
  • Codex, directly (its sandbox blocks Gradle):
    • host: 105 passed;
    • 34/34 wire replays;
    • runtime 99/99, serve 13/13, dApp 104/104;
    • FixturesTest 1/1 (no change under fixtures/m0);
    • 42 schema checks.

M1b exit's DevKit gates: done. fixtures/host/ was recorded on a freshly reset DevKit (-PdevnetOnly -PjoustHostFixtures), HostVectorsTest replays it offline, and CI's devnet shard 5 runs the end-to-end test on a fresh chain (-PjoustHostE2e).

Review: independent design and security reviews (Claude agents) and the fix rounds are on this PR as comments (round 3 at the time of writing); Codex re-review follows when its usage resets.

Known TODO (ADR Q7): deployment returns an empty governor list, and governor-authorized calls stay refused (authorizedBy).

🤖 Generated with Claude Code

https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv

satran004 and others added 2 commits November 20, 2026 03:45
…er dev-host protocol 1

Build prerequisite transactions from a call's complete holder and registration
answers. Project effects from the balanced body and redeemers, and page
inspection results over session snapshots. Exercise historical wire replay,
the DevKit vector format and the fresh-chain workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
Include eligible wallet UTxOs carrying the offered native assets before
QuickTx balances the fixed script inputs. Preserve the default JVM
wallet path. Check output quantities and both spending and collateral
value conservation from call-local chain evidence before reservation.

Replay the split-wallet Dex recording and cover the original negative
change, an unfunded nonnegative output, and reserved token selection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
…ADR-0022 §9)

24 vectors recorded by DevKitHostTest.recordHostVectors on a freshly reset
DevKit (-PdevnetOnly -PjoustHostFixtures), every recorded transaction accepted by
the node: Bank, Dex (publications, init, addLiquidity with native assets) and
HostCouncil (owned init/action/destroy, a destroy with events, @quorum with the
caller alone and with a second signer), the reconstructed combined verifier
publication, and typed unsupported requests (authorizedBy, keyed, maps, params,
unverifiable). HostVectorsTest replays all 24 offline; no key material is in
the vectors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
@satran004

Copy link
Copy Markdown
Member Author

Update · head 59efe5a: M1b's DevKit gates pass. On the way, a real bug was found and fixed.

The bug. On a freshly reset DevKit, the recorder's Dex addLiquidity paid 100 ADA plus 100,000 M1B. The returned body had payer change of −100,000 M1B, and the node rejected it ("DeserialiseFailure 545 expected word").

Root cause. AssetTx.java:285 returned early for every WalletAccount, so the wallet's token inputs were never collected. With the instance input fixed, CCL 0.8.0-pre7 builds change from the fixed inputs, and its later fee selection asks only for lovelace. It picked the ADA-only sibling UTxO and left the token deficit in change. The negative change and the positive payment cancel, so plain conservation passes.

Fix (4983f456, Codex):

  • Collection: with the host's claim store, the offered units are collected explicitly. The default JVM store keeps its historical shortcut, byte-identical.
  • Balance gate: BodyBalance refuses any body with a negative output quantity or a per-asset imbalance, as internal/unbalanced. It runs before anything is reserved or returned. It covers mints and burns, withdrawals, fees, deposits, and collateral with its return.
  • Regression tests:
    • AssetBalanceTest replays the exact failing recording; it failed before the fix;
    • a selection test with an ADA-only UTxO first, a reserved token UTxO second and an eligible token UTxO third;
    • the refusal itself.
  • The default path has the same latent bug. It is filed separately as Runtime: a wallet prepare paying native assets can build negative token change (AssetTx wallet shortcut) #152 and left unchanged here.

Recordings (59efe5aa). fixtures/host/ holds 24 vectors, recorded on a freshly reset DevKit with every transaction accepted:

  • Bank, Dex and HostCouncil publications and calls;
  • owned init/action/destroy, and a destroy with events;
  • @Quorum with the caller alone and with a second signer;
  • the reconstructed combined publication;
  • typed unsupported requests.

No key material is in the vectors.

Verification (coordinating session, real Gradle)

  • ./gradlew build -PnoDevnet --continue: BUILD SUCCESSFUL, 1,607 tests, 0 failures, 0 errors, 4 skipped.
  • :julc-state-host:test -PdevnetOnly -PjoustHostFixtures --tests '*DevKitHostTest.recordHostVectors' on a fresh DevKit: PASSED.
  • :julc-state-host:test --rerun -PnoDevnet --tests '*HostVectorsTest': 24/24.
  • :julc-state-host:test -PdevnetOnly -PjoustHostE2e --tests '*DevKitHostTest.freshChainDeployment' on a fresh DevKit: PASSED. It covers prerequisites, then signing and submitting the publications, then Dex init and addLiquidity with the verifier withdrawal, checking the LP supply.

The independent design and security reviews are still to come.

satran004 and others added 2 commits November 21, 2026 00:51
…/dev-host-m1b

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
DevKitHostTest made :julc-state-host:test a DevKit module, which plan refused because no shard listed it. Its
end-to-end test needs a fresh chain, which only a shard's own new DevKit gives, so the module gets a shard of its
own; plan refuses it next to anything else, and that shard runs with -PjoustHostE2e. Recording the vectors
(-PjoustHostFixtures) stays a manual step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
@satran004

Copy link
Copy Markdown
Member Author

CI fix · head d8b65d79 (all checks green)

  • Merged feat(gradle): ADR-0022 M1a-3 — the joustHostSpec launch spec, TestKit consumer gate and replay gate #150's NIO warm-up (fb270669) with a merge commit (088ce7af, no force-push); the Linux trace passes here too: all 128 host tests under the trace in a privileged container, and in CI.
  • plan refused the shard list because DevKitHostTest made :julc-state-host:test a DevKit module. The module now has a shard of its own (a fresh chain on that shard's own DevKit), plan refuses it next to anything else, and that shard runs with -PjoustHostE2e. So the M1b exit's fresh-chain end-to-end test now runs in CI: DevKitHostTest > freshChainDeployment() PASSED in devnet (5). Recording the vectors (-PjoustHostFixtures) stays manual.

🤖 Generated with Claude Code

satran004 and others added 3 commits November 21, 2026 22:42
…nical units, call-body shape (#151 review r1)

Design review r1 (DB1-DB9) and security review r1 (SB1-SB4) of d8b65d7:
- DB1: publish refuses `pending` while a live transaction already publishes the prerequisite or one of its components
  (derived from the body, so restored bodies count); verifier:h overlaps referenceScript:h and stakeRegistration:h.
- DB2: tests that fail if the owned-spend instance or reservation check is removed.
- DB3: a publication the wallet cannot pay is the runtime's refusal, as in prepare (cause chain kept).
- DB4: a prerequisite id foreign to the contract is bad/request; a stale one stays a refusal.
- DB5: the seed message names reservations on a session store; the default store keeps its message.
- DB6: drop the unused unsupported codes m1b and notYet from the protocol doc and schemas.
- DB9: say in AssetTx why only the default store keeps the wallet shortcut, and link #152.
- SB1: at most 64 co-signers (protocol doc, methods schema), refused before any account is built.
- SB3: a call body with a certificate, a non-zero or foreign withdrawal, or a foreign mint is internal/unbalanced.
- SB4: chain-read units must be lovelace or lowercase policy+name (at most 32 bytes): one spelling per asset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
# Conflicts:
#	docs/protocol/dev-host-1.md
…151 review SB2)

The traced forked session test also starts one session per fixtures/host vector (publications, owned and quorum
calls, the unsupported families), answers its recorded reads and checks its bytes, so publish, owned and quorum
paths are observed for sockets, processes and file writes, not only the plain prepare. Verified on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
@satran004

Copy link
Copy Markdown
Member Author

Verdict: CHANGES REQUESTED
Design review (independent Claude review agent) · round r1 · head d8b65d7

Design review · round r1 · head d8b65d7

Scope: PR #151 (ADR-0022 M1b), git diff origin/feat/dev-host-m1a-gradle...d8b65d79. I read the Java and JS sources,
the protocol document and schemas, and the way fixtures/host/ is recorded and replayed. I did not review the fixture
JSON line by line. My worktree was a detached checkout at d8b65d7 in the scratchpad. The probes lived only there and
were moved out afterwards (scratchpad/probes/), and the worktree is clean.

Summary

The M1b design is implemented faithfully, and nothing I found contradicts ADR-0022:

  • The D14 verifier table is implemented row by row (Prerequisites.java:57-72).
  • Publications are bounded before balancing (Publication.build), and the result's validTo is read from the body.
  • Registration knowledge is learned only at final confirmation or from a registered assertion. It is dropped on
    rollback, on a rewound reset and on restart.
  • Listings follow D15: one read, sorted, LRU of 8, limit 500, owner taken from the datum.
  • decode answers ambiguous when more than one type fits.
  • Quorum: the caller is always counted and is deduplicated by key hash. The order does not matter because
    TxRunner dedupes and sorts the required signers, as the engine path does (DescribedContract:313/401).
  • Predicted effects are projected from TxPlan.of(tx), the returned body and its redeemers.

Shared-runtime changes leave the default path unchanged:

  • exportPrepared(rt, what, claimed) delegates with null.
  • The new prepareReferenceScript/VerifierHandle.prepare overloads are additive.
  • The AssetTx shortcut is still taken for every WalletAccount on ClaimStore.jvm(). The only non-JVM store in
    main code is the host's (Session.java:130). DevHostSeamsTest checks both branches.
  • The engine (julc-state-runtime-wasm/Prepare.java) sets no claim store, so it is unaffected too.
  • ServedContract.call is still called with signers == null by the server.

The host-path asset fix holds:

  • My probes covered three wallet layouts:
    • a single rich token UTxO;
    • a rich token UTxO plus an ADA-only one;
    • a token UTxO with too little ADA, which forced an extra fee input.
  • All three built bodies that pass BodyBalance. No input was counted twice.
  • The recorded negative-change body is refused (AssetBalanceTest).

Recorded fixtures are checked, not just stored:

  • Every fixtures/host vector except the labelled reconstruction was submitted to a fresh DevKit and confirmed
    (DevKitHostTest.Node.submit).
  • Each vector is replayed byte for byte offline (HostVectorsTest.recordedVectors, which runs at this head; it does
    not skip).
  • CI shard devnet (5) ran freshChainDeployment → PASSED on a fresh chain.

Two P2s remain open:

  • publish does not refuse while a publication of the same prerequisite is still pending.
  • The new owned-spend safety checks have no test that would fail if they were removed (shown by mutation).

Findings

DB1 · P2 · publish builds a second publication while the first one is still pending

  • Where: julc-state-host/src/main/java/org/julclang/state/host/Prerequisites.java:107-111 (next) and
    Session.java:212-214. Registration knowledge is tracked in Reservations.java:168-180 for registrations only.
  • Problem: next(id) consults only this call's chain reads and learned registrations. It does not check whether a
    live (prepared or shallow) reservation of the session already publishes that prerequisite. So the host builds the
    same publication again, from fresh inputs, because the first one's inputs are reserved.
    • For referenceScript and verifier, a second holder output locks a large minimum-UTxO amount (about 50 ADA for
      Dex) at a script address that no JOUST validator releases.
    • For stakeRegistration on an unknown provider (DevKit), prerequisites keeps listing the registration from
      inclusion until final depth. A client that publishes again gets a second registration, which the ledger rejects.
  • Evidence: a probe (scratchpad/probes/ProbeOwnedTest.publishTwiceWhilePendingAndOutOfOrder) publishes
    referenceScript:85c72ee1… and then requests the same id again before settlement. The host attempted a second build.
    It failed only because the synthetic wallet's remaining funds were reserved: internal/internal InsufficientBalanceException. A funded wallet gets a second unsigned holder transaction.
  • Why it matters: D8 makes the host's refusal authoritative for pending work. D13 rule 4's absence check by the
    client cannot see a transaction that has not landed. The client's own pending set is the only other guard, and D14
    calls publication "bounded".
  • Requested change:
    • Record the prerequisite id on every publication reservation, not only the credential.
    • In publish, refuse with refusal/pending, naming the reservation, while a live reservation holds that id or any
      component of it: verifier:h overlaps referenceScript:h and stakeRegistration:h.
    • Add a test.
    • Alternatively, if this is intended, state in D14 and the protocol document that only the client prevents it.

DB2 · P2 · No test protects the owned-spend pending check or the datum-owner check

  • Where: julc-state-host/src/main/java/org/julclang/state/host/Session.java:268-283: the owned object lookup,
    object does not belong to instance and reservations.avoids(spent) for owned spends.
  • Problem:
    • These lines carry D8 (no prepare over a reserved object input) and D15/D16 (an object belongs to the instance its
      datum names) for the new owned path.
    • The object is a script input. Coin selection's avoids never sees it, so this check is the only guard against
      building a second transaction over a pending object.
    • Only Counter's instance-level pending is tested (IntegrationTest.pendingInstanceAndRewindFenceAcrossPrepares).
  • Evidence:
    • Mutation run: I deleted the owner check and skipped the pending check for owned kinds. The full
      :julc-state-host:test suite then passed: 130 tests, 0 failures. The original was restored afterwards.
    • Behaviour today is correct (probe ProbeOwnedTest.ownedPendingAndOwner):
      • a second Bank ownedAction or ownedDestroy → refusal/pending reserved input …#0;
      • the wrong instance → bad/request object does not belong to instance;
      • an unknown object → refusal/runtime … not found.
  • Requested change: add host tests over the M0 Bank recordings. Each should fail if its check is removed:
    • a repeated ownedAction and ownedDestroy → pending, then discarded, then success with new bytes and the same
      reservation behaviour as IntegrationTest;
    • an owned spend naming another instance → bad;
    • an owned output with an unrecognised or foreign datum → bad, never a build.

DB3 · P3 · Wallet shortfalls in publish come back as internal/internal

  • Where: Prerequisites.publish and Publication.build. The CCL InsufficientBalanceException escapes
    unclassified.
  • Problem: a wallet that cannot pay is not a host fault. The same condition inside prepare surfaces as a
    refusal.
  • Evidence: DB1's probe got {"kind":"internal","code":"internal","message":"InsufficientBalanceException: Not enough funds …"}.
  • Requested change: classify it as a refusal (the runtime code, as in prepare) in Errors or at the call site.

DB4 · P3 · An unknown prerequisite id is refused with prerequisite instead of bad

  • Where: Prerequisites.java:110.
  • Problem: publish with prerequisite: "bogus", or with a malformed id, answers refusal/prerequisite "refresh the prerequisite list". That code means "work is outstanding". A request naming no possible prerequisite of the
    contract is a bad request.
  • Requested change: answer bad/request when the id is not kind:hash for one of the contract's possible
    components. Keep refusal/prerequisite for a real component that is out of order or has a changed shape.

DB5 · P3 · ownedInit with every wallet input reserved gives a misleading message

  • Where: the runtime's seed pick under the host store. The message comes from Designation.
  • Problem: a second ownedInit while the wallet's only UTxO is reserved answers refusal/runtime "deploy: every UTxO of the caller is designated by a keyed operation". Nothing is keyed. The inputs are reserved by the host's
    reservations.
  • Evidence: probe ownedPendingAndOwner (ownedInit second attempt).
  • Requested change: word the message for avoided inputs, for example "reserved by pending transactions", when the
    store is not the JVM store. Optionally return pending when every candidate seed is reserved.

DB6 · P3 · The protocol still lists codes the host no longer emits

  • Where:
    • docs/protocol/dev-host-1.md:183 (m1b, notYet);
    • docs/protocol/dev-host-1/error.schema.json:61;
    • docs/protocol/dev-host-1/results.schema.json:18-19.
  • Problem: nothing in M1 produces these codes any more: Contracts.code and Session were changed in this PR.
    Clients and conformance kits written against the schema will still accept them.
  • Requested change: drop them, or mark them reserved or historical.

DB7 · P3 · Effects.sends assumes the verifier's reward redeemer is at index 0

  • Where: julc-state-host/src/main/java/org/julclang/state/host/Effects.java:60-62.
  • Problem: the assumption holds in M1's served matrix, where there is no other withdrawal. The @Params, map and
    governor contracts that would add one are refused. A later milestone that serves a second withdrawal would parse
    the wrong redeemer as OutputClaims and fail with internal.
  • Requested change: derive the pointer from the body's ledger-ordered withdrawals and the pinned verifier's reward
    address, or assert that there is exactly one withdrawal. Note it in the code for M3.

DB8 · P3 · The PR description is out of date

  • Problem: the body says the DevKit gates are not done and that HostVectorsTest skips. At this head:
    • fixtures/host/ holds 22 recorded vectors (59efe5a), and HostVectorsTest.recordedVectors runs them;
    • CI devnet (5) ran DevKitHostTest.freshChainDeployment → PASSED (run 44777644643).
  • Requested change: update the Tests section and the counts before merge.

DB9 · P3 · The asset-collection branch is chosen by claim-store identity

Checked and found consistent

  • D14:
    • Script presence is searched over the complete holder answer: chunked, last chunk (publicationChecksTheLastChunk…).
    • Registration is true, false or unknown. A definite provider answer wins, and session knowledge applies only to
      unknown.
    • The order and ids match the protocol table. A pure kind-0 certificate with keyDeposit is checked in
      BodyBalance.
    • The holder lovelace is between the minimum and the minimum plus 1 ADA, checked independently with
      MinAdaCalculator in verifierTableBuildsOnlyMissingComponentsBeforeBalancing.
    • prepare refuses with prerequisite while anything is missing. deployment reads no stake registration and
      needs no wallet.
  • D8:
    • A publication reservation carries its credential and is learned only in state confirmed.
    • A deep rollback drops that knowledge and fences building. A rewound reset clears assertions and downgrades entries.
    • expiredOnArrival, window and the commit at the result write are unchanged. The checkLive removed before
      reservations.prepare is harmless: prepare only allocates an id, and the commit runs only after delivery.
  • D16:
    • Co-signers are lowercase 28-byte hashes made into enterprise WalletAccounts (I5). Co-signers on a plain call →
      bad.
    • The quorum kinds allowed are action, destroy, ownedAction and ownedDestroy. migrateTo → unverifiable.
      authorizedBy, params and keyed codes are unchanged.
    • The generated Account... is required, else bad. Body signers are tested as a set for caller only, caller plus
      another, and duplicates, and the DevKit vectors were ledger-accepted with one and with two keys.
  • D5a:
    • State is found by the thread token at the contract address (null for ownedInit and destroy). Objects are found by
      token and mint sign (created, updated, removed).
    • Events come from the redeemer at its ledger pointer. Spend pointers are sorted by txid bytes then index, which
      matches lowercase hex order.
    • Payouts are matched by address and input tag, with the full value and lovelace owed. The runtime merges owed
      amounts per recipient, so one output is never attributed twice. Sends carry owed from the claim metadata.
  • D15:
    • The snapshot is touched only on commit. LRU uses putLast. listingGone is returned after eviction, after reset
      and on a method mismatch.
    • Unrecognised items appear in both listings. Keyed datums carry instance, as the Registry description shows.
  • BodyBalance:
    • Inputs, mint, withdrawals, outputs, fee and registration deposits must sum to zero. Collateral is checked
      separately. Negative output quantities are refused.
    • Fail-closed internal/unbalanced is documented. CCL TransactionBody defaults its lists to non-null, so the
      unguarded loops are safe for built bodies.

What I ran

  • git fetch; a detached worktree at d8b65d7 in the scratchpad; read ADR-0022 (D5, D5a, D8, D9, D13–D16, §8, §9),
    docs/protocol/dev-host-1.md, the schemas, gh pr view 151, gh pr checks 151 and the devnet (5) job log.
  • ./gradlew --no-watch-fs :julc-state-host:test at d8b65d7 plus two probe classes: BUILD SUCCESSFUL, 135 tests,
    0 failures, 2 skipped (both in DevKitHostTest, as expected without -PdevnetOnly). HostVectorsTest replayed the
    recorded vectors.
  • Probe ProbeRichTokenTest: three wallet layouts on the split-wallet Dex addLiquidity recording. All built bodies
    balance and contain no double-counted input.
  • Probe ProbeOwnedTest:
    • owned pending, wrong owner and unknown object for Bank ownedAction, ownedDestroy and ownedInit;
    • a duplicate pending publish, an out-of-order publish and an unknown id for Dex.
  • Mutation run (DB2): :julc-state-host:test with the owner and owned-pending checks removed → 130 tests,
    0 failures. Reverted afterwards.
  • No DevKit or devnet runs, no pushes, no commits, no comments.

@satran004

Copy link
Copy Markdown
Member Author

Verdict: APPROVED
Security review (independent Claude review agent) · round r1 · head d8b65d7

Security review · round r1 · head d8b65d7

Scope: git diff origin/feat/dev-host-m1a-gradle...d8b65d79, sources only (host Session, BodyBalance, Prerequisites,
Effects, ContractDatums, Listings, Contracts, Reads, Reservations; runtime Publication, AssetTx,
StateContractHandle, VerifierHandle, TxRunner.exportPrepared; ServedContract quorum/owned dispatch), checked
against ADR-0022 §2, D5/D5a, D12–D16, I5/I9/I10 and docs/protocol/dev-host-1.md.

No P0–P2 findings. Four P3 findings follow (SB1–SB4).

What holds (checked, with no counterexample found)

  • Value conservation (4983f45). BodyBalance.check runs in Session.prepared on every body that prepare and
    publish return, before the reservation is made. Inputs are resolved from this call's snapshot, and a missing or
    duplicate input is refused. It adds mints (a burn is negative) and withdrawals, subtracts outputs (a negative output
    quantity is refused), the fee and one key deposit per certificate. Only kind 0, or kind 7 carrying the protocol
    deposit, is accepted; any other certificate, a donation or a proposal is refused. Collateral is balanced on its own
    path. The AssetTx change (a wallet with a session store now collects its token UTxOs explicitly) relies on this
    check: if QuickTx counted an input twice or produced a negative change (the recorded Dex case), the result is
    internal/unbalanced, never a body handed out. Reserved token UTxOs are skipped (claimStore().avoids).
  • Signers. The caller and co-signers are address-only WalletAccounts, so no key is ever used. Quorum co-signers
    are checked as 28-byte hex and deduplicated with the caller by key hash, and the caller is always added
    (Session.java:230-243). TxRunner still adds every input and collateral owner, so signers covers the body's
    needs. A publication's signer is the payer alone, and its inputs come only from the payer's address.
  • Owned objects. The object id must match 4f followed by 28 bytes. The spent output is the first one at the
    contract address that holds the token, and its holding datum must name the instance in the request; the reservation
    check runs on that output. The runtime finds the object through the same snapshot with the same exact unit match, so
    a unit spelled differently cannot get past the reservation check. Ownership and authority are still enforced by the
    validator, which is evaluated locally (D6a). Naming the owner as a co-signer only makes the body need the owner's
    real signature, and @SignedBy on a non-quorum method refuses co-signers outright.
  • Publication (D14). The verifier table matches the ADR, and the parts are re-derived from this call's reads on
    every publish. An out-of-order or reshaped id is refused with refusal/prerequisite; a satisfied one returns null.
    Publication.build sets validTo before balancing, and prepared refuses a body without an upper bound or one
    above now + ttlSlots (I9). Registrations are kind 0 with the deposit accounted for. A holder output carries no
    datum, and its deposit is the minimum UTxO plus 1 ADA. Registration knowledge is consulted only when the read is
    unsupported, and it is dropped on rollback and on a rewound reset.
  • Reads. UTxO addresses and refs must match the query, quantities must be non-negative integers and units unique,
    datum hashes are re-derived, and failed ends the call. TransactionService throws, so no submission path is
    reachable. Read count and byte caps apply.
  • Predicted effects. They are projected from TxPlan.of(tx) (the body) and the body's redeemers. Only owed comes
    from build metadata. Send claims that do not match the spent input, or metadata without a claim, throw (fail
    closed). Event pointers use ledger input order.
  • Refusals. keyed, maps, params, authorizedBy, migrateTo, batched, moves, admissions, receives, deposits
    and needsService without a recipe are refused before any build. A quorum init is refused. Sends need the output
    verifier's prerequisites first.
  • Resources. At most 8 listing snapshots are kept, a page holds at most 500 items, an oversized page gives
    tooLarge, and deep CBOR gives tooDeep. A call that overruns its deadline ends the session after 2 s.
  • I10 (by reading the code). None of the new code writes files, opens sockets or starts processes. Test-only
    dependencies (examples:dex/registry/pool) stay in testImplementation.

Findings

SB1 · P3 · julc-state-host/src/main/java/org/julclang/state/host/Session.java:230-243, docs/protocol/dev-host-1/methods.schema.json:87: unbounded co-signer list, each entry costing a key generation

Problem. cosigners has no item limit, in the code or in the schema. Every entry becomes a WalletAccount, whose
CCL Account(Network) superclass generates a random BIP39 mnemonic and derives keys. All of this happens before the
first chain read, in a loop that never checks for cancellation.
Evidence. Probe scratchpad/probes/CosignerCost.java, run on the host's test classpath: 2,000 address-only
accounts took 10,188 ms (about 5.1 ms each). One 4 MiB prepare frame fits about 71,000 entries (59 bytes each), or
about 6 minutes of CPU. The deadline then fires, and 2 s later the session is stopped ("execution did not stop within
two seconds"). This fails closed, but a single frame from either side kills the session (T5).
Requested change. Refuse more than a small fixed number of co-signers (for example 32, or the quorum's key count
where the description gives it) with bad/request, before building any account. Add a matching maxItems to the
schema.

SB2 · P3 · julc-state-host/src/test/java/org/julclang/state/host/ForkedSessionTest.java:64-120, docs/protocol/dev-host-1.md:206: I10's OS-level check still runs only the M1a plain prepare

Problem. The forked check (empty working directory, home and temp; strace/unshare on Linux CI) replays one
plain prepare. M1b adds new reachable runtime paths: publish through Publication.build and
VerifierHandle.prepare, which sit next to VerifierHandle.ensure's submitPlain and sleep loop listed in D12;
named views running generated code; listings; decode; owned and quorum prepares. None of them runs under that
check. Reading the code finds no side effect, but the invariant's evidence does not cover the milestone, and the I10
row in the protocol document is unchanged.
Requested change. In ForkedSessionTest, also replay the recorded fixtures/host vectors, or at least one
publish per shape, a named view, an objects listing, an owned call and a quorum prepare. Update the I10 row.

SB3 · P3 · julc-state-host/src/main/java/org/julclang/state/host/BodyBalance.java:31-41, Session.java:298-303: a call body gets no shape check; certificates and any withdrawals pass

Problem. BodyBalance is a balance check only. A prepare body with a registration certificate, a non-zero or
foreign withdrawal, or a mint under another policy would pass, provided it balances. Today none of these can be
produced, since the runtime's publish-on-demand paths are refused while hosted and the generated builders add only
zero withdrawals. Still, nothing in the host refuses such a body. D13 makes this the client's job, so this is defence
in depth only.
Requested change. For prepare (not publish), refuse before reserving: any certificate; any withdrawal other
than a zero withdrawal at the pinned output verifier's reward address (or the contract's own, for withdraw-zero
contracts); and any mint outside the contract's policy. Use internal/unexpectedBody or a similar code. For
publish, check that the body has exactly the shape of the part being built (D13 rule 4) as the same kind of guard.

SB4 · P3 · julc-state-host/src/main/java/org/julclang/state/host/Reads.java:172-180, BodyBalance.java:65: unit spelling is not canonicalised at the read boundary

Problem. checkOutput only requires each unit to be non-empty text and unique as a string. So abcd…, ABCD…
and 0xabcd… can all appear for one asset in one output. BodyBalance normalises input units
(AssetUtil.normalizeUnit, which lowercases and strips 0x), while Session's owned lookup and SnapshotBackend's
asset filter compare exact strings. A crafted answer that lists one NFT twice under two spellings makes the host's
balance check sum it to 2. If QuickTx also carries both into the outputs, the check passes for a body the ledger will
reject. Every path I traced still fails closed (the object is not found, or the ledger rejects), and only the client
can craft such an answer, so this is hardening.
Requested change. In checkOutput, accept only lovelace or lowercase hex of 56 to 120 even-length characters.
Refuse any other spelling, and any duplicate after normalisation, with inconsistentRead.

Notes (not findings)

  • predicted.state is null both for a destroy and for an owned call that does not touch the instance. This is
    consistent with the protocol text, but a client should not label null as "destroyed" without checking the kind.
    D13 rule 5 already makes it a host claim.
  • Reservations.entries is never pruned within a session. This predates M1b (M1a); it grows only with the client's
    own prepares.

What I ran

  • A detached worktree at d8b65d7 (scratchpad/rev151-sec); read CLAUDE.md, ADR-0022 §2/D5/D5a/D12–D16/§4, the
    protocol document, gh pr view 151, and every changed source file listed above, plus the runtime paths they call
    (TxRunner.prepareInScope, AssetTx.collectAssets, Compose, WalletAccount, SnapshotBackend, TxPlan).
  • ./gradlew --no-watch-fs :julc-state-host:test -PnoDevnet: BUILD SUCCESSFUL, 128 tests, 0 failures, 0 errors,
    0 skipped (the host vectors are now recorded).
  • Probe scratchpad/probes/CosignerCost.java on the host test classpath (taken through the scratch init script
    scratchpad/probes/cp.gradle; no repository file was changed): about 5.1 ms per address-only co-signer account.
  • No DevKit, no pushes, commits or comments.

@satran004

Copy link
Copy Markdown
Member Author

Author reply: round r2 · head b59a5f8

Addresses the design review r1 (changes requested: DB1, DB2) and security review r1 (approved) of d8b65d7. Merges #150 r2.

Finding Change
DB1 (P2) publish refuses refusal/pending while a live transaction already publishes the prerequisite or one of its components (derived from the body, so restored bodies count; verifier:h overlaps referenceScript:h and stakeRegistration:h)
DB2 (P2) Tests for the owned-spend instance check and reservation check; each fails with its check removed
DB3 A publication the wallet cannot pay is the runtime's refusal, as in prepare
DB4 A prerequisite id foreign to the contract is bad/request; a stale one stays a refusal
DB5 The seed message names reservations on a session store; the default store keeps its message
DB6 m1b and notYet removed from the protocol doc and schemas
DB9 AssetTx says why only the default store keeps the wallet shortcut, and links #152
DB7, DB8 DB7 holds for every M1 call (noted); DB8: PR description to be refreshed
SB1 At most 64 co-signers (doc, schema), refused before any account is built
SB2 The traced session also replays every fixtures/host vector; passes on Linux
SB3 A call body with a certificate, a non-zero or foreign withdrawal, or a foreign mint is internal/unbalanced
SB4 Chain-read units must be lovelace or lowercase policy + name of at most 32 bytes

Host 133, runtime 103 and serve 16 tests pass.

… and send pointer (#151 review r2 DB10, DB7)

- DB10: the protocol doc and reads.schema.json state the canonical unit format the host requires.
- DB7: a send's predicted effects require the output verifier's withdrawal to be the body's only one, failing closed
  otherwise, instead of assuming the reward pointer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
@satran004

Copy link
Copy Markdown
Member Author

Verdict: APPROVED
Design review (independent Claude review agent) · round r2

Design review · round r2 · head b59a5f8

Scope: d8b65d79..b59a5f8d. That range holds the author's commits 7cf2df3 and b59a5f8 plus the merged M1a stack: #145 r2 at 90e225e, #149 r1 fixes at b59db8c, and #150 at b5dc012. I checked the code; I did not rely on the author's reply. No P0, P1 or P2 finding is open. Three P3s remain: DB7, DB8 and DB10, the last one new.

Status of r1 findings

ID Pri Status Reason
DB1 P2 Resolved See DB1 below.
DB2 P2 Resolved M1bTest.ownedSpendsCheckTheirInstanceAndReservation asserts both refusals and their messages. I re-ran the mutations at b59a5f8 (see DB2 below), and each mutation fails this test.
DB3 P3 Resolved See DB3 below.
DB4 P3 Resolved Prerequisites.possible holds every id the contract's deployment can list. An id outside that set is now bad/request; a stale or out-of-order id is still refusal/prerequisite (Prerequisites.java:113). Tested with referenceScript:00….
DB5 P3 Resolved With a session store, the seed message now says "designated or reserved by a pending transaction". The default store keeps its historical message (StateContractHandle.java:559-561).
DB6 P3 Resolved m1b and notYet are gone from dev-host-1.md, error.schema.json and results.schema.json. A grep of the protocol docs and the host sources finds neither.
DB7 P3 Not resolved (accepted deferral) Effects.java:60-62 still takes reward pointer 0. The reply says this holds for every M1 call, and I agree: the new checkCall (SB3) limits a call's withdrawals to zero ones from the contract's own or the verifier's reward account, and no served M1 call uses the contract's own. There is still no comment or guard for M3. Leave it open as a P3.
DB8 P3 Not resolved The PR body still says "Not done yet: the M1b exit's DevKit gates" and "HostVectorsTest … skips itself". At this head the vectors are recorded and replay. Refresh the body before merge.
DB9 P3 Resolved AssetTx.java:285-286 now explains why only the default JVM store keeps the wallet shortcut, and links #152.

DB1 (publishing the same prerequisite twice):

  • Reservations.Body.publishes derives, from each body, the D14 ids it would put on chain. A reference-script output gives referenceScript:h; a kind-0 or kind-7 registration gives stakeRegistration:h. Because the ids come from the body, restored bodies count too.
  • publishing(id) checks every live entry (prepared or shallow) and expands verifier:h into both of its components.
  • Session.java:214-215 refuses with refusal/pending after the null early return, so a satisfied id still answers null.
  • The new test aPendingPublicationIsNotBuiltTwice covers the refusal, and also that a discard lets the publication be built again.
  • I removed the check and re-ran the suite: that test fails.
  • The other DevKit case is covered as well. While a stakeRegistration is shallow on an unknown provider, a second publish is refused, because shallow entries are live.

DB2 (no tests for the owned-spend checks). I re-ran the r1 mutations at b59a5f8, one Gradle run of the host module each:

  • Owned pending check skipped, together with the DB1 check removed: the run failed in ownedSpendsCheckTheirInstanceAndReservation and aPendingPublicationIsNotBuiltTwice.
  • Owner check removed alone: the run failed in ownedSpendsCheckTheirInstanceAndReservation.

The coverage has two small gaps, which I accept for M1b:

  • only ownedAction is exercised, not ownedDestroy;
  • there is no case with an unrecognised or foreign datum.

DB3 (wallet shortfall in publish came back as internal):

  • Publication.build now wraps build failures in SubmitException, a JoustException, so they answer refusal/runtime. This matches how TxRunner already treats prepare builds (TxRunner.java:264-267 and :636-637).
  • ReservedInputException and CallAbort are rethrown untouched.
  • Errors.classify walks the cause chain for HostError, ReadFailed, Unsupported and Need before it looks at JoustException. So a read failure or a control event under the wrapper still decides the answer.

New findings

DB10 · P3 · The protocol does not document the new canonical-unit rule (SB4)

  • Where:
    • julc-state-host/src/main/java/org/julclang/state/host/Reads.java:181-198: CANONICAL_UNIT accepts only lovelace|[0-9a-f]{56}(?:[0-9a-f]{2}){0,32};
    • docs/protocol/dev-host-1/reads.schema.json:81: still "unit": {"type": "string", "minLength": 1};
    • docs/protocol/dev-host-1.md:130 (the UTxO field paragraph): says nothing about units.
  • Problem: a client that validates its answers against the published schema can still send 0x-prefixed, uppercase or policy.name units. Those come back as internal/inconsistentRead, with nothing in the protocol explaining why. IntelliAda's provider adapters (Koios, Ogmios) are the likely case.
  • Requested change: put the unit pattern in reads.schema.json and add one sentence to the read-encoding paragraph: units are lovelace or lowercase policy id plus hex name, at most 32 bytes.

Interaction of the merged M1a stack with M1b

None of these merged changes causes a problem for M1b:

  • Scoped calls no longer use the cross-call reference cache (StateContractHandle.findReferenceScript and VerifierHandle.find). This fits D14: Prerequisites reads the full holder set itself on each call, and the runtime's finder now sees the same answers rather than a hit from before a rollback.
  • Input spellings:
    • Claim and reservation keys are lowercase. Designation.ref and Reservations.refs agree, and Reads already requires lowercase tx_hash.
    • So the owned-spend spent ref and the instance ref in Session.prepare are matched in the same spelling.
    • The new D14 publishes ids come from HexFormat, which is lowercase, as are the Part ids from policyId() and hash().
  • Deterministic seed for session stores: the seed is the first eligible UTxO among the first 50 in provider order, so it no longer depends on where reserved inputs fall. This is what makes the owned-init and init bytes replayable. The default store is unchanged.
  • Strict host codec (JsonValues.TYPED): it applies to view and call arguments only. The co-signer, listing and prerequisite parameters are parsed by the host itself. The HTTP service keeps BAD_VALUES, so the default path is unchanged.
  • Typed abort for a read outside a call: this can only make the M1b paths stricter. deployment, view and the listings all run inside withReads.
  • SB3 checkCall: it runs on every prepare, after Effects. The 34 M0 replays still produce identical bytes, and so do all the fixtures/host vectors and the split-wallet Dex vector, so the check does not falsely refuse served shapes. Publications are not passed through it; they keep BodyBalance.check, which allows only pure registrations.

What I ran

  • git fetch, then moved my scratch worktree to b59a5f8. Read git diff d8b65d79..b59a5f8d for the host, runtime, serve and protocol files, the author's r2 reply, and the current PR body.
  • ./gradlew --no-watch-fs :julc-state-host:test at b59a5f8: 135 tests, 0 failures, 2 skipped. Both skips are DevKitHostTest tests, which need -PdevnetOnly.
  • Mutation runs, each one host-module run:
    • (a) owned pending check skipped plus the DB1 publishing check removed: 2 failures, the two tests named above;
    • (b) owner check removed: 1 failure, in ownedSpendsCheckTheirInstanceAndReservation.
  • The source was restored after the mutation runs and the worktree is clean. No DevKit runs, pushes, commits or comments.

@satran004

Copy link
Copy Markdown
Member Author

Author reply: round r3 · head 9688b4a

Addresses design review r2 (approved; DB7, DB8 open P3s, DB10 new) and merges #150 r3.

Finding Change
DB10 The protocol doc and reads.schema.json state the canonical unit format (lovelace or lowercase policy id + token name of at most 32 bytes)
DB7 A send's predicted effects require the output verifier's withdrawal to be the body's only withdrawal and fail closed otherwise (M3b's map calls locate it by pointer)
DB8 PR description to be refreshed

…se fields a call kind does not take (#151 final review F-B1, F-B4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
@satran004

Copy link
Copy Markdown
Member Author

Verdict: APPROVED
Final review (Fable) · head 9688b4a

Final review (Fable) · head 9688b4a

Scope: PR #151 (ADR-0022 M1b), git diff origin/feat/dev-host-m1a-gradle...origin/feat/dev-host-m1b, sources, protocol
document and schemas, and how fixtures/host/ is recorded and replayed (the fixture JSON itself was not read line by
line). Design, correctness and security together. I formed my view from the code and probes first and read the PR
comments afterwards.

No P0, P1 or P2 finding. Five P3 findings (F-B1 to F-B5), none blocking.

Answers to the review questions

Can a crafted request or read answer make the host build a body that moves value or authority beyond the call and
its predicted effects?
I found no way.

  • Every body prepare and publish return passes BodyBalance.check before it is reserved (Session.java:311):
    per-unit conservation over inputs resolved from this call's own answers, mints, withdrawals, outputs, fee and key
    deposits; negative output quantities refused; collateral balanced separately; any certificate other than a pure
    registration with the protocol deposit refused; donations and proposals refused.
  • A call body additionally passes BodyBalance.checkCall (Session.java:302-303): no certificate, only zero
    withdrawals from the contract's or the output verifier's reward account, mints only under the contract's policy.
  • Read answers are canonical at the boundary (Reads.java:181-199): one spelling per unit, non-negative quantities,
    address and ref must match the query, datum hash re-derived. The balance check and every unit lookup therefore see
    the same values.
  • Signers come only from the request: the caller and, for @Quorum methods only, at most 64 lowercase 28-byte key
    hashes made into address-only WalletAccounts. Co-signers on a non-quorum method are bad/request.
  • Probes (below): a single-UTxO wallet holding ADA and the token, a rich token UTxO beside an ADA one in both orders,
    and a token UTxO holding more than is paid. All four bodies balance, spend no input twice, return the token surplus
    as change, and predict the send at the right index. A payout to the fee payer's own enterprise address keeps its
    full value (1,055,950 lovelace for 1 owed) and is attributed separately from change.

Do predicted effects always match the body? Yes for what is reported, with one gap in what may be omitted (F-B1).
Effects projects from TxPlan.of(tx) and the body's redeemers; only owed comes from build metadata. Sends fail
closed on any mismatch between claims, metadata and the spent input, and require the verifier's withdrawal to be the
only one. Event pointers use ledger input order.

Are publications bounded and never duplicated while pending? Yes.

  • Publication.build sets validTo before balancing; Session.prepared refuses a body without an upper bound or
    above now + ttlSlots.
  • Reservations.publishing derives the published components from each live body (so restored bodies count), expands
    verifier:h into both components, and is consulted across contracts because the table is session-wide.
  • I walked the D14 table against Prerequisites.java:61-76 and the state machine (shallow, final, expired, rolled
    back, rewound, restart) and found no path to a second holder output or registration while the first can still land.
  • Registration knowledge is used only when the provider answers unsupported, is learned only at final confirmation
    or from registered, and is dropped on deep rollback, rewound reset and restart.

Do owned and quorum calls bind the right object, instance and signer set? Yes.

  • The owned object must be 4f + 28 bytes; its output is found by exact unit at the contract address; its holding
    datum must name the requested instance (Session.java:276-285); the pending check runs on that output.
  • A shared owned action only reads the instance as a reference input (OwnedObject.java:331, :418), so the object
    is the only script input to reserve.
  • The runtime also refuses a build over a reserved input (Designation.checkReservation), a second net under the
    host's pre-check.
  • Quorum: the caller is always added, deduplicated by key hash; quorum is limited to action, destroy, ownedAction and
    ownedDestroy; ServedContract.call requires the generated Account... parameter.

Do refusals fail closed with the documented codes? Yes in every probe:

Request Answer
owned action or destroy on an unknown object refusal/runtime "object … not found"
ownedInit or action on an unknown instance refusal/runtime "instance … not found"
cosigners: null, uppercase key hash bad/request
decode of a datum no declared type fits bad/request
view on a missing instance refusal/runtime
listings on Registry, Pool, Bank, Dex, HostCouncil with a foreign output {unrecognized: ref}, never an error

deployment, prerequisites, instances, objects and decode work on keyed (Registry) and intent (Pool)
contracts; their actual results match results.schema.json by inspection.

Any default-path runtime change that alters behaviour or bytes? No.

  • AssetTx.java:287: the wallet shortcut is still taken whenever the store is ClaimStore.jvm(); the only non-JVM
    store in main code is the host's (Session.java:130).
  • TxRunner.exportPrepared(rt, what, claimed) delegates with null, keeping the old expiry.
  • StateContractHandle.prepareReferenceScript(String, long, List), prepareStakeRegistration and
    VerifierHandle.prepare are additive; the seed message changes only for a non-JVM store.
  • ServedContract.call keeps its old signature; the lookup now uses at.getClass(), the generated client class that
    at returns.
  • Runtime (103) and serve (16) tests pass at this head.

Fixtures. Each fixtures/host vector except the labelled reconstruction is built in a live session, submitted to
DevKit and confirmed, then rebuilt in a fresh session from the same ordered answers and compared byte for byte before
it is written (DevKitHostTest.Node.build, :122-143). HostVectorsTest.recordedVectors replays all of them offline
with strict request order and no unused read; it ran here (24 dynamic tests, not skipped).

Findings

F-B1 · P3 · julc-state-host/src/main/java/org/julclang/state/host/Effects.java:42-50 — a recorded payout with no matching output is dropped silently

  • Problem: for each payout the build recorded, Effects looks for an output with the same address and tag datum
    and adds nothing when none matches. Sends, in the same class, throw on any mismatch (:73, :79). So predicted
    can under-report payouts without any signal, while D5a says it describes what the transaction does.
  • Evidence: by reading the code. I could not produce a body where it happens: the M0 replays, the quorum test and
    my enterprise-payer probe all attribute their payouts. ReplayTest.java:99-102 iterates the payouts it gets and
    would pass on an empty list for Bank withdraw.
  • Requested change: throw (as sends do) when a recorded payout matches no output, and assert a non-empty payout
    list for a recorded call that pays one.

F-B2 · P3 · julc-state-host/src/main/java/org/julclang/state/host/Session.java:216-217 — a publication body gets no positive shape check on the host

  • Problem: checkCall guards call bodies (feat(host): ADR-0022 M1b — prerequisites and bounded publication, inspection, owned and quorum calls, predicted effects #151 SB3), but a publish body is checked for balance and bounds only.
    Nothing on the host asserts that it is exactly the part requested: one holder output at the part's target carrying
    that script hash, and/or one registration of that credential, no mint, no withdrawal. The second half of SB3's
    request was not taken up.
  • Evidence: by reading the code. Publication.build and the two builders produce only these shapes today, the
    verifier-table test checks them, and D13 rule 4 makes the client check them, so this is defence in depth.
  • Requested change: after building, compare Reservations.Body.publishes with the ids the Part implies
    (verifier:h → both components) and refuse a body with a mint or a withdrawal, as internal/unbalanced.

F-B3 · P3 · julc-state-host/src/test/java/org/julclang/state/host/HostVectorsTest.java:43-48, :81-90 — vectors pin bytes only; nothing checks results against the published schemas

  • Problem: a vector's expected holds cbor, txHash, the bounds and the body's required signers. predicted,
    signers and plan are not recorded, so a regression in D5a's projections passes every recorded vector. Separately,
    no test in the repository validates a host result against results.schema.json or a request against
    methods.schema.json (the PR body's "42 schema checks" were run by hand).
  • Evidence: grep for results.schema and methods.schema finds only docs/protocol/dev-host-1.md. Predicted
    effects are asserted in ReplayTest and M1bTest for selected fields only.
  • Requested change: record predicted in each successful vector and compare it on replay (it is what M2's
    differential runs will need), and add a schema-validation test, here or in M1c's conformance kit.

F-B4 · P3 · julc-state-host/src/main/java/org/julclang/state/host/Session.java:273-274 — inapplicable instance and object are ignored, not refused

  • Problem: prepare with kind init ignores a supplied instance, and any non-owned kind ignores a supplied
    object (ownedInit ignores it too). A client that sends the wrong kind with an object id gets a transaction for
    something other than it named. D5 refuses unknown fields; these known fields are accepted where they mean nothing.
  • Evidence: by reading the code: instance is read only when the kind is not init, object only for
    owned*, and ServedContract.call does not look at object for ownedInit.
  • Requested change: answer bad/request when instance is present on init, or object on a kind that takes
    none.

F-B5 · P3 · julc-state-host/src/main/java/org/julclang/state/host/Listings.java:10, :17-23 — the listing's tip hash is stored and never used

  • Problem: D15 and the protocol document say a listing snapshot is bound to the query and the tip hash it was read
    at. Snapshot.tip (and contract, instance) are stored but neither returned nor compared, so a client cannot
    tell which chain point a page describes; only method is checked on resume.
  • Evidence: by reading the code; results.schema.json has no tip field for instances or objects.
  • Requested change: return the tip (hash, or the chain point) with each page, or drop the field and the sentence.

Notes (not findings)

  • A contract with a withdraw purpose handler lists stakeRegistration:<policy> as a prerequisite
    (Prerequisites.java:58-60), so every prepare is refused until it is registered, although the purpose call itself
    is unverifiable in v1. This follows D14 as written. I did not run it: no staking example is on the host's test
    class path.
  • DB8 from the earlier rounds is resolved: the PR body now states the DevKit gates as done.
  • CI for this head was still running when I looked (plan succeeded; build, engines and devnet shards had no
    conclusion yet). The fresh-chain end-to-end test runs only there (devnet shard 5); I did not run DevKit.

What I ran

  • git fetch; a detached worktree at 9688b4a in the scratchpad. Read CLAUDE.md, ADR-0022 (§2, D5, D5a, D8, D9,
    D12–D16, §4, §8, §9), docs/protocol/dev-host-1.md and the three schemas' diffs, every changed main source, the
    tests, and the runtime paths they reach (OwnedObject, Designation, AssetTx, VerifierHandle, PreparedTx).
  • ./gradlew :julc-state-host:test -PnoDevnet: BUILD SUCCESSFUL, 133 tests, 0 failures, 0 skipped (34 replays,
    24 host vectors).
  • ./gradlew :julc-state-runtime:test -PnoDevnet: 103 tests, 0 failures.
  • ./gradlew :julc-state-serve:test -PnoDevnet: 16 tests, 0 failures.
  • Three scratch probe classes in my worktree's host test directory, one host-module run each, removed afterwards
    (the worktree is clean):
    • inspection (deployment, prerequisites, instances, objects, decode, view) on Registry, Pool, Bank, Dex
      and HostCouncil; owned calls on unknown objects and instances; malformed co-signers;
    • Dex addLiquidity from fixtures/host/Dex-addLiquidity.json with four wallet layouts;
    • HostCouncil vote paid from the caller's enterprise address with the payout to the same address.
  • gh pr view 151 (comments, body, checks), read only, after forming my view.
  • No DevKit, no full build, no pushes, commits or comments. The main checkout is still at bcd4075 with its original
    untracked files.

@satran004

Copy link
Copy Markdown
Member Author

Author reply: round r4 · head 166a6e4

Final review (Fable) approved with P3s. Taken: F-B1 (a recorded payout without its output in the body now fails closed, as sends do) and F-B4 (instance on init and object on kinds that take none are refused, not ignored). F-B2, F-B3 and F-B5 are noted as follow-ups. Host 133 tests pass.

…he split-wallet build checked on the Dex vector

fixtures/host (21 vectors) recorded on a fresh DevKit chain with
`:julc-state-host:test -PdevnetOnly -PjoustHostFixtures --tests '*DevKitHostTest.recordHostVectors'`; the combined
reconstruction is built from fixtures/m0/dex 0001 and 0003, which #148's dex re-recording restored.
AssetBalanceTest's fixed-build check replays fixtures/host/Dex-addLiquidity.json, the same split-wallet addLiquidity
recorded under pre22 (the supplied failing recording has pre21 scripts); its rejected-body checks keep that recording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
satran004 added a commit that referenced this pull request Nov 22, 2026
…2 recordings

`:julc-state-host:recordClientConformance` over #151's re-recorded host vectors and fixtures/m0/dapp. pre21's
dapp-0034 (a Counter.increment whose state input sorted second) has no counterpart: every plain call of the pre22
dApp flow spends the state output first, so the second plain vector is dapp-0015 (the last increment) at pointer 0;
owned-action and owned-destroy keep a spend redeemer at pointer 1. The conformance document says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
…in and owned replay gate checks coverage

ReplayTest.plainAndOwnedPrepares requires every recording to replay and, together, every plain and owned call kind
of Counter and Bank (PLAIN_AND_OWNED); its message lists what is missing. The protocol document describes the
coverage instead of a count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
satran004 and others added 2 commits November 22, 2026 21:09
…t/dev-host-m1b

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv

# Conflicts:
#	julc-state-host/src/main/java/org/julclang/state/host/Session.java
…feat/dev-host-m1b

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
@satran004

Copy link
Copy Markdown
Member Author

Verdict: CHANGES REQUESTED
Codex adversarial review · head 0ab0c90f

Hold PR #151. A Bank close can pass the documented signing checks with the wrong parent instance, and a withdrawal can be prepared against shared state already reserved for spending. Static review also found ambiguous object selection and two validatable input-selection failures. I did not run the test suite in the read-only checkout.

Findings:

  • [high] The signing rules do not bind an owned destroy to its parent instance (docs/protocol/dev-host-1.md:160-163)
    Consider a stale selection naming bank B and an account token that belongs to bank A, both controlled by the same wallet. Bank.close burns the token, needs no shared bank input, and leaves no holding output. A client following rule 3 can verify the exact token, address, signer and payout while missing the parent mismatch. The host checks the parent, but D13 requires independent verification before signing or export. The existing JS verifier checks holding.instance in decodeNext, which a destroy never calls.
    Recommendation: Require the client to decode the resolved spending input with the method's anchored holding schema and compare its instance with call.instance for every owned spend. Add a wrong-parent Bank.close conformance case.
  • [medium] Bank.withdraw can reference a bank UTxO already pending consumption (julc-state-host/src/main/java/org/julclang/state/host/Session.java:281-295)
    Prepare Bank.setPaused(true), then prepare a customer's Bank.withdraw before the pause lands, using separate funded wallets. The first reservation holds the bank UTxO. The owned-spend branch checks only the account UTxO, although OwnedObject adds the bank UTxO as a reference input for withdraw's @shared state. Both prepares can succeed against the old unpaused state. If the pause lands first, the withdrawal is unusable and must be rebuilt after signing.
    Recommendation: Before returning a prepared body, reject reference inputs that a live reservation already intends to spend. Keep concurrent withdrawals on separate accounts possible when they only read the same bank state.
  • [medium] The first matching output wins even when the object identity is contradictory (julc-state-host/src/main/java/org/julclang/state/host/Session.java:284-289)
    A provider can return the old and new out-refs for the same account token during an indexer transition. Reads rejects duplicate out-refs, so these two distinct refs pass. The ownership scan stops at the first match, and OwnedObject.utxo() also selects the first match. With the old holding first, the host can prepare and reserve the spent account version even though the same answer contains evidence that its supposedly unique token occurs twice.
    Recommendation: Check the complete address answer for exactly one holding of the requested token at quantity one. Return internal/inconsistentRead for multiple matches before dispatching the call.
  • [medium] Bank.open silently ignores a supplied object ID (julc-state-host/src/main/java/org/julclang/state/host/Session.java:273-282)
    The object-field guard exempts every owned kind, including ownedInit. A Bank.open request carrying an existing account ID therefore succeeds and reserves funding for a newly derived account. Even an object-valued JSON field passes because textValue() yields null and the creation path ignores it. The request names one target while the returned transaction funds another.
    Recommendation: Allow a non-null object only for ownedAction and ownedDestroy. Validate the kind-specific fields before prerequisite reads and express the same constraint in methods.schema.json.
  • [medium] Hosted asset selection stops after 1,900 wallet outputs (julc-state-runtime/src/main/java/org/julclang/state/runtime/AssetTx.java:309-314)
    This change routes hosted WalletAccount payments through collectAssets. Its loop reads pages 1 through 19 at 100 items per page. A funded Dex.addLiquidity call whose only matching token UTxO is number 1,901 reports that the caller does not hold the asset, even though Reads already acquired the complete wallet listing. Reserved or unrelated UTxOs in the first 19 pages still count toward the cutoff.
    Recommendation: For hosted calls, scan the cached provider-ordered pages until the requested quantities are covered or the address set is exhausted. Add a regression case with the sole eligible asset input on page 20.

Fixes are in progress; an author reply will follow with the new head.

🤖 Generated with Claude Code

https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv

satran004 and others added 5 commits November 22, 2026 23:29
…) internal

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
…d state, one holding per object, objects only on owned spends, hosted asset selection reads the whole listing (#151 Codex review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
…ts tip counts; asset picks count as spent (#151 Codex re-review)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
…tion skips reference scripts and the composition's inputs (#151 Codex re-review 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
@satran004

Copy link
Copy Markdown
Member Author

Author reply: Codex round · head d0143667

Addresses the Codex review of 0ab0c90f (comment 7080450438) and two re-review rounds (25f7ceaa, 0609a896). Also merges #150 at 2f83143b. a5a6582b fixes a compile break from #145 making ClaimStore.jvm() internal.

Finding Change Test (fails without the change)
[high] Owned destroy not bound to its parent Signing rule 3 (dev-host-1.md): for every owned spend, a destroy included, decode the spent input's holding datum and require its instance to equal call.instance. The kit's checker change and a wrong-parent case belong to #153. doc only at this level
[medium] Withdraw references a bank UTxO a pending tx spends Session.requireUnreservedReferences: a body whose reference inputs a live reservation spends is refusal/pending. References reserve nothing, so reads of the same state stay independent. Documented beside the reservation rule. ReservationsTest.aReferenceToAReservedInputIsPending
[medium] First matching holding wins Reads refuses a listing holding a catalogued contract's unique token twice, or with quantity ≠ 1, before its tip is observed. This covers every listing, objects included, and every provider order. 0x4B names count only for keyed contracts (ADR-0016 I44; re-review 2). ReadsTest.aListingHoldingAUniqueTokenTwiceReleasesNoReservation (reservation stays held; keyed and non-keyed 0x4B), M1bTest.anObjectHeldTwiceIsAnInconsistentRead (both orders)
[medium] Bank.open ignores an object ID Only ownedAction/ownedDestroy take object, as a string, checked before any chain read. Also in methods.schema.json (if/then/else on kind). M1bTest.onlyAnOwnedSpendNamesAnObject
[medium] Asset selection stops after 19 pages A hosted call reads the whole call-local listing in one request, bounded by the host's read limits. DevHostSeamsTest.hostedAssetCollectionReadsTheWholeWalletListing (token on UTxO 1,901)
[medium] (re-review 1) Asset picks not in the composition's spent set Picks go through TxRunner.collect, so the payout funding pick skips them. DevHostSeamsTest.assetPicksCountAsSpentInAComposition
[high] (re-review 2) Asset selection can spend a reference script Asset selection skips reference-script UTxOs. DevHostSeamsTest.assetSelectionSkipsReferenceScriptsAndSpentInputs
[medium] (re-review 2) Second composed payment re-picks the first's input Asset selection skips inputs the active composition already spends. same test

Tests at d0143667

Module Result
julc-state-runtime 121, 0 failures
julc-state-host 147, 2 skipped (DevKit e2e), 0 failures
julc-state-serve 16, 0 failures

Runtime changes (AssetTx.collectAssets)

  • The full listing is read in hosted calls.
  • Picks go through TxRunner.collect.
  • Reference-script and already-spent inputs are skipped.

#165 rewrites the same method, with a pre-credit of spent seeds and the countedInputs/assetInputs capture. When the two meet, keep #165's structure and carry over these four rules.

Codex rounds: the two re-review rounds allowed per level are used up. The second round's three findings are fixed but have not been re-reviewed by Codex.

🤖 Generated with Claude Code

https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv

@satran004

Copy link
Copy Markdown
Member Author

Verdict: CHANGES REQUESTED
Codex adversarial review, re-review (r2) · head 25f7ceaa

Hold PR #151 at 25f7cea. Static review confirms four fixes: owned-spend signing binds the holding to call.instance, reserved spending inputs block new references, object arguments are restricted before reads and in the schema, and hosted asset selection scans the full wallet listing. Duplicate-holding validation remains incomplete, and a funded asset-paying call can still fail during preparation. Tests were not run in the read-only workspace.

Findings:

  • [high] A contradictory holding list can release reservations before it is rejected (julc-state-host/src/main/java/org/julclang/state/host/Session.java:283-298)
    Prerequisites reads the contract address before the duplicate check. Reads.utxos accepts the listing and passes its tip to Reservations.observe, so a tip past the expiry margin can release an existing reservation even though prepare subsequently returns internal/inconsistentRead. The error also depends on provider order: if the first holding names another instance, line 297 returns bad/request before examining the second holding. The objects RPC bypasses this loop and can return both holdings.
    Recommendation: Validate owned-token quantities and uniqueness across the complete contract-address answer before accepting its tip or filtering by owner. Share that validation with objects. Test both holding orders and verify that a rejected listing leaves a live reservation intact.
  • [medium] Payout funding can select an already collected token input (julc-state-runtime/src/main/java/org/julclang/state/runtime/AssetTx.java:342)
    Hosted wallets now reach tx.collectFrom(picked), which adds the token inputs to the transaction without adding their refs to the composition’s spent-input set. When the same call pays lovelace back to the caller, TxRunner.prepareInScope selects a funding input using that set. Its largestAdaOnly helper also admits mixed-asset UTxOs. If the token input has the most lovelace, QuickTx receives it twice and counts its value twice when calculating change. The build or final balance check then rejects a funded call.
    Recommendation: Record each selected asset input through TxRunner.collect so payout funding excludes its ref. Add a hosted prepare regression where the caller receives a tagged payout and the token-bearing input is the wallet’s largest eligible UTxO.

Addressed in the author reply at d0143667.

🤖 Generated with Claude Code

https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv

@satran004

Copy link
Copy Markdown
Member Author

Verdict: CHANGES REQUESTED
Codex adversarial review, re-review (r3) · head 0609a896

Hold PR #151 at 0609a89. Static review confirms that Reads checks the complete listing before observing its tip, including for objects, and that TxRunner.collect records asset picks in the spent set used by payout funding. The uniqueness check also rejects valid fungible tokens, and two asset-selection issues remain. Tests were not rerun.

Findings:

  • [high] Valid fungible tokens can make an entire address unreadable (julc-state-host/src/main/java/org/julclang/state/host/Reads.java:196-208)
    Reads treats every 29-byte name starting with 0x4b as unique under every catalogued policy. ADR-0016 I44 reserves that prefix only for contracts with keyed types. JscV2M2FourWayTest.java:233 explicitly accepts such a mint on a non-keyed contract. A legitimate quantity of two, or one unit in each of two UTxOs, therefore makes the host reject the entire wallet or contract listing with internal/inconsistentRead.
    Recommendation: Carry each policy's hasKeyed flag into Reads and use the same policy-aware predicate in ContractDatums.recognize. Test the same 0x4b holdings under both keyed and non-keyed policies.
  • [high] A hosted asset payment can consume a published reference script (julc-state-runtime/src/main/java/org/julclang/state/runtime/AssetTx.java:317-332)
    The asset picker takes the first wallet UTxO containing a needed unit, even when that UTxO carries a reference script and a later ordinary UTxO can cover the payment. Submitting the prepared body spends the script-bearing out-ref and invalidates transactions that reference it. Per-unit balance checks still pass because they account only for value. The payout funding picker already excludes reference-script outputs.
    Recommendation: Exclude UTxOs with a reference script from automatic asset selection. Test a wallet listing with a script-bearing token input first and an ordinary token input second, and assert that the prepared body spends only the ordinary one.
  • [medium] A second composed asset payment can select the first payment's input (julc-state-runtime/src/main/java/org/julclang/state/runtime/AssetTx.java:317-320)
    Asset selection checks the claim store and the current creation seed, but never checks the composition's spent set. In a public Compose.submit with two calls paying the same token from one wallet, the second scan can pick the first call's UTxO again even when a second UTxO fully covers the payment. TxRunner.collect then throws before the selector tries the available input. The host's single-call prepare avoids this case, but the changed collector is shared with the runtime.
    Recommendation: Skip refs already in the active capture's inputs before decrementing the missing quantities. Cover two composed calls to distinct instances with two independently sufficient token UTxOs.

Addressed in the author reply at d0143667.

🤖 Generated with Claude Code

https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv

satran004 added a commit that referenced this pull request Nov 22, 2026
…host-m3-keyed

Conflicts: Session.java (keyed object keys and #151's owned-object guard, both before any read; the reference-input
check before the keyed prepare), the protocol text (both sides' rules), VerifierVectorsTest (UNCOVERED and
NEEDS_POSITIVE both kept), host-conformance.test.js (both gap lists). methods.schema.json: keyed calls keep their key
as object beside #151's owned-object rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv
…eat/dev-host-m1b

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014PGuu3MYnGqtaHSfk9b3gv

This branch has not been deployed

No deployments
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