How do you prove your app didn't do something?

Not what it did.
Logs cover that. What it tried and was stopped from doing.

I hit this building a spend-limited agent wallet. The refusals turned out to
matter more than the payments, and I could not find a good way to hand
someone proof that a refusal actually happened.

What I ended up with: every attempt, allowed or refused, becomes one
hash-chained receipt saying what was tried and which rule decided it.

The limits are assertMsg fences in the Daml, so the refusal is the ledger’s, not
my app saying so about itself. You can check a chain here with nothing
installed: Check a payment record | KYA Rails

But I might be solving something nobody else has.

Has anyone ever asked you to prove your app didn’t do something?
What did you show them?

Hey @orumedominic , Is my understanding correct that the hash-chained receipts are produced by the application based on the response it gets from the participant/validator?

If so, one limitation is that you are still trusting the application to create the receipts and include every attempt. The hash chain makes existing receipts tamper-evident, but it doesn’t prove that a receipt wasn’t omitted or that its contents accurately represent the participant’s response.

An alternative worth considering would be to make the refusal itself a valid Canton transaction. For example, wrap the operation in a choice that checks the policy and either performs the action or creates a RejectedAttempt audit record. The transaction commits in both cases, but the underlying action only happens when allowed.

That would make the refusal part of the Canton ledger rather than evidence produced by the application. The trade-off is that rejection becomes explicitly modeled in Daml rather than using a failed transaction.

Yes, that is right. And the omission gap was the real problem.

I built what you described.

A choice called TryCharge checks the policy. If it passes, it pays. If it
fails, it creates a ChargeRefused contract and pays nothing. Both paths
commit. That is your RejectedAttempt under another name.

You called the trade-off right too. Rejection is modelled in Daml now.
That cost a second copy of the rules. They drifted once. I changed one
comparison. Every test stayed green. The two paths then disagreed about a
charge landing exactly on the cap. There is a test for that now.

Your caveat still stands. An attempt nobody submits still leaves
nothing. This only fixes refusals that reached the ledger.

That was better review than most code gets. Thank you.

Federico, an update, since your point was the one that mattered.

You said a chain of receipts written by my app cannot prove I left one out.
Right, and no hash fixes it, because I choose what to hash.

So I stopped hashing and started counting.

One contract per owner and actor. Every attempt consumes it and puts it back
with the count up by one. The auditor observes that contract, so they read the
count off the ledger instead of off what I hand them.

Fifty attempts, refusals at 3, 7 and 19. I show them two records. They know one
is missing and which position it was.

The work and the count commit in the same transaction, so skipping the count
means skipping the work. That is the part you described, reached from the other
side.

Two things I could not do. Daml 3 removed contract keys, so I cannot stop
someone opening a second journal. The auditor sees both, which is detection and
not prevention. And nothing forces an app to use the journal at all.

Still no credential, so all of it is Daml Script until it runs on DevNet.

Thank you for the review.

On the two gaps in your last post. Second journal: if the auditor is a signatory on the journal, not only an observer, nobody can create another one without the auditor’s authority, since a create needs every signatory. That moves it from detection to prevention without contract keys. Nothing forcing the app to use it: put the counter on the mandate itself. If TryCharge is a consuming choice on the contract that holds the spend authority and recreates it with count + 1, there is no way to pay that skips the count. The cost is contention, every attempt for one owner and actor serialises on that one contract.

Both built.

Auditor on the signatory line: the second journal is now impossible. Free at
runtime, since a choice that recreates the journal already carries its
signatories’ authority.

Contention: Sharded it. The test holds the original contract ID and uses it
twice. One journal refuses the second.
Two shards allow both.

All four properties survive.
The new failure mode is a hidden shard, so the set declares how many.

What would you break next?

PREDGE, I marked your reply as the solution. It was the fix and the thread should say so.

I read the receipt spec properly this week.

One thing you may want in section 2. RFC 8785 orders keys by UTF-16 code units. Python’s json.dumps(sort_keys=True, separators=(",", ":")) orders by code point and escapes non-ASCII by default. They disagree:

python : U+FF3A then U+1F600
JCS    : U+1F600 then U+FF3A
python : {"x402.resource":"https://a/\u00e9"}
JCS    : {"x402.resource":"https://a/é"}

Your v1 keys are all ASCII so the ordering is safe today. But issuer.id and x402.resource are values, and an internationalised origin or a path with an accent will change the canonical bytes. One sentence saying “JCS is not Python’s sorted-keys dump” would save the first Python implementer a day.

Two questions, if you have the time.

What went wrong that made you add the dispute window? A receipt that is provisional until a window closes is a different object, and nobody else on Canton is doing it.

And you have sandbox runs in docs/runs. I have never stood one up. Was it worth what it cost you?

You offered a walkthrough on #925. I would take it.

Federico, PREDGE, this went somewhere, and you should both see it.

It is now a CIP draft, and the two of you are in it by name.

Federico, your 11 September reply is the reason it exists. You said a hash chain over receipts cannot prove an omission, however well it is chained, and that a refusal should be a committed Canton transaction instead. I was defending the chain at the time. You were right, and I was not. That argument is the motivation section now.

PREDGE, your 21 October reply is what makes it hold. The auditor is on the signatory line, not the observer line, so a second journal cannot be created rather than merely spotted. I built it, and the test is called testASecondJournalIsPrevented. The boundary you implied is there too, as testWithNoAuditorASecondJournalIsStillPossible, because without an auditor it really does degrade to detection, and the draft says so.

Draft:

One thing I found while writing it up that neither of us knew. Dev Fund proposal #866, OS Ledger, independently arrived at the same auditor-co-signatory mechanism for its period attestations. Two proposals reaching it without talking to each other is the best evidence it is the right shape.

Both packages are published and rebuild byte for byte from source. 165 scripts pass. Nothing has run on DevNet, I hold no credential, and the draft says that too.

If either of you thinks this is wrong, I would rather hear it now than after it goes to CIP-discuss.

Daml runs more than once. The submitting participant interprets the full transaction. Each confirming participant then re-interprets the views it hosts (the model-conformance check) and sends a local verdict to the mediator.

If the submitter’s interpretation fails (a failed assert, fetch or exercise), the transaction never reaches confirmation, and the submitter gets the error from the Ledger API.

The confirmation step protects a stakeholder automatically. If its participant hosts the party with confirmation permission and finds a view that does not conform, the participant rejects it, and the mediator rejects the transaction. Nothing is committed. A non-submitting stakeholder gets no Ledger API event for this. Its participant only logs the rejection. Canton has two kinds of reject codes (canton/community/base/src/main/scala/com/digitalasset/canton/protocol/LocalRejectError.scala:26-41):

  • LocalRejectErrorCode: usually not hostile. Examples: LOCAL_VERDICT_LOCKED_CONTRACTS, LOCAL_VERDICT_INACTIVE_CONTRACTS, LOCAL_VERDICT_LEDGER_TIME_OUT_OF_BOUND, LOCAL_VERDICT_TIMEOUT.
  • MalformedErrorCode (an AlarmErrorCode, logged as a security alert): hostile or faulty. Examples: LOCAL_VERDICT_MALFORMED_REQUEST, LOCAL_VERDICT_MALFORMED_PAYLOAD, LOCAL_VERDICT_FAILED_MODEL_CONFORMANCE_CHECK, LOCAL_VERDICT_BAD_ROOT_HASH_MESSAGES, LOCAL_VERDICT_CREATES_EXISTING_CONTRACTS, LOCAL_VERDICT_ACTIVATES_EXISTING_CONTRACTS. An honest submitter cannot cause these, because its own interpretation would fail first. They point to a modified node or a tampered external-party transaction.

To detect such attempts, alert on these codes in the participant logs. If an application needs this data through an API, that is a reasonable request: discuss the use case, and consider a CIP to expose it.

The mediator also stores the verdicts, with the views blinded (no payloads). Splice Scan reads the mediator’s verdict stream and publishes accepted and rejected verdicts on /v0/events, with the submitting participant, the parties and the confirmers, but without the reject reason.

The use case, and your first three paragraphs move where it sits.

An agent holds a spending mandate. Its principal has to answer one question to
an auditor: did it ever try to exceed it?

That refusal is an assertion in our own choice body, so it is your second
paragraph and not your third. It fails in the submitter’s interpretation. No
messages are sent, no view is non-conforming, no mediator verdict exists and
Scan has nothing to publish.

The only record is at the submitting participant,
which is the actor. Your log-alerting advice covers the confirmation-stage
class, and I had been treating the two as one thing.

So the API you offered to consider would not reach this one. The information
never leaves the submitter.

That is an argument against how I framed it and,
I think, for making the refusal a successful transaction instead, so that it
goes through confirmation like any other and is simply visible.

Thus this question. Is there a protocol-level way for a refusal decided in the
submitter’s interpretation to leave an artefact beyond that participant, or is
turning it into an accepted transaction the only route?