in reviewhumanPR #321Identity

FlexGrid: every node an agent, 8 days against their rules control, with a replayed-id failure case

FlexGrid is a demand-flexibility market for a community of homes and buildings. Seller nodes offer load cuts, a coordinator pools them into one sale, two stand-in buyers order and settle on signed meter readings, and every message is a…

Author

Status
In review
Opened on
Nov 8
Branch
integration/flexgrid-all-agents

Description

The pitch.

## Summary

FlexGrid is a demand-flexibility market for a community of homes and buildings. Seller nodes offer load cuts, a coordinator pools them into one sale, two stand-in buyers order and settle on signed meter readings, and every message is a signed Beckn envelope over Town's HTTP mailbox.

This PR adds `examples/flexgrid/` (a process adapter, `run_check.py`, `stand_in_model.py` and recorded evidence), `tests/test_flexgrid_integration.py`, and a root `.gitattributes` that keeps the evidence byte for byte. It plays whole market days on runs from current `main`, 15 participants joined through Run Grants, from order with deposit to payment. All 8 homes and all 3 buildings are agents: a model decides each one's offer, its answer to the contract, its plan when the sale opens and whenever anything changes, and how it reads its owner's notes, with code's rules as one input it may take, change or drop. 8 days, 1 normal and 7 unusual, are each played twice, every node an agent and every node on rules, so what the agents changed can be read against a control. The clock waits for the agents: every service's clock holds at each step until every agent has answered. That is a test and demo device: a real evening doesn't wait.

All 17 cases came out as expected. Every node an agent, every day closed on Town: each offer on Town's record is the amount on its agent's receipt, every answer below the rule's amount carries a reason logged for its person, and no answer fell back to a rule. With every node on rules, 7 of the 8 days on Town are the offline day to the cent. Against that control the agents measured 0.6% to 2.9% more on 4 days, 3.4% less on the snow day and on the day with a building event, and 6.6% less on the day people's notes asked them to hold back; the network failure day is the normal day again. The failure case: on the code of 6 Nov a second play of the day is refused by Town 43 times and all 11 sellers go unpaid; on the current code both plays settled, and in this recording the second was the first again, to the cent.

## Integration

- **Where the project runs**: in its team's folder of a public course repository, https://github.com/rbynwang/MAS.665_AI-Studio_ENGIE-Teams/tree/main/teams/robyn-community-coordination/code, which `FLEXGRID_HOME` points at, as separate processes: the coordinator, two buyers, the homes, the buildings. No FlexGrid code is in this PR. `run_check.py` works on a staged copy, with its own config folder, ports and `NANDATOWN_HOME`.
- **How Town connects**: FlexGrid's own `TownSession` and inbox loops speak the Track contract: join, messages, inbox notify, claim, ack. Every market message of the day is a Town message of kind `beckn.*`. Control traffic goes around Town: starting the clock, each step's hold and release (the coordinator polls each node service's `/agents` and posts `/demo/clock`), naming the steps the check posts at, entering each buyer's order, posting the day's events through each service's what-if door, and reading status. On a later play `run_check.py` sends `/demo/start` twice, because the waiting clock keeps stepping after a play ends and a step landing during the start would put clocks back; that second call came after the recording. The model is called by each node process directly.
- **What the adapter adds**: a join through a Run Grant, since FlexGrid knows only tokens; an answer to `quote_request`; and a reader for each node's decision log: the model's answers, each decision's receipt, what each person was told, and each guard verdict.
- **Town's own evidence**: `run_town` starts one buyer and one seller, so a market day can't be a stock profile. `run_check.py` drives the same pieces: the coordinator, `POST /runs` with a `TestProfile` naming all 15, then `evaluate`, `write_bundle`, `attest_bundle`. `verify`, `report`, `receipt`, `verify-receipt`, `proof` and `visualize` all work on the bundle. Each day closes with one quote that Town's stock buyer asks FlexGrid's coordinator.

…

Try it

Open PR on GitHubView diff

Checkout locally

git fetch origin pull/321/head:pr-321
git checkout pr-321