A pure Rust core
Bounded data, checked integer arithmetic, fixed recipes. No NEAR dependency in the core’s default build.
diff --git a/README.md b/README.md index a8349ee..74ae4c1 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Agents submit an owner-defined recipe and exact integer quantity. The core check ## Hackathon review path +Submission details, category, team, and the matching formal verification are in [`nearhackathon.md`](nearhackathon.md). + 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. diff --git a/nearhackathon.md b/nearhackathon.md new file mode 100644 index 0000000..49569d0 --- /dev/null +++ b/nearhackathon.md @@ -0,0 +1,24 @@ +# NEAR Hackathon submission + +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) | +| **Formal verification** | The matching verification work in [difflabai/formalver PR #31](https://github.com/difflabai/formalver/pull/31) | +| **Live site** | Static replay of the scenarios, published from this repository with GitHub Pages | + +## What is submitted + +- 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 includes Lean model proofs and TLA+ checks; Rust-core Kani verification is pending and that PR reports settlement/liveness findings that are not yet resolved. + +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. + +## Team membership + +The hackathon rules allow a person to be a member of up to two teams. [gabehamilton](https://github.com/gabehamilton) is a member of the team for this submission and also a member of the team for the [gabehamilton/invest-in-near](https://github.com/gabehamilton/invest-in-near) submission. diff --git a/ui/app.js b/ui/app.js index b113f8f..a519e03 100644 --- a/ui/app.js +++ b/ui/app.js @@ -306,7 +306,7 @@ guarded(reset); const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)'); const revealAll = $('reveal-all'); if (!('IntersectionObserver' in window) || reducedMotion.matches) return; - const groups = document.querySelectorAll('.hero-copy, .orbital-scene, .premise-heading, .mechanism article, .energy-note, .section-heading, .demo-guide > div, .technical-points article, .evidence-grid article, .review-status > div, .near-boundary, .closing'); + const groups = document.querySelectorAll('.hero-copy, .orbital-scene, .premise-heading, .mechanism article, .energy-note, .deploy-guide, .section-heading, .demo-guide > div, .technical-points article, .evidence-grid article, .review-status > div, .near-boundary, .closing'); const timers = new Map(); const clear = group => { (timers.get(group) || []).forEach(clearTimeout); diff --git a/ui/base.css b/ui/base.css index 605b0df..fdc6f61 100644 --- a/ui/base.css +++ b/ui/base.css @@ -1668,3 +1668,25 @@ body:not(.story-site) .row { } .orbital-scene { scroll-margin-top:16px; } + +/* Deploy guide: configure and deploy the contract for your own problem. */ +.deploy-guide { display:grid; grid-template-columns:1.1fr .9fr; gap:28px 56px; margin:56px 0 12px; padding-top:44px; border-top:1px solid var(--line); align-items:start; } +.deploy-intro { grid-column:1 / -1; max-width:720px; } +.deploy-intro h3 { font-size:clamp(1.5rem,2.6vw,2.1rem); line-height:1.2; margin:10px 0 14px; } +.deploy-intro p { color:var(--muted); font-size:.9rem; line-height:1.8; margin:0; } +.deploy-steps { list-style:none; margin:0; padding:0; display:grid; gap:2px; } +.deploy-steps li { display:flex; gap:22px; padding:20px 0; border-bottom:1px solid var(--line); } +.deploy-steps li:first-child { padding-top:4px; } +.deploy-steps li:last-child { border-bottom:0; } +.deploy-steps .step-number { font-size:1.6rem; margin:0; min-width:44px; } +.deploy-steps h4 { font-size:1rem; margin:0 0 8px; } +.deploy-steps p { font-size:.82rem; color:var(--muted); line-height:1.75; margin:0 0 8px; } +.deploy-steps code, .deploy-code + .deploy-commands code { font-size:.78em; } +.deploy-code { position:sticky; top:24px; } +.deploy-code pre { font-size:.7rem; line-height:1.75; white-space:pre; overflow-x:auto; } +.deploy-commands { grid-column:1 / -1; } +.deploy-commands pre { white-space:pre; overflow-x:auto; font-size:.74rem; line-height:1.8; } +@media(max-width:900px) { + .deploy-guide { grid-template-columns:1fr; gap:28px; } + .deploy-code { position:static; } +} diff --git a/ui/index.html b/ui/index.html index 7356bbd..edfc20b 100644 --- a/ui/index.html +++ b/ui/index.html @@ -116,6 +116,48 @@
Recovery from an externally disturbed state has additional checks. See the full specification for exact semantics.
Bounded data, checked integer arithmetic, fixed recipes. No NEAR dependency in the core’s default build.
The synthetic adapter accepts execution only from the lock. Callback failure does not automatically release a commitment.
Accepted reservations do not increase the configured potential. External events can. Lean model proofs and TLA+ checks are complete; Rust-core verification remains in progress. Explore the formal verification.
Everything that makes the six scenarios different is data. Describe your shared resource in one JSON policy, then deploy the same tested Wasm.
Each metric is a quantity the pool tracks, with hard min and max bounds: GPU blocks, MW, inventory, budget.
Add one metric per window or bucket you need to protect separately. A protected reserve is simply a lower max on the shared bucket.
Each term scores imbalance: Target distance, Excess over a line, or Deficit below one. Admission requires the total never rises.
Weights decide which problems matter most. Hard bounds and the score are separate checks; a lower score never buys a breach.
A recipe fixes who may ask (actor), who executes (executor), what is reserved, and what completion changes. Agents choose only a recipe and a quantity.
requires chains recipes, so a later step can need an earlier one to finish first.
Policy is immutable once new runs, so review it first. Deploy and initialize in one transaction from the contract’s own account.
Then check the code hash, preview as an agent, and submit.
{
+ "name": "api-budget",
+ "owner": "you.near",
+ "max_age_seconds": 0,
+ "metrics": [{ "name": "Requests booked", "unit": "req/min",
+ "initial": 0, "min": 0, "max": 100 }],
+ "terms": [{ "metric": 0, "target": 80,
+ "weight": 10, "shape": "Excess" }],
+ "recipes": [{ "name": "Crawler: batch", "actor": "crawler.near",
+ "executor": "api-gateway.near",
+ "reserve": [1], "complete": [0],
+ "max_units": 40, "requires": [] }]
+}# 1. Build both Wasm contracts and a provenance manifest
+./scripts/build.sh
+
+# 2. Deploy and initialize the lock in one transaction
+# (near-cli-rs syntax; check `near contract deploy --help` for your version)
+near contract deploy pool.you.near \
+ use-file target/wasm32-unknown-unknown/release/pool_contract.wasm \
+ with-init-call new json-args "$(jq -c '{config: .}' config.json)" \
+ prepaid-gas '100 Tgas' attached-deposit '0 NEAR' \
+ network-config testnet sign-with-keychain send
+
+# 3. Read it back and compare the code hash to your build manifest
+near contract call-function as-read-only pool.you.near get_pool \
+ json-args {} network-config testnet now
+ Use the deployment checklist for account setup, then open the NEAR console with your account and expected code hash.
+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, 32 recipes, and 256 lifetime commitments; deploy a fresh pool to rotate. The contract is not independently audited and its formal verification is in progress, so test on testnet first.
A recipe ID, an exact integer quantity, the state version it reviewed, and a short expiry. Recipes fix the actor, executor, effects, and prerequisites. The agent cannot supply its own risk estimate or ledger delta.
{
"recipe": 0,
@@ -128,19 +170,19 @@ Three ships.
One power grid.
No exceptions.
Inspect the selected scenario’s policy
Inspect the last Rust decision
Run a scenario decision to inspect its response.
The deliverable is an MIT-licensed contract for the NEAR ecosystem. Fork it, define the shared resources and policy for your application, and connect an enforced executor. The six scripted scenarios show how the same admission rule applies across businesses.
The GPU trace includes a request that passes hard capacity bounds but raises energy. It is denied without reserving resources.
Inspect the Rust-generated trace ↗NEAR sandbox tests attempt direct executor calls and agent-authored settlement. Both fail; registered execution evidence is required.
Inspect the bypass tests ↗Sandbox tests exercise stale requests, unknown execution outcomes, and reconciliation. A failed callback alone does not free capacity.
Inspect the verification handoff ↗The GPU trace includes a request that passes hard capacity bounds but raises energy. It is denied without reserving resources.
Inspect the Rust-generated trace ↗NEAR sandbox tests attempt direct executor calls and agent-authored settlement. Both fail; registered execution evidence is required.
Inspect the bypass tests ↗Sandbox tests exercise stale requests, unknown execution outcomes, and reconciliation. A failed callback alone does not free capacity.
Inspect the verification handoff ↗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.
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.
No public-network deployment, real payments, live LLM agents, NEAR Intents integration, or production provider adapters. Not independently audited. Formal verification is in progress and has identified settlement/liveness findings. Policy quality and trusted observations remain assumptions.
Open source · MIT licensed · Built for the NEAR ecosystem
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