diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d0aab7..767f56e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,9 @@ All notable changes to this project are listed here. The format follows 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. +v1.0.0. The v1.1.0 fixes are covered by unit tests, seeded random tests, the +sandbox suite and the [v1.1.0 verification](https://github.com/difflabai/formalver/pull/32) +(source revision `57b3f02`). ### Fixed diff --git a/README.md b/README.md index e74d42b..8946608 100644 --- a/README.md +++ b/README.md @@ -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. 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. +**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/32) of v1.1.0 (source revision `57b3f02`) covers Lean model proofs, TLA+ checks, Kani on the Rust core, and conformance traces. Verification found settlement/liveness and other findings in v1.0.0; v1.1.0 fixes them ([findings](docs/verification-findings.md), [changelog](CHANGELOG.md)). Credits, GPU jobs, physical delivery, and financial positions are synthetic. The risk coefficients are illustrative, not a production portfolio model. ## Hackathon review path @@ -23,7 +23,7 @@ Submission details, category, team, and the matching formal verification are in Track: **AI Security & Defense**. The deliverable is an open-source contract that ecosystem teams can adapt and deploy for shared compute, delivery capacity, inventory, worker funding, and risk budgets. The explorer demonstrates those applications. See the [judge walkthrough](docs/judges-guide.md) for a 90-second demo script and a claim-to-evidence map. -Start the lab below, then click **Begin docking sequence**. Atlas reserves 4 MW and Lyra 2 MW. Vega asks for 4 MW: **WAIT TO DOCK**. The station has 12 MW per window, but 4 MW is protected for life support; docking cannot exceed 8 MW. The denied request leaves 6 MW booked. Click **Request Vega docking in window 02** to submit a fresh request against the second window. The animation reflects Rust decisions, not a JavaScript policy implementation. The original GPU scenario remains available as a separate example of an energy-only denial. +Start the lab below, then click **Watch an example: docking**. Atlas reserves 4 MW and Lyra 2 MW. Vega asks for 4 MW: **WAIT TO DOCK**. The station has 12 MW per window, but 4 MW is protected for life support; docking cannot exceed 8 MW. The denied request leaves 6 MW booked. Click **Request Vega docking in window 02** to submit a fresh request against the second window. The animation reflects Rust decisions, not a JavaScript policy implementation. The original GPU scenario remains available as a separate example of an energy-only denial. ## Run the interactive lab @@ -74,7 +74,7 @@ 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 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. +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 covered by tests and the v1.1.0 verification. 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). @@ -89,4 +89,4 @@ Read the [API](docs/api.md), [state-machine specification](docs/spec.md), [updat - 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 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. +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/32) targets v1.1.0, with the contract source pinned at `57b3f02`: Lean proofs cover the model transcription, TLA+ checks a bounded model, Kani checks the Rust core, and conformance traces connect the models to the Rust core. Verification of v1.0.0 (pinned at `a4bb5c3`) 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). The v1.1.0 verification checks those fixes. Changes to the contract or policy require review against the proof assumptions. diff --git a/SECURITY.md b/SECURITY.md index adf15f7..18880cc 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,6 +1,6 @@ # Security and scope -This is an unaudited, not-formally-verified prototype. Do not treat synthetic credits or risk coefficients as a live financial system. +This is an unaudited prototype. Its v1.1.0 source (`57b3f02`) has been through [multi-level formal verification](https://github.com/difflabai/formalver/pull/32); the proofs have stated scopes and assumptions. Do not treat synthetic credits or risk coefficients as a live financial system. 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. diff --git a/docs/judges-guide.md b/docs/judges-guide.md index df1272e..0bd1837 100644 --- a/docs/judges-guide.md +++ b/docs/judges-guide.md @@ -9,7 +9,7 @@ The contribution is checking combined consequences, including pending commitment ## A 90-second presentation 1. **Arrival (15 seconds):** Three independent ships share a station's power. Life support always retains 4 of the 12 MW available in each docking window. -2. **The conflict (25 seconds):** Click **Begin docking sequence**. Atlas reserves 4 MW, then Lyra 2 MW. Vega's 4 MW request is rejected: **WAIT TO DOCK**. The illustration changes from blue power routes to an amber holding marker. The reserved power remains 6 MW. +2. **The conflict (25 seconds):** Click **Watch an example: docking**. Atlas reserves 4 MW, then Lyra 2 MW. Vega's 4 MW request is rejected: **WAIT TO DOCK**. The illustration changes from blue power routes to an amber holding marker. The reserved power remains 6 MW. 3. **A new decision (15 seconds):** Click **Request Vega docking in window 02**. A new request reserves 4 MW in a separate allocation period. Waiting does not create an authorization or silently queue a transaction. Dispatch is a separate lifecycle step. 4. **The real product (35 seconds):** This is an MIT-licensed Rust / NEAR contract the ecosystem can adapt and deploy. Show the same gate in compute or agent hiring, then the contract, evidence, and verification scope. Explain that the station is a synthetic example; its power values are policy fixtures, not telemetry. @@ -23,7 +23,7 @@ From the repository root, with the Rust toolchain installed: cargo run -p pool-demo -- serve ``` -Open `http://127.0.0.1:8080/` and click **Begin docking sequence**. It resets the station and runs three decisions, pausing briefly between them unless reduced motion is enabled. Expect **WAIT TO DOCK**, 6 / 8 MW docking power, and the protected 4 MW life-support allocation. The explorer records **Bounds**, prospective score 20 → 44, while the committed score stays 20. +Open `http://127.0.0.1:8080/` and click **Watch an example: docking**. It resets the station and runs three decisions, pausing briefly between them unless reduced motion is enabled. Expect **WAIT TO DOCK**, 6 / 8 MW docking power, and the protected 4 MW life-support allocation. The explorer records **Bounds**, prospective score 20 → 44, while the committed score stays 20. Continue to submit Vega's new window-02 request. Expect 4 / 8 MW reserved in window 02, score 20 → 4, and a blue admitted route. Continue once more for Lyra's remaining 2 MW: window 02 reaches 6 MW and the score reaches zero. These are separate allocation periods, not simultaneous use of twice the station's capacity. @@ -53,11 +53,11 @@ Not implemented: public-network deployment, live LLM agents, real escrow/payment ## Formal verification -[Formal verification PR #31](https://github.com/difflabai/formalver/pull/31) targets v1.0.0, with contract source pinned at `a4bb5c3`. It reports completed Lean model proofs, bounded TLA+ safety checks, Prolog requirements checks, and conformance traces against the Rust core and NEAR shell. These are substantive verification results, with distinct scopes; they are not a completed proof of every deployed Rust/Wasm behavior. +[Formal verification PR #32](https://github.com/difflabai/formalver/pull/32) targets v1.1.0, with contract source pinned at `57b3f02`. It covers Lean model proofs, bounded TLA+ safety checks, Prolog requirements checks, Kani on the Rust core, and conformance traces against the Rust core and NEAR shell. These are substantive verification results, with distinct scopes; they are not a completed proof of every deployed Rust/Wasm behavior. The new station fixture is not part of that pinned verification revision; it has a dedicated Rust regression test. -The PR is a draft labeled **In-Progress**. Kani verification of the real Rust core and refinement obligations remain pending. It reported high-severity settlement/liveness findings F-1 and F-2 and several lower-severity findings. 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), which changes admission, record retention and the version limit ([findings](verification-findings.md), [changelog](../CHANGELOG.md)). The fixes are tested but not formally re-verified. Present the findings and fixes alongside the proofs, and inspect the PR's current status before making a deployment claim. Modifying the contract or its policy requires reviewing the proof assumptions and rerunning applicable checks. +Verification of v1.0.0 (pinned at `a4bb5c3`, [PR #31](https://github.com/difflabai/formalver/pull/31)) reported high-severity settlement/liveness findings F-1 and F-2 and several lower-severity findings. 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), which changes admission, record retention and the version limit ([findings](verification-findings.md), [changelog](../CHANGELOG.md)). The v1.1.0 verification checks those fixes. Present the findings and fixes alongside the proofs, and inspect the PR's current status before making a deployment claim. Modifying the contract or its policy requires reviewing the proof assumptions and rerunning applicable checks. ## Presentation rationale and official sources diff --git a/docs/spec.md b/docs/spec.md index 12482b5..51f25d5 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -1,6 +1,6 @@ # Core specification -This document describes v1.1.0 of the implemented prototype. It is not a claim of completed formal verification. An outside verification checked v1.0.0; v1.1.0 fixes its findings and has not been re-verified ([verification findings](verification-findings.md), [changelog](../CHANGELOG.md)). +This document describes v1.1.0 of the implemented prototype. An outside verification checked v1.0.0 and found issues; v1.1.0 fixes them and is covered by a [formal verification](https://github.com/difflabai/formalver/pull/32) of source revision `57b3f02`. Its proofs have stated scopes and assumptions ([verification findings](verification-findings.md), [changelog](../CHANGELOG.md)). ## State and identity diff --git a/docs/verification-findings.md b/docs/verification-findings.md index 4bb0efa..b778294 100644 --- a/docs/verification-findings.md +++ b/docs/verification-findings.md @@ -9,8 +9,8 @@ owner may remain a recipe's executor. The repository owner also accepted the record window (F-3) and the stricter admission (F-1, F-2). Each finding has a **Status** line with the fixing commit and the tests that check the fix; [CHANGELOG.md](../CHANGELOG.md) lists the changes. The -formal results cited here apply to v1.0.0. v1.1.0 has not been formally -re-verified: its fixes are checked by tests in this repository only. The +formal results cited here apply to v1.0.0. The v1.1.0 fixes are checked by tests in +this repository and by the [v1.1.0 verification](https://github.com/difflabai/formalver/pull/32). The commit hashes on this page are commits of [PR #4](https://github.com/difflabai/shared-pool-controls/pull/4), which lists them. @@ -42,8 +42,11 @@ paragraphs below cite results as that section reports them. In this repository the findings are checked by the regression tests in `crates/core/src/findings.rs` (the v1.0.0 reproducers, rewritten for v1.1.0) and by the unit, build and sandbox tests that v1.1.0 added. The -TLC, Lean, Prolog, shell and sandbox results of the verification project -were not re-run for this page, and none of them covers v1.1.0. +findings and the Evidence paragraphs below come from the v1.0.0 verification +(PR #31). The v1.1.0 fixes are covered by the separate +[v1.1.0 verification](https://github.com/difflabai/formalver/pull/32), which +targets source revision `57b3f02`. The TLC, Lean, Prolog, shell and sandbox +results cited on this page were not re-run for it. ## How the findings were found @@ -65,8 +68,8 @@ The formalver project checked the code with several independent methods: runtime. - **Sandbox.** Both wasm files on a local near-workspaces chain, compared with the host core. -- **Kani** (bounded model checking of the Rust core) is in progress. It has - produced no results yet. +- **Kani** (bounded model checking of the Rust core) ran on v1.0.0 and, in the + v1.1.0 verification, on `57b3f02`. Nothing here is a proof about the Rust core or the NEAR shell. The Lean results hold for the transcription, and the TLC and MC-1 results hold @@ -104,7 +107,7 @@ refused (`Bounds`). Every open record can now be resolved: a Reserved one by cancel, a dispatched one by its executor's report. Regression tests: `f1_hedge_that_cures_by_reservation_is_refused`, `f1_recovery_by_completion_is_admitted_and_live`, `live_all_on_random_runs`. -Formal re-verification pending. +Re-checked by the [v1.1.0 verification](https://github.com/difflabai/formalver/pull/32). **What happens.** An `observe` puts metric 0 at 12, above its max of 10. The recovery rule (spec:21, spec:23) admits a hedge that reserves −2 on @@ -175,8 +178,7 @@ the position open, 8- and 7-unit hedges are refused and 6 units are admitted. After the hedge completes, the position can still be released by `settle(false)` or `cancel`. Regression tests: `f2_hedge_cannot_rely_on_an_unexecuted_position`, -`f2_reserved_position_can_always_be_cancelled`. Formal re-verification -pending. +`f2_reserved_position_can_always_be_cancelled`. Re-checked by the [v1.1.0 verification](https://github.com/difflabai/formalver/pull/32). **What happens.** There is no `observe`, and every metric is in bounds. A credit position (recipe 0, 1 unit) reserves +20 selloff loss: 60 becomes @@ -252,7 +254,7 @@ settle(executor, 0, true) Ok **Status.** Fixed in v1.1.0 (`59e404f`). The release is inside the admission interval, so b x 100 fails `Arithmetic` at admission and b x 66 is admitted; after b completes, a can be cancelled. Regression test: -`f2b_release_stays_in_the_value_range`. Formal re-verification pending. +`f2b_release_stays_in_the_value_range`. Re-checked by the [v1.1.0 verification](https://github.com/difflabai/formalver/pull/32). **What happens.** A release subtracts the reservation (`values - reserve * units`), and nothing bounds that result in advance. If @@ -302,8 +304,7 @@ Regression tests: `f3_window_frees_terminal_records_and_keeps_ids`, `f3_prerequisites_survive_pruning`, `window_on_random_runs`, the contract and executor `f3_*` tests, the executor `d1_*` tests, and the sandbox tests `window_of_300_records_through_the_executor` and -`confirmed_failed_executes_keep_the_executor_at_256_jobs`. Formal -re-verification pending. +`confirmed_failed_executes_keep_the_executor_at_256_jobs`. Re-checked by the [v1.1.0 verification](https://github.com/difflabai/formalver/pull/32). **What happens.** Records are never deleted (spec:54: `observe` does not delete history), and `submit` fails `Full` at 256 records. A submit followed @@ -340,7 +341,7 @@ actor is its executor (`InvalidConfig`), so both mutations below are refused. The owner may be a recipe's actor, or its executor, when the other role is a different account: the repository owner decided to allow it. This is the owner's decision, not an open question. Regression test: -`f4_actor_cannot_be_its_own_executor`. Formal re-verification pending. +`f4_actor_cannot_be_its_own_executor`. Re-checked by the [v1.1.0 verification](https://github.com/difflabai/formalver/pull/32). **What happens.** `Config::validate` does not compare a recipe's actor with its executor or with the owner. A recipe with actor = executor, or with @@ -382,7 +383,7 @@ and at most 256 records are open. At the cap a paused pool stays paused, and its open records still settle. Regression tests: `f5_open_records_resolve_above_the_version_cap`, `f5_paused_pool_at_the_cap_still_settles`, `f5_reserve_is_exactly_enough`. -Formal re-verification pending. +Re-checked by the [v1.1.0 verification](https://github.com/difflabai/formalver/pull/32). **What happens.** Every effective transition adds 1 to `version` with `checked_add`. At `version = u32::MAX` every transition fails `Arithmetic`: @@ -434,8 +435,7 @@ observe(owner, [0, 0, 0, 0, 0]) Arithmetic **Status.** Fixed in v1.1.0 (`3eaf1cb`). The owner can restate the current values at any time, which renews the snapshot timestamp. New values still need every record terminal. Regression test: -`f6_owner_refreshes_the_snapshot_with_records_open`. Formal re-verification -pending. +`f6_owner_refreshes_the_snapshot_with_records_open`. Re-checked by the [v1.1.0 verification](https://github.com/difflabai/formalver/pull/32). **What happens.** With `max_age_seconds > 0`, `submit` and `dispatch` need a snapshot no older than `max_age_seconds` (spec:19, spec:37). Only diff --git a/docs/verification-handoff.md b/docs/verification-handoff.md index 397dd78..6185e4b 100644 --- a/docs/verification-handoff.md +++ b/docs/verification-handoff.md @@ -1,6 +1,6 @@ # Handoff for formal verification -No formal proof is claimed in this repository. The implementation intentionally focuses on small Rust APIs, tests, synthetic execution and static UIs. +The formal verification of v1.1.0 (source revision `57b3f02`) lives in [difflabai/formalver PR #32](https://github.com/difflabai/formalver/pull/32); this repository holds no proofs itself. The implementation intentionally focuses on small Rust APIs, tests, synthetic execution and static UIs. Start with `crates/core/src/lib.rs` and `docs/spec.md`. The default pool-core build has **zero dependencies**, no unsafe code, no NEAR imports, and no external I/O. Optional serde/borsh are serialization only. `cargo test -p pool-core --no-default-features` exercises the proof-facing configuration. @@ -31,18 +31,18 @@ Important nuances: - Recovery admission uses nonincrease at reservation and strict decrease for the proposed completed state. A reservation never changes a metric's violation amount. It does not prove eventual completion or safety under arbitrary future market moves. - Hard checks use intervals that contain every outcome of every open record: it stays open, completes, or releases its reservation. This overapproximation can reject feasible correlated bundles; it should never underapproximate the modeled independent effects. -- Admission requires each metric's interval violation to be at most its violation before the request and after the reservation. So in every reachable state each metric's interval violation equals its current violation, and no completion or release can fail the bounds check (LIVE). The version reserve below means the version increment cannot fail either. Liveness is conditional only on authoritative evidence and gas. These rules were added after the v1.0.0 verification (findings F-1, F-2, F-2b and F-5 in verification-findings.md). They are tested, not formally re-verified. +- Admission requires each metric's interval violation to be at most its violation before the request and after the reservation. So in every reachable state each metric's interval violation equals its current violation, and no completion or release can fail the bounds check (LIVE). The version reserve below means the version increment cannot fail either. Liveness is conditional only on authoritative evidence and gas. These rules were added after the v1.0.0 verification (findings F-1, F-2, F-2b and F-5 in verification-findings.md). They are tested and covered by the v1.1.0 verification ([formalver PR #32](https://github.com/difflabai/formalver/pull/32), `57b3f02`). - Fixed policy is part of the theorem. Owner observations, executor honesty, and source model adequacy are assumptions, not consequences of a low potential. - Energy is not checked on lifecycle reversal or observation. Do not accidentally state an all-transition monotonicity theorem. - Version reserve: submit, dispatch, pause and observe stop 768 versions below u32::MAX (`VERSION_CAP`, `Arithmetic`); acknowledgment, settlement and cancellation always remain available. An open record needs at most three more increments (Dispatched -> Unknown -> Active -> terminal) and there are at most 256 records, so the reserve is exactly enough. Every effective transition still increments version by exactly 1. Pause/observe still advance version. -- Record window: the pool keeps its 256 most recent records. A submit into a full window prunes the oldest record if it is terminal and fails `Full` if it is open. By LIVE that record can be closed: by its actor or the owner while Reserved, and by its executor's report once dispatched. Until the executor reports, submit stays `Full` (head-of-line). Ids never repeat, a pruned id is `NotFound`, and replay protection is the version, not retention. Prerequisites read `completed_units`, a lifetime count updated by `settle(true)`. The executor forgets a job once its id is 256 or more behind the newest id the lock vouched for (an `execute` that created a job, or an accepted `settle`); the lock has pruned that record, so it is terminal and never dispatched again. This replaces v1.0.0's 256 lifetime records (finding F-3); it is tested, not formally re-verified. +- Record window: the pool keeps its 256 most recent records. A submit into a full window prunes the oldest record if it is terminal and fails `Full` if it is open. By LIVE that record can be closed: by its actor or the owner while Reserved, and by its executor's report once dispatched. Until the executor reports, submit stays `Full` (head-of-line). Ids never repeat, a pruned id is `NotFound`, and replay protection is the version, not retention. Prerequisites read `completed_units`, a lifetime count updated by `settle(true)`. The executor forgets a job once its id is 256 or more behind the newest id the lock vouched for (an `execute` that created a job, or an accepted `settle`); the lock has pruned that record, so it is terminal and never dispatched again. This replaces v1.0.0's 256 lifetime records (finding F-3); it is tested and covered by the v1.1.0 verification. - Executor job cap: the synthetic executor holds at most 512 jobs. Job ids are distinct, so at most 256 have ids at or below its newest id. The lock accepts honest confirmations, and each accepted one moves the newest id, so honest use holds 256 jobs plus confirmations in flight. The cap needs at least 256 jobs above the newest id (more if fewer sit at or below it): confirmations the lock refused (operator error: an unassigned or pruned id, a record still Reserved, a record whose other outcome is recorded, or another executor's recipe, `Unauthorized`) or confirmations whose `on_settled` has not run. A refused job is forgotten only once the newest id is 256 or more past its id, so never for an id the lock does not reach. At the cap, `confirm_not_executed` fails `full`, and so does an `execute` that frees no job. If executes then keep failing, their records stay Unknown and cannot be confirmed; once the lock holds 256 records, the oldest of them Unknown and none Reserved, submit fails `Full` and nothing can be dispatched. The exits are a `settle` signed with the executor account's own key, or an accepted `finish(id, false)` of a refused job whose record the lock holds as cancelled or open. LIVE still holds at the lock (the executor's `settle` would succeed), but in that state the synthetic executor contract may not be able to send it. `docs/api.md` (Executor protocol) gives the details. ## Boundary checks The NEAR shell serializes the same core with borsh. Review `predecessor_account_id`, init authority, callback privacy, private callback's promise-result mapping (the lock's `on_result`; the executor's `on_settled`, which is private, needs exactly one promise result and moves the newest id only when the lock's `settle` succeeded), persistent state atomicity, and bounded gas/storage. The synthetic executor is independent code and must be included if claiming end-to-end gating. Unknown receipt failure cannot imply a refund. -Both contracts create promises only with `promise_create`, `promise_then` and `promise_return`, and every promise is a function call with no deposit. Neither Wasm imports a host function for any other action: deploy, keys, transfer, stake, account creation or deletion, global contracts, or any `promise_batch_*` function. `scripts/build.sh` fails if one is imported, and also on any import not on its reviewed list (18 for the contract, 16 for the executor). This was added after the v1.0.0 verification (finding NT-F3); it is checked by the build, not formally re-verified. +Both contracts create promises only with `promise_create`, `promise_then` and `promise_return`, and every promise is a function call with no deposit. Neither Wasm imports a host function for any other action: deploy, keys, transfer, stake, account creation or deletion, global contracts, or any `promise_batch_*` function. `scripts/build.sh` fails if one is imported, and also on any import not on its reviewed list (18 for the contract, 16 for the executor). This was added after the v1.0.0 verification (finding NT-F3); it is checked by the build and covered by the v1.1.0 verification. Account upgrades, oracle dishonesty, physical delivery, real broker fills, and deployment locks are outside the current tests. There is no real token custody. Do not inherit formalver's labels or proofs: the design pattern is reused, not its implementation theorem. diff --git a/nearhackathon.md b/nearhackathon.md index c7bd5d7..a9d1907 100644 --- a/nearhackathon.md +++ b/nearhackathon.md @@ -7,7 +7,7 @@ This repository is a submission to the **November 2026 NEAR Hackathon**. | **Category** | AI Security & Defense | | **Project** | Shared Pool Controls: an MIT-licensed Rust / NEAR contract that keeps independent agents' combined commitments to a shared resource within an owner-defined policy | | **Submission** | This repository, [difflabai/shared-pool-controls](https://github.com/difflabai/shared-pool-controls), together with its formal verification (below) | -| **Formal verification** | **Part of this submission:** the matching verification of this contract in [difflabai/formalver PR #31](https://github.com/difflabai/formalver/pull/31) | +| **Formal verification** | **Part of this submission:** the matching verification of this contract in [difflabai/formalver PR #32](https://github.com/difflabai/formalver/pull/32), which verifies v1.1.0 (`57b3f02`) | | **Live site** | [difflabai.github.io/shared-pool-controls](https://difflabai.github.io/shared-pool-controls/): a static replay of the scenarios, published from this repository with GitHub Pages | ## What is submitted @@ -15,7 +15,7 @@ This repository is a submission to the **November 2026 NEAR Hackathon**. - The Rust core, the NEAR lock contract, and the synthetic executor adapter in [`crates`](crates). - Six scenarios (station power, GPU compute, delivery capacity, inventory, worker budgets, and risk headroom) with Rust-generated traces in [`scenarios`](scenarios). - A static explorer and NEAR console in [`ui`](ui), plus a guide for configuring and deploying the contract against your own resource contention problem. -- Formal verification of the contract, in progress, in the companion PR above; it is part of the submission and is evaluated with it. It includes Lean model proofs and TLA+ checks of v1.0.0; Rust-core Kani verification is pending. v1.1.0 fixes the settlement/liveness and other findings that PR reported ([findings](docs/verification-findings.md)); the fixes are tested but not formally re-verified. +- Formal verification of v1.1.0 in the companion PR above; it is part of the submission and is evaluated with it. It includes Lean model proofs, TLA+ checks, Kani on the Rust core, and conformance traces. Verification of v1.0.0 reported settlement/liveness and other findings; v1.1.0 fixes them ([findings](docs/verification-findings.md)). The [judge walkthrough](docs/judges-guide.md) has a 90-second demo script and a claim-to-evidence map. The contract is not independently audited and has not been deployed to a public network. diff --git a/ui/base.css b/ui/base.css index fdc6f61..42ad56f 100644 --- a/ui/base.css +++ b/ui/base.css @@ -1690,3 +1690,18 @@ body:not(.story-site) .row { .deploy-guide { grid-template-columns:1fr; gap:28px; } .deploy-code { position:static; } } + +/* Hero: what the project is, how it is verified, and that docking is an example */ +.orbital-hero h1 { font-size:clamp(2.5rem,3.9vw,3.9rem); line-height:1.06; margin:22px 0 20px; } +.orbital-hero .hero-what { color:#d3e1f6; font-size:.98rem; line-height:1.65; max-width:520px; } +.proof-strip { margin:22px 0 4px; padding:14px 16px; max-width:520px; border:1px solid #88dfff3a; border-left:3px solid #88dfff; border-radius:10px; background:#88dfff0d; } +.proof-badges { display:flex; flex-wrap:wrap; gap:8px; } +.proof-badges span { font:600 .66rem ui-monospace,SFMono-Regular,monospace; letter-spacing:.04em; color:#bdf0ff; padding:5px 10px; border:1px solid #88dfff55; border-radius:20px; background:#08142a; } +.proof-badges span:before { content:"✓ "; color:#78dfcb; } +.proof-note { margin-top:10px; font-size:.74rem; line-height:1.55; color:#a6b6d1; } +.proof-note a { color:#bdf0ff; white-space:nowrap; } +.orbital-hero .hero-actions { margin-top:24px; } +.example-tag { color:#ffb574; } +@media(max-width:760px) { .orbital-hero h1 { font-size:clamp(2.2rem,9vw,3.2rem); } .proof-strip { max-width:none; } } +.scene-topline { font-size:.62rem; } +.example-tag { font-weight:700; padding:4px 9px; border:1px solid #ffa96766; border-radius:20px; background:#ffa9671a; } diff --git a/ui/index.html b/ui/index.html index 2c1e097..792629e 100644 --- a/ui/index.html +++ b/ui/index.html @@ -4,9 +4,9 @@ - + - + @@ -14,29 +14,32 @@ - Shared Pool Controls — Shared-state security for AI agents + Shared Pool Controls — A formally verified contract for shared resources
-

NEAR Hackathon / AI Security & Defense

-

Three ships.
One power grid.
No exceptions.

-

Every captain wants to dock.
Life support comes first.

-

A shared resource. Independent agents. One enforceable boundary. Shared Pool Controls is an open-source Rust / NEAR contract you can modify and deploy to keep their combined commitments within policy.

-
Explore all six scenarios ↓
+

Open-source Rust / NEAR contract

+

A formally verified contract for shared resources.

+
Independent agents book capacity from one shared pool: GPU time, power, inventory, budget. The contract admits a booking only if hard limits hold and the pool’s combined commitments do not get worse. Owners write the policy as one JSON file. Agents cannot rewrite it.
+
+
Lean model proofsTLA+ safety checksKani on the Rust coreConformance traces
+
The verification found two high-severity settlement bugs in v1.0.0. v1.1.0 fixes them. Multi-level verification ↓
+
+
Explore all six scenarios ↓
-
COMMONS / ORBITAL STATION SYSTEM ONLINE
+
EXAMPLE 1 OF 6 · SPACE STATION SYSTEM ONLINE
@@ -124,7 +127,7 @@

Three ships.
One power grid.
No exceptions.// Reserve first. Dispatch second. commit(next);

Recovery from an externally disturbed state has additional checks. See the full specification for exact semantics.

-
01

A pure Rust core

Bounded data, checked integer arithmetic, fixed recipes. No NEAR dependency in the core’s default build.

02

A NEAR execution boundary

The synthetic adapter accepts execution only from the lock. Callback failure does not automatically release a commitment.

03

A precise claim

Accepted reservations do not increase the configured potential. External events can. Lean model proofs and TLA+ checks of v1.0.0 are complete; Rust-core verification remains in progress. Explore the formal verification.

+
01

A pure Rust core

Bounded data, checked integer arithmetic, fixed recipes. No NEAR dependency in the core’s default build.

02

A NEAR execution boundary

The synthetic adapter accepts execution only from the lock. Callback failure does not automatically release a commitment.

03

A precise claim

Accepted reservations do not increase the configured potential. External events can. Lean model proofs, TLA+ checks, and Kani verification of the Rust core target v1.1.0. Explore the formal verification.

Make it yours

Configure it for your own contention problem. Deploy it on NEAR.

Everything that makes the six scenarios different is data. Describe your shared resource in one JSON policy, then deploy the same tested Wasm.

    @@ -175,7 +178,7 @@

    Three ships.
    One power grid.
    No exceptions.

    Use the deployment checklist for account setup, then open the NEAR console with your account and expected code hash.

-
Before you deploy for real

Replace every executor with an adapter you control. The bundled executor is synthetic: it proves the gate, not a connection to your GPUs, warehouse, or funds. A real adapter must implement the execute and status protocol, idempotency, and authoritative cancellation, and it must leave agents no route around the lock.

Policy and principals cannot be edited after initialization. A pool holds at most 32 metrics and 32 recipes, and keeps its 256 most recent commitments; a new one replaces the oldest once that has ended. The contract is not independently audited. Its formal verification covers v1.0.0; v1.1.0 fixes the reported findings, and the fixes are tested but not yet formally re-verified. Test on testnet first.

+
Before you deploy for real

Replace every executor with an adapter you control. The bundled executor is synthetic: it proves the gate, not a connection to your GPUs, warehouse, or funds. A real adapter must implement the execute and status protocol, idempotency, and authoritative cancellation, and it must leave agents no route around the lock.

Policy and principals cannot be edited after initialization. A pool holds at most 32 metrics and 32 recipes, and keeps its 256 most recent commitments; a new one replaces the oldest once that has ended. The contract is not independently audited. Formal verification of v1.0.0 found issues; v1.1.0 fixes them. Future versions are likely to add more capabilities, check that the contract version you use has the capabilities you want (sometimes simpler is better). Test on testnet first.

@@ -186,7 +189,7 @@

Three ships.
One power grid.
No exceptions.

Illustrative request: the real expiry is an integer timestamp. A stale version is rejected and must be reviewed again.

What happens after approval?
Reserved→Dispatched→Active→Completed

Unknown execution outcomes keep their encumbrance. Before dispatch, the actor or owner can cancel. After dispatch, release requires definitive nonexecution evidence from the registered executor.

-
What is—and isn’t—guaranteed?

The kernel checks the configured bounds and potential against a modeled state. It does not guarantee fairness, profitable trades, truthful external observations, or eventual completion. The immutable policy and registered evidence authorities are part of the trust boundary.

Compute jobs, deliveries, worker payments, and financial positions in this explorer are synthetic. Real-world enforcement requires an adapter without a route around the lock. Dedicated formal verification includes model proofs and checks; Rust-core Kani verification is pending. The verification PR also reports settlement/liveness findings. v1.1.0 fixes them (findings); the fixes are tested, not yet formally re-verified. The contract is not independently audited.

+
What is—and isn’t—guaranteed?

The kernel checks the configured bounds and potential against a modeled state. It does not guarantee fairness, profitable trades, truthful external observations, or eventual completion. The immutable policy and registered evidence authorities are part of the trust boundary.

Compute jobs, deliveries, worker payments, and financial positions in this explorer are synthetic. Real-world enforcement requires an adapter without a route around the lock. Dedicated multi-level verification of v1.1.0 includes model proofs, checks, and Kani on the Rust core. The verification PR reports settlement/liveness findings. v1.1.0 fixes them (findings). The contract is not independently audited.

Inspect the selected scenario’s policy
Inspect the last Rust decision
Run a scenario decision to inspect its response.
@@ -200,8 +203,8 @@

Three ships.
One power grid.
No exceptions.Execution authority

Try going around the gate.

NEAR sandbox tests attempt direct executor calls and agent-authored settlement. Both fail; registered execution evidence is required.

Inspect the bypass tests ↗
Asynchronous safety

Keep uncertain work reserved.

Sandbox tests exercise stale requests, unknown execution outcomes, and reconciliation. A failed callback alone does not free capacity.

Inspect the verification handoff ↗
-

Formal verification, with evidence you can inspect

Dedicated verification of the contract includes Lean model proofs, bounded TLA+ checks, and conformance traces against the Rust core. The work targets source revision a4bb5c3. Kani verification of the Rust implementation remains pending; the PR reports high-severity settlement/liveness findings F-1 and F-2. v1.1.0 fixes them and the lower-severity findings (findings); the fixes are tested, not yet formally re-verified.

Read the formal verification results, scope & findings ↗
-

What you can verify today

Rust kernel, NEAR lock and synthetic executor, six deterministic scenarios, local Wasm integration tests, and a static explorer. The browser demo is a simulation or recorded replay—not a public-chain transaction.

Where the prototype stops

No public-network deployment, real payments, live LLM agents, NEAR Intents integration, or production provider adapters. Not independently audited. Formal verification of v1.0.0 is in progress and identified settlement/liveness findings; v1.1.0 fixes them, tested but not yet formally re-verified. Policy quality and trusted observations remain assumptions.

+

Formal verification, with evidence you can inspect

Dedicated multi-level verification of the contract includes Lean model proofs, bounded TLA+ checks, Kani on the Rust core, and conformance traces against the Rust core. The work targets v1.1.0, source revision 57b3f02. Verification found high-severity settlement/liveness findings F-1 and F-2. v1.1.0 fixes them and the lower-severity findings (findings).

Read the formal verification results, scope & findings ↗
+

What you can verify today

Rust kernel, NEAR lock and synthetic executor, six deterministic scenarios, local Wasm integration tests, and a static explorer. The browser demo is a simulation or recorded replay—not a public-chain transaction.

Where you can go from here:

Integrate into your systems, real payments, live LLM agents, or NEAR Intents integration. Note that this contract has been formally verified but has not been independently audited. Review the contract mechanics to adapt them to your use case.

Open source · MIT licensed · Built for the NEAR ecosystem

Your shared resources.
Your deployed contract.

Modify the contract and policy for your application. Review the verification findings, connect your execution adapter, and deploy a gate your agents share.

Get the contract