Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
94f27ff
core: reproducer tests pinning the v1.0.0 verification findings
gabehamilton Nov 12, 2026
75d7cda
docs: verification findings for v1.0.0
gabehamilton Nov 12, 2026
a2a7dd8
docs: qualify trace 207 and attribute cross-layer evidence
gabehamilton Nov 12, 2026
4e55036
docs: scope F-1's 'forever' to the trace-0 configuration; full v1.0.0…
gabehamilton Nov 12, 2026
effd174
build: --cfg near, panic_utf8 import check, sandbox fail asserts the …
gabehamilton Nov 12, 2026
59e404f
core: resolution envelope with assert_live and a random LIVE test (F-…
gabehamilton Nov 12, 2026
dc774f8
core: actor must differ from executor (F-4)
gabehamilton Nov 12, 2026
3eaf1cb
core: snapshot refresh with records open (F-6)
gabehamilton Nov 12, 2026
da43188
core: version reserve below u32::MAX (F-5)
gabehamilton Nov 12, 2026
138ef98
core: cancel of Completed is InvalidState; docs for the ack no-op (di…
gabehamilton Nov 12, 2026
1d441c5
contract: reconcile rejects deposits; on_result reads the raw result …
gabehamilton Nov 12, 2026
3598902
contract, executor: low-level promises; build fails on non-function-c…
gabehamilton Nov 12, 2026
1f01d43
core, contract, executor, demo: sliding window of the 256 most recent…
gabehamilton Nov 12, 2026
e47f1e5
scenarios, docs: regenerate traces; gas table measured on the v1.1 wa…
gabehamilton Nov 12, 2026
34ec9d4
release: version 1.1.0, CHANGELOG, findings status, README (F-1 to F-…
gabehamilton Nov 12, 2026
762ffa4
merge: origin/main 58e925a (live site, PR #5) into v1.1
gabehamilton Nov 12, 2026
2a1506c
fix(build): import allowlist beside the action denylist (NT-F3)
gabehamilton Nov 12, 2026
d9f6605
test(sandbox): non-string executor results on the real host (NT-F4)
gabehamilton Nov 12, 2026
1dfba39
fix(docs): state the window's head-of-line cost (F-3, F-1)
gabehamilton Nov 12, 2026
101d8f5
fix(ui): site text for v1.1.0 (F-1, F-2, F-3)
gabehamilton Nov 12, 2026
cf1f94f
fix(docs): evidence scope, event format version, read-method deposits…
gabehamilton Nov 12, 2026
ffed738
test(sandbox): RES-1 gas test in the repository; executor at 512 jobs…
gabehamilton Nov 12, 2026
0941116
fix(docs): when the executor's job cap clears, and when it cannot (F-3)
gabehamilton Nov 12, 2026
9cb7146
fix(docs): SECURITY.md says records are pruned and ids never reused (…
gabehamilton Nov 12, 2026
80e7eac
fix(docs): the executor's job cap in the handoff, CHANGELOG and READM…
gabehamilton Nov 12, 2026
f4909fb
fix(docs): v1.1.0 changes the stored state; deploy to fresh accounts …
gabehamilton Nov 12, 2026
8161432
fix(docs): F-4 is fixed for actor = executor only (F-4)
gabehamilton Nov 12, 2026
733524d
fix(docs): the gas margin rule and the measured state, as used (gas)
gabehamilton Nov 12, 2026
4be9dab
fix(docs): wrap long lines; F-3 status names the executor's job cap (…
gabehamilton Nov 12, 2026
4d69f19
fix(executor): an accepted settle moves the newest id (D-1, F-3)
gabehamilton Nov 13, 2026
4e1a4e1
test(sandbox): confirmed failed executes keep the executor at 256 job…
gabehamilton Nov 13, 2026
b954c50
test(sandbox): RES-1 measures on_settled; finish and confirm minimums…
gabehamilton Nov 13, 2026
e583781
fix(docs): gas for finish and confirm_not_executed with on_settled (gas)
gabehamilton Nov 13, 2026
e0aad49
fix(docs): honest confirmations no longer fill the executor's job cap…
gabehamilton Nov 13, 2026
171a65f
fix(docs): owner decisions on the window, admission and owner as exec…
gabehamilton Nov 13, 2026
765465b
fix(executor): execute of a stored id moves no newest id; a valued se…
gabehamilton Nov 13, 2026
cc0e95c
fix(docs): the newest id, confirm gas at 254 jobs, Unauthorized refus…
gabehamilton Nov 13, 2026
6fcbd56
fix(docs): a too-early confirmation with a different payload leaves t…
gabehamilton Nov 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Changelog

All notable changes to this project are listed here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
[Semantic Versioning](https://semver.org/).

## [1.1.0] - 2026-11-12

This release fixes the findings of an outside verification of v1.0.0. They are
described in [docs/verification-findings.md](docs/verification-findings.md).
The formal results there (TLA+, Lean, Prolog, conformance traces) apply to
v1.0.0. v1.1.0 has not been formally re-verified. Its fixes are covered by
unit tests, seeded random tests and the sandbox suite.

### Fixed

- F-1 (high): a hedge admitted after an `observe` broke a bound could never
settle. Admission now counts every outcome of every open record, including
its release. Every open record can now be resolved: a Reserved one by
cancel, a dispatched one by its executor's report.
[F-1](docs/verification-findings.md#f-1-high-disturbed-state-hedge-wedge)
- F-2 (high): in the `risk` fixture, a position that a completed hedge relied
on could not be released. A hedge must now stay in bounds if the position is
later reported unexecuted.
[F-2](docs/verification-findings.md#f-2-high-healthy-state-release-wedge-in-the-risk-fixture)
- F-2b: a release could leave the value range and fail `Arithmetic`. The
release is now inside the admission interval.
[F-2b](docs/verification-findings.md#f-2b-a-release-can-leave-the-value-range)
- F-3 (low): one actor could use up all 256 lifetime records with free
submit-and-cancel cycles. The pool now keeps a window of the 256 most recent
records. [F-3](docs/verification-findings.md#f-3-low-lifetime-record-exhaustion)
- F-4 (low): a recipe's actor could be its own executor. `new` now rejects
such a config (`InvalidConfig`). The owner may still be a recipe's
executor; the repository owner decided to allow it.
[F-4](docs/verification-findings.md#f-4-low-a-principal-can-attest-its-own-work)
- F-5 (low): at version u32::MAX every transition failed, including
settlement. Submit, dispatch, pause and observe now stop 768 versions
earlier, so acknowledgment, settlement and cancellation always remain
available.
[F-5](docs/verification-findings.md#f-5-low-version-saturation-freezes-every-transition)
- F-6 (low): one long-open record blocked the snapshot refresh. The owner can
now restate the current values at any time.
[F-6](docs/verification-findings.md#f-6-low-an-open-record-blocks-the-only-snapshot-refresh)
- NT-F1 (medium, diagnostics): the documented build dropped every panic
message. `scripts/build.sh` now sets `--cfg near` and fails if a Wasm does
not import `env.panic_utf8`.
[NT-F1](docs/verification-findings.md#nt-f1-medium-diagnostics-not-safety-the-documented-build-drops-every-panic-message)
- NT-F2 (low): `reconcile` kept an attached deposit. It now rejects any
deposit. [NT-F2](docs/verification-findings.md#nt-f2-low-reconcile-keeps-an-attached-deposit)
- NT-F4 (low): a promise result that was not a JSON string made the callback
panic. `on_result` now reads the raw result; anything but one JSON string of
at most 64 bytes becomes Unknown.
[NT-F4](docs/verification-findings.md#nt-f4-low-a-non-string-promise-result-does-not-become-unknown)

### Changed

- Stricter admission. Two kinds of request that v1.0.0 admitted are refused:
a reservation that by itself reduces a violated metric (recovery must come
from completion), and a request that is in bounds only while another open
record's reservation stays in place. In the `risk` fixture, with one credit
position open, the largest admitted selloff hedge is 6 units, not 8.
Confirmed by the repository owner.
- Record window. The pool keeps the 256 most recent commitments. A submit
prunes the oldest one when it is completed or cancelled, and fails `Full`
while it is open. A dispatched oldest record closes only when its executor
reports, so a silent executor can hold submit at `Full`. Ids keep
counting, and a pruned id is `NotFound` (including a repeated executor
`settle`, which v1.0.0 accepted). `get_pool` gains `first_id` and
`completed_units`; prerequisites count completed units over the pool's
life. `get_commitments` takes `from` as an id. Confirmed by the
repository owner.
- `cancel` of a Completed record fails `InvalidState` (was `Pending`).
Dispatched, Active and Unknown records still fail `Pending`.
- Version reserve: submit, dispatch, `set_paused` and `observe` fail
`Arithmetic` from `VERSION_CAP` (u32::MAX - 768). `preview` reports it too.
- Executor retention. The synthetic executor forgets a job once the newest
id the lock has vouched for is 256 or more past its id. That newest id is
the largest one for which the lock's `execute` created a job, or whose
`settle` (from `finish` or `confirm_not_executed`) the lock accepted,
recorded by a new private callback `on_settled`; both methods still
return the lock's result. An `execute` of an id that already has a job
moves nothing.
Forgotten id: `execute` returns `"cancelled"`, `confirm_not_executed`
fails `stale id`, `finish` fails `unknown job`. At most 256 jobs have ids
at or below the newest id, so honest use holds 256 jobs plus
confirmations in flight. The cap is 512 (v1.0.0: 256 over the executor's
life). It is reached only with at least 256 jobs above the newest id
(more if fewer sit at or below it): confirmations the lock refused, which
keep their jobs (a typo of a far id for good), or confirmations whose
callback has not run. At the cap `confirm_not_executed` fails `full`, and
if executes keep failing the lock can stay at `Full`
([docs/api.md](docs/api.md#executor-protocol)).
- Wasm import surface (NT-F3). Both contracts create promises with
`promise_create`, `promise_then` and `promise_return` instead of near-sdk's
`Promise`. The 15 host imports for accounts, deploys, keys, transfers and
staking are gone, and `scripts/build.sh` fails if one comes back. It also
fails on any import that is not on its list of the current 18 contract and
16 executor imports (the executor's `on_settled` reads the lock's `settle`
result). `dispatch`, `reconcile`, `finish` and `confirm_not_executed`
return `()` in Rust; on chain the result is still that of the promise each
returns: `on_result` for `dispatch` and `reconcile`, the lock's `settle`
for `finish` and `confirm_not_executed`.
- Build: `scripts/build.sh` sets `RUSTFLAGS="--cfg near"`, and
`artifacts/build.json` records the flags and each Wasm's imports.
- `on_result` logs a result for an id with no record (`error: "NotFound"`)
instead of panicking.
- Stored state. The lock's pool gains `first_id` and `completed_units`, and
the executor gains `newest`. A v1.0.0 deployment cannot be upgraded in
place: its state would not load. Deploy v1.1.0 to fresh accounts; no
migration is provided.

### Docs

- An acknowledgment that does not change the status is `Ok` without a
version change. The docs now say so (the code already did).
- [docs/api.md](docs/api.md) describes the events. Their format version
stays `1.0.0`: no event shape changed. It also says that the read methods
keep a deposit sent with a transaction.
- [docs/api.md](docs/api.md) has a gas table, measured on the v1.1.0 Wasm at
a maximum-size state by `crates/sandbox/tests/res1.rs` (ignored by
default; run it with `--ignored`). Executor `finish` and
`confirm_not_executed` need 70 Tgas (least measured 55; 56 for `finish`
with 512 jobs).
- [docs/verification-findings.md](docs/verification-findings.md) gives each
finding's status.

## [1.0.0] - 2026-11-12

First release (commit `80fb89e`, not tagged): the pool core, the NEAR
contract, the synthetic executor, six scenarios, the local demo and static
UIs, and the sandbox integration tests. It is the baseline the outside
verification checked: its core, contract and executor are byte-identical to
commit `a4bb5c3`.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default-members = ["crates/core", "crates/contract", "crates/executor", "crates/
resolver = "2"

[workspace.package]
version = "1.0.0"
version = "1.1.0"
edition = "2021"
license = "MIT"
repository = "https://github.com/difflabai/shared-pool-controls"
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

Agents submit an owner-defined recipe and exact integer quantity. The core checks caller authority, freshness, prerequisites, resource bounds and `V(after) <= V(before)`, then atomically reserves the commitment. The execution adapter accepts calls only from the lock. Unknown outcomes retain reservations.

**Status:** implemented prototype with Rust tests and NEAR sandbox integration tests. Not independently audited or deployed to a public network. [Formal verification](https://github.com/difflabai/formalver/pull/31) includes completed Lean model proofs and TLA+ checks; the overall effort is in progress, with Rust-core Kani verification pending and reported settlement/liveness findings unresolved in that PR. Credits, GPU jobs, physical delivery, and financial positions are synthetic. The risk coefficients are illustrative, not a production portfolio model.
**Status:** implemented prototype with Rust tests and NEAR sandbox integration tests. Not independently audited or deployed to a public network. This is v1.1.0. [Formal verification](https://github.com/difflabai/formalver/pull/31) of v1.0.0 includes completed Lean model proofs and TLA+ checks; Rust-core Kani verification is pending. v1.1.0 fixes the settlement/liveness and other findings that verification reported ([findings](docs/verification-findings.md), [changelog](CHANGELOG.md)). The fixes are tested but not formally re-verified. Credits, GPU jobs, physical delivery, and financial positions are synthetic. The risk coefficients are illustrative, not a production portfolio model.

## Hackathon review path

Expand Down Expand Up @@ -60,7 +60,7 @@ The separate [`ui/live.html`](ui/live.html) is a static NEAR console: read any c
python3 scripts/smoke.py # local HTTP demo; start server first
```

`near-workspaces` downloads its sandbox binary on first use. Network access and a supported host are required. `artifacts/build.json` records source revision, dirty status, Rust version, Cargo.lock hash, and Wasm hashes. This is a local build manifest, not an independent reproducibility or deployment attestation.
`near-workspaces` downloads its sandbox binary on first use. Network access and a supported host are required. `build.sh` builds with `RUSTFLAGS="--cfg near"` and fails if a Wasm does not import `env.panic_utf8` (without the flag, failed calls carry no error name). It also fails if a Wasm imports a host function for an action other than a function call (deploy, keys, transfer, stake, accounts), or any import not on its reviewed list. `artifacts/build.json` records source revision, dirty status, Rust version, Rust flags, Cargo.lock hash, and each Wasm's hash and imports. This is a local build manifest, not an independent reproducibility or deployment attestation.

## Small architecture

Expand All @@ -74,18 +74,19 @@ python3 scripts/smoke.py # local HTTP demo; start server first
| [`ui`](ui) | Static scenario lab and live NEAR console |
| [`scenarios`](scenarios) | Generated configurations and reproducible decision traces |

One pool per deployment; immutable recipes, principals and policy. At most 32 metrics, 32 recipes, 64 potential terms and 256 lifetime commitments. Fixed limits bound computation and storage. The 257th commitment is rejected; rotate to a new deployment rather than pruning replay protection. The owner funds storage. This favors inspection and verification over indefinite production operation.
One pool per deployment; immutable recipes, principals and policy. At most 32 metrics, 32 recipes and 64 potential terms. The pool keeps a window of the 256 most recent commitments. A new commitment prunes the oldest one if it is completed or cancelled; while the oldest is still open, submit fails `Full`, even if every other commitment has ended. The actor or owner can cancel the oldest while it is reserved; once dispatched, it closes only when its executor reports. So an executor that never reports can hold submit at `Full`. The synthetic executor forgets a job once the newest id the lock vouched for (by an `execute` that created a job, or by accepting a confirmation or `finish`) is 256 or more past its id; the lock has pruned that record by then. Honest use holds at most 256 jobs plus confirmations in flight, under a cap of 512. Confirmations the lock refuses (operator errors) keep their jobs, a typo of a far id for good; at least 256 of them above its newest id (more if fewer jobs sit at or below it) fill the cap and stop further confirmations, and if executions then keep failing that can hold submit at `Full` the same way ([API](docs/api.md#executor-protocol)). Ids keep counting, and a pruned id is `NotFound`; the event log keeps pruned records. Replay protection is the version, not retention. Prerequisites count completed units over the pool's whole life. Fixed limits bound computation and storage. The owner funds storage. The window replaces v1.0.0's 256 lifetime commitments (finding F-3); it is tested, not formally verified.

Read the [API](docs/api.md), [state-machine specification](docs/spec.md), [updated implementation plan](docs/implementation-plan.md), and [verification handoff](docs/verification-handoff.md).
Read the [API](docs/api.md), [state-machine specification](docs/spec.md), [updated implementation plan](docs/implementation-plan.md), [verification handoff](docs/verification-handoff.md), [verification findings](docs/verification-findings.md), and [changelog](CHANGELOG.md).

## Important boundaries

- Hard bounds and the potential are different checks. A lower score cannot buy permission to breach a protected limit.
- Pending commitments count immediately. Pending negative-risk hedge effects do not provide headroom before fill.
- No unexecuted position backs a hedge: a hedge must stay in bounds if the position is later reported unexecuted.
- Cancellation after dispatch needs authenticated evidence of nonexecution. A timeout or failed receipt is insufficient.
- The administrator and registered execution/evidence accounts are trusted. The owner can update observed facts only when there are no unresolved commitments; it cannot edit policy. That observation can raise energy or reveal a limit breach.
- The administrator and registered execution/evidence accounts are trusted. The owner can update observed facts only when there are no unresolved commitments, and can restate the current values at any time to renew the snapshot; it cannot edit policy. That observation can raise energy or reveal a limit breach.
- Only admitted reservation transitions promise nonincreasing energy. Settlement, cancellation, observations, fairness, economic correctness and eventual completion have separate assumptions.
- The adapter boundary is real in the sandbox. Real brokers, cloud providers or warehouses would need enforceable integrations with no alternate credentials/path around the gate.
- The prototype uses no real escrow token. Hiring credits are accounting fixtures, not NEAR balances.

The architecture follows [`difflabai/trust-framework`](https://github.com/difflabai/trust-framework/tree/249f932d84b91fbc6f82abd0668cac6c0503fc42/contracts/approval): a pure core and thin wrapper. Its proofs do **not** apply to this code. Dedicated [shared-pool formal verification](https://github.com/difflabai/formalver/pull/31) targets the contract source pinned at `a4bb5c3`: Lean proofs cover the model transcription, TLA+ checks a bounded model, and conformance traces connect the models to the Rust core. Kani verification and refinement work remain pending. The PR reports high-severity settlement/liveness findings F-1 and F-2; consult its current status and findings before deploying. Changes to the contract or policy require review against the proof assumptions.
The architecture follows [`difflabai/trust-framework`](https://github.com/difflabai/trust-framework/tree/249f932d84b91fbc6f82abd0668cac6c0503fc42/contracts/approval): a pure core and thin wrapper. Its proofs do **not** apply to this code. Dedicated [shared-pool formal verification](https://github.com/difflabai/formalver/pull/31) targets v1.0.0, with the contract source pinned at `a4bb5c3`: Lean proofs cover the model transcription, TLA+ checks a bounded model, and conformance traces connect the models to the Rust core. Kani verification and refinement work remain pending. It reported high-severity settlement/liveness findings F-1 and F-2 (with F-2b), and lower-severity findings F-3 to F-6 and NT-F1 to NT-F4. v1.1.0 fixes all of them, F-4 only for a recipe whose actor is its executor (by the repository owner's decision, the owner may be a recipe's executor); see [docs/verification-findings.md](docs/verification-findings.md). Those formal results apply to v1.0.0. v1.1.0 changes admission, record retention and the version limit, and has not been re-verified. Changes to the contract or policy require review against the proof assumptions.
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is an unaudited, not-formally-verified prototype. Do not treat synthetic cr

Trust assumptions: immutable configuration is honestly designed; registered executor/operator truthfully reports execution; the owner truthfully reports observed values; NEAR runtime/SDK behavior is correct; the deployment account's upgrade authority is controlled. The lock cannot stop external actions using bypass credentials.

Attack surfaces intentionally limited: no agent-provided deltas, no arbitrary external method or account, no dynamic policy code, no unbounded logs in state, no frontend keys, no automatic timeout releases. Limits are fixed and terminal records retained to preserve ID replay protection.
Attack surfaces intentionally limited: no agent-provided deltas, no arbitrary external method or account, no dynamic policy code, no unbounded logs in state, no frontend keys, no automatic timeout releases. Limits are fixed. The pool keeps its 256 most recent records and prunes the oldest only once it is completed or cancelled. Ids keep counting, so a pruned id is never reused. Replay protection comes from the request's version, not from retaining records.

The local Rust server is a **simulator**: identities are selectable and independent-provider evidence is a button. It binds to 127.0.0.1, validates Host/Origin, requires JSON POST for API access, uses an allowlist for static files and caps requests. Do not reverse-proxy it publicly or use it as an authenticated production gateway.

Expand Down
Loading
Loading