Skip to content

showcase: Fiducia deterministic rebalance planner - #117

Open
fiduciaindex wants to merge 4 commits into
Virtual-Protocol:mainfrom
fiduciaindex:showcase-fiducia
Open

showcase: Fiducia deterministic rebalance planner#117
fiduciaindex wants to merge 4 commits into
Virtual-Protocol:mainfrom
fiduciaindex:showcase-fiducia

Conversation

@fiduciaindex

Copy link
Copy Markdown

Summary

Adds showcase/fiducia-deterministic-rebalance/. Fiducia compiles an index mandate into a hash-committed rebalance plan, so the trades an executor is permitted to make are fixed before it reaches a router.

Proof

PROOF.md has the commands and the recorded output. The planner is pure computation: no RPC, no keys, no clock, no network. Same input, same hash, any machine.

git clone https://github.com/fiduciaindex/fiducia.git
cd fiducia/packages/mandate
pnpm install --ignore-workspace
node --experimental-strip-types --test test/*.test.ts        # 46 pass
node --experimental-strip-types examples/deterministic-plan.ts

Expected on any machine:

mandateHash 0xe3420dccd9f0f958d51e2b2e1ae6d3a6fac1baffe12dc23e9a7a213e2d5125dd
planHash 0x07061e2f22ea83cca89468e9eba86c26300e92896a0e1ce69a8d30187df3e30e
determinism 100 rebuilds produce an identical planHash
tamper halving minAmountOut yields 0x76c1fff7…; swapping router calldata yields 0xfbccc8be…

If those hashes do not reproduce, the determinism claim is false and this should be rejected.

Why the hash is the point

An agent that plans its own trades can quietly widen its own limits. The plan is hashed before execution and checked at settlement, so discretion is bounded by arithmetic instead of trust. minAmountOut and the router calldata are inside the hash preimage, not passed alongside it, so neither can be altered without changing planHash. The preimage is an ABI encoding of (bool, bytes32, uint256, uint256, address, bytes)[] matching the Solidity side, and test/planner.test.ts asserts it against an independent restatement of that tuple rather than against the implementation's own helper.

A real bug the tests found

The weight solver carried a comment claiming its invariants were "property-tested". No tests existed. Writing them showed waterFill returned allocations summing to 13000 bps — 130% whenever a cap and a floor bound at once: cap 0.9 / floor 0.1 over five assets produced 0.9 + 4x0.1 instead of the feasible 0.6 + 4x0.1. It clamped in both directions in one pass and never revisited a pinned name, so a cap-pinned name could leave less mass than the remaining floors needed. Reformulated as floor-plus-excess and verified over 4000 randomised feasible cases with zero invariant violations. In production it would have misallocated capital.

Scope — stated so the proof is not read as more than it is

  • Runs: the deterministic core — canonicalisation, hashing, weight solving, planning, plan hashing, guardrails. 46 tests.
  • Live: the $FIDUCIA agent token on Virtuals (#139254) and https://fiduciaindex.com
  • Written, not deployed: the Solidity contracts. No Foundry tests, no deployment, no audit.
  • Not implemented: the ACP adapter. No ACP job has been created or settled, which is why primitives lists token only and no ACP claim appears anywhere in the manifest. The agent processes in the repo do not run without that adapter. No token utility is implemented — the planner denominates in USDG, not $FIDUCIA.

The repo README carries the same per-component status table.

Checklist

  • Folder name equals slug; kebab-case; unique
  • node scripts/validate-showcase.mjsValidated 60 showcase project manifest(s).
  • Exactly three feedbackPrompts; seven artifacts
  • All 13 manifest URLs return 200; posterUrl serves image/png
  • Poster is 1600x900 (16:9), generated from a real demo run, not mocked up
  • No credentials, keys, or wallet material in the package
  • Diff adds only files under showcase/fiducia-deterministic-rebalance/

visual.posterUrl and the PROOF.md artifact point at the post-merge upstream main path, so they 404 until this merges. Both files are reachable on the PR branch for review — happy to switch them to branch URLs if you prefer to see them resolve pre-merge.

No video. Poster renders as a static card image per the Card Image rules.

Adds a showcase package for a planner that compiles an index mandate into a
hash-committed rebalance plan. The proof is a pure-computation demo: no RPC,
no keys, no clock, so the mandateHash and planHash in PROOF.md reproduce
byte-for-byte from a clean clone.

primitives lists token only. The ACP adapter is not implemented and no ACP job
has been created or settled, so no ACP claim is made. PROOF.md and the package
README both state which components run, which are written but undeployed, and
which do not exist.
Fork branches are transient. A card referencing raw.../fiduciaindex/
acp-cli-demos/showcase-fiducia/... breaks the moment the branch is deleted
after merge, so both URLs now target the post-merge upstream path. The same
files are reachable on the PR branch for pre-merge review.
"description": "Fiducia plans rebalances for tokenised-equity index vaults. A mandate is canonicalised to bytes and hashed, target weights are solved in integer basis points, and the resulting leg sequence is hashed into a single planHash that an executor can be checked against — an agent cannot widen slippage, resize a leg, or swap the calldata without changing the hash. The core is pure computation with no RPC or keys, so anyone can clone the repo and reproduce the same mandateHash and planHash byte-for-byte. Writing the test suite found a real bug: the weight solver returned allocations summing to 130% when a cap and a floor bound at once, which is fixed and now covered by 46 passing tests plus a 4000-case randomised sweep.",
"status": "deterministic core running, contracts not deployed",
"topic": "agents",
"topics": ["rwa", "index", "determinism", "risk", "tokenised-equities"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The showcase guide has a short list of allowed topics (agents, skills, commerce, security) to keep the site's filtering consistent. security and commerce seem like the best fit for the great work you're showing here!

Suggested change
"topics": ["rwa", "index", "determinism", "risk", "tokenised-equities"],
"topics": ["security", "commerce", "agents"],

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

This is a really sharp submission — the technical detail in PROOF.md and the upfront honesty about what is and isn't built yet are both great.

The core question for us is one of scope: the showcase is focused on agents doing actual commerce, and this is a component for an agent that isn't at the commerce stage yet. It's a bit of a gray area, so we'll need a maintainer to make the final call on whether it's a fit.

One small thing that is a clear fix: I left a suggestion inline to trim the topics list to the standard set from the contributor guide.

Suggested edits (couldn't be anchored inline — copy manually)

showcase/fiducia-deterministic-rebalance/showcase.json (around line 8)
Let's trim this to the topics in the contributor guide. agents and security are great fits, and commerce seems appropriate for the problem domain.

  "topics": ["agents", "security", "commerce"],

Refreshed after a new push. Any inline suggestions from the first pass may now be stale.

Adds agents, security, robinhood-chain and tokenized-stocks to topics so the
card surfaces under the filters reviewers pointed at, keeping the descriptive
tags alongside them.

Not restricting topics to the four primary buckets: 56 of 60 manifests use
values outside that set, the most common tags being acp, base, robinhood-chain
and tokenized-stocks, and showcase/README.md documents topics as the free-form
search tags with topic as the single primary bucket. topic here stays agents.
@fiduciaindex

Copy link
Copy Markdown
Author

Thanks for the read. Pushed e114ae0 picking up the filtering intent:

"topics": ["agents", "security", "robinhood-chain", "tokenized-stocks", "rwa", "determinism", "risk"]

I kept the descriptive tags rather than narrowing to the four buckets, because the four-value list is the constraint on topic, not topics. Counting the manifests on main:

  • 56 of 60 have topics values outside {agents, skills, commerce, security}
  • the most-used tags are acp (19), agents (15), commerce (15), base (13), security (12), robinhood-chain (11)
  • showcase/README.md describes topics as "the free-form tags used for search" and topic as "the one primary bucket"

So security and robinhood-chain are in now, and topic stays agents. Happy to trim further if you'd rather these cards carry fewer tags.

On links.share: fair point, and I'd rather not fake it. There is no announcement post for this work yet, so the profile is the honest destination. I'll swap it for the specific post once it exists — before merge if that's preferred.

One thing worth flagging since it affects how the proof reads: visual.posterUrl and the PROOF.md artifact deliberately point at the post-merge upstream main path, so both 404 until this merges. They resolve on the PR branch:

Re-verified just now on the current branch: validator passes across all 60 manifests, the suite is 46/46, and two consecutive demo runs are byte-identical at 2525 bytes, still producing planHash 0x07061e2f…3e30e.

Replaces the profile URL with the specific post, as the contributor guide asks.
@fiduciaindex

Copy link
Copy Markdown
Author

The share nit is resolved in 35f7a93 — there's an announcement post now, so it points at that rather than the profile:

https://x.com/fiduciaindex/status/2096257736510160916

Both review points are addressed. Validator still passes across all 60 manifests.

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