Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions submissions/mcp-hackathon/solonsky-grid-witness/RIGHTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Submission rights declaration

Project: Grid Witness
Submission slug: solonsky-grid-witness
Submitter: Aleksei Solonskii (Alex SOLONSKY)
Date: 2026-09-12

The submitter confirms that they own, or have sufficient authorization for, the source code, dependencies, service, data, branding, and other materials submitted in this pull request.

Subject to the official program terms, the submitter authorizes X-Agent to retain, reproduce, audit, test, archive, and publish the submitted program artifact for judging, fraud prevention, dispute handling, ecosystem submission, and post-award accountability. Closing the pull request, deleting a fork, or deleting an external repository does not revoke the official archive rights attached to an accepted and rewarded entry.

The original project source is MIT-licensed. The numerical baseline is the submitter's synthetic classical demonstrator, not sponsor data or proprietary utility software. This entry adds the agent/HTTP capability and its tests. No third-party dataset, brand asset or pretrained model is included.

Runtime dependencies: FastAPI (MIT), Starlette (BSD-3-Clause), Pydantic (MIT), Uvicorn (BSD-3-Clause), Gradio (Apache-2.0), Hugging Face spaces (Apache-2.0). HTTPX (BSD-3-Clause) is used for tests. Applicable licenses and notices remain those in each package distribution. source/requirements-test.lock lists the tested dependency set; the Hugging Face platform manages Gradio and spaces runtime packages.

Exceptions/restrictions: this small synthetic educational example must not be represented as a real-grid engineering approval, an E.ON dataset, certified AC global optimality, or quantum advantage. No private Life CP code or personal data is part of this submission.
50 changes: 50 additions & 0 deletions submissions/mcp-hackathon/solonsky-grid-witness/SUBMISSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Grid Witness

## Capability

- **Track:** General Challenge (Open Innovation).
- **One-line description:** Give an agent a reproducible numerical witness when a simplified grid-upgrade screen is too optimistic.
- **Who it helps:** Developers testing whether an agent can challenge a proposed plan instead of blindly accepting its optimizer output; educators demonstrating model mismatch.
- **Capability boundary:** One fixed synthetic six-line radial chain, 64 upgrade plans and three demand scales. No arbitrary network ingestion or real-world design advice. Reports AC operating-point residuals and violations; does not certify physical infeasibility or an AC global optimum.

A cost-18 plan `111000` passes the rational lossless screen but has a minimum-voltage violation after AC power flow at high load. Budget comparison finds two cost-20 plans with accepted operating points across all three scenarios. Costs are synthetic units, not money. The capability returns the actual violation magnitude and residuals, alongside an explicit unresolved state when a check cannot be trusted.

## Live API

- **API base:** https://bestdeeplearning-grid-witness.hf.space/v1
- **Health:** https://bestdeeplearning-grid-witness.hf.space/health
- **Authentication:** none, no reviewer secrets.
- **Limits:** six integer bits or integer budget 0–27, 2048-byte JSON request limit. Bounded 64-plan catalogue. No dedicated per-user rate limiter; hosting platform limits and cold starts apply; no SLA.
- **Contract:** source/README.md; `POST /v1/inspect-plan`, `POST /v1/compare-budget`, `GET /v1/benchmark`. Invalid input returns HTTP 400; unknown routes return 404.
- **Demo:** https://bestdeeplearning-grid-witness.hf.space/

## Source and reproducibility

- **Repository:** https://github.com/alexsolonsky/grid-witness
- **Review commit:** `9102fa95b06ec90b43d7c8dc397e2a03fbd0bf35`
- **Complete reviewed source:** source/
- **Tests:** `cd source && python -m pip install -r requirements-test.txt && python -m unittest discover -v` (16 tests).
- **Run locally:** install Gradio 6.27.0 and spaces in addition to requirements.txt; set SOURCE_COMMIT to the reviewed SHA; `python app.py`.
- **Deploy:** public Hugging Face Gradio Space with README configuration, free ZeroGPU allocation; set public variable SOURCE_COMMIT and upload reviewed files. All grid work uses CPU; optional one-second scheduler diagnostics satisfy the free-hosting runtime requirement. No paid hardware or external model API.
- **Version binding:** health and same-origin proof expose the public deployment SHA. Verification additionally compares all uploaded source file SHA-256 hashes against GitHub at that commit; self-reported health alone is not proof of provenance.

The classical benchmark predates the API packaging, and is identified in BENCHMARK.md. The full catalogue and all 512 encoded surrogate states are exhaustively checked; no quantum computation was performed. The original baseline has not been represented as a newly invented numerical method.

## Verification

See verification/README.md for exact commands, recorded responses and expected errors. The live API must match the declared commit before submission.

## Security and data

- **Collected:** only user-supplied binary upgrade decisions or a bounded budget for the fixed example.
- **Purpose/retention:** calculations in memory; no application database, input/output logs or stored run history. The hosting provider may retain platform access logs.
- **Third parties:** Hugging Face hosting and Gradio runtime/assets. Scientific computation has no outbound requests, model calls or paid API dependencies.
- **Secrets:** none needed or included.
- **Restrictions:** no real network or personal data should be sent. Numerical limitations are explicit in API output and README. HTTP API and numerical solver have validation tests; no claim of a production security audit.

## Support

- **Builder:** Alex SOLONSKY / Aleksei Solonskii.
- **Contact:** https://github.com/alexsolonsky/grid-witness/issues
- **License:** MIT; dependencies retain their licenses. See RIGHTS.md.
- **Registration:** Luma registration confirmed on 2026-09-12. The submitter confirmed joining the official X-Agent Telegram community on 2026-09-12.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
.venv/
.env
results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Synthetic classical grid-reinforcement protocol

Executed local infrastructure prototype, 12 September 2026. **This is not an E.ON benchmark, contest submission, quantum algorithm or demonstration of quantum advantage.** The sponsor's full brief remains unavailable. The instance and voltage limit are deliberately crafted to make a tiny linear screening model reducible to an exactly checkable binary constraint and expose disagreement with AC validation.

## Reproduce

Python 3, standard library only; no packages, accounts, payment or network access required. From this directory:

```sh
python3 -m unittest discover -s . -p 'test_*.py' -v
python3 benchmark.py
```

The second command overwrites `results.json` with the complete 64-plan × 3-scenario catalogue, specification, source hash, A/B/C references and runtime. `verification.json` records the validation run supplied with this version. Results are deterministic except runtime; Python version and source SHA-256 are recorded. Runtime is local bookkeeping, not a comparison with any competing algorithm.

## Model

Six existing edges form radial chain 0–1–2–3–4–5–6. Slack voltage is 1+0j. Every other bus consumes constant complex power 0.08+j0.04 per unit times a design load scale of 0.6, 1.0 or 1.2. Each binary investment halves its edge impedance from 0.01+j0.006 to 0.005+j0.003; ampacity remains 1 per unit. Costs `[7,6,5,4,3,2]` are arbitrary units, **not euros**. Voltage magnitude limits are the square roots of 0.966304 and 1.1025. No physical base MVA or kV is selected, so no physical grid capacity claim is possible.

**A — exact finite lossless reference.** Rational LinDistFlow squared voltages include active and reactive flows but omit line losses. The current screening proxy is apparent power magnitude at assumed 1-per-unit voltage. Positive demand and radial-chain topology make the terminal bus and maximum scale binding for voltage. With investment bits `x`, the terminal squared voltage at scale 1.2 is exactly:

```
0.947584 + 0.001248 * (6*x0 + 5*x1 + 4*x2 + 3*x3 + 2*x4 + x5)
```

Thus the constructed limit is equivalent to weighted investment sum ≥15. Upper voltage and proxy thermal constraints do not bind on this instance. All 64 complete linear checks are compared against this reduced predicate, rather than assuming the reduction generalizes.

**B — numerical AC acceptance catalogue.** A backward/forward sweep solves the balanced single-phase equivalent. The independent residual calculation derives branch currents from voltage differences and impedance, then checks complex nodal power balance, nodal current balance, fixed slack voltage, voltage limits and ampacity. Flat initialization, no fallback, 500-iteration cap; voltage-change tolerance `1e-12`, absolute residual tolerance `1e-9`, floating limit tolerance `1e-10` per unit. Nonconvergence, invalid voltages or failed residuals are `unresolved`; a returned solution beyond limits is `returned_operating_point_violates_limits`. Neither status proves physical infeasibility. No external power-flow implementation or uniqueness certificate was used.

**C — complete integer QUBO reference.** Nine variables comprise six investments plus three slack bits. Enumerate all 512 states of:

```
C(x) + 28 * (6*x0 + 5*x1 + 4*x2 + 3*x3 + 2*x4 + x5 - 15 - s)^2
s = y0 + 2*y1 + 4*y2
```

Maximum feasible excess is 6, within the slack range 0–7. The penalty 28 exceeds total investment cost 27, and every nonzero integer residual incurs at least 28. A zero-penalty feasible solution exists. Expanded linear/quadratic energies are checked against the squared form for every state; projection over slack bits is checked for every investment vector. This encoding is valid only for A on this particular instance; it does not encode AC physics.

## Measured result

| Reference | Evaluated | Accepted plans | Reference cost |
|---|---:|---:|---:|
| A, exact specified lossless model | 64 plans | 14 | 18 |
| B, declared AC procedure | 192 plan/scenario checks | 10 | 20 |
| C, complete QUBO enumeration | 512 bit states | — | Minimum energy 18 |

A's sole minimum plan is `[1,1,1,0,0,0]`. B's best accepted plans are `[1,1,0,1,1,0]` and `[1,1,1,0,0,1]`. Four A-accepted plans fail the AC limit predicate. All 192 AC checks converged and passed residual checks on this run; zero were unresolved. **Cost 20 is the lowest cost accepted by this numerical procedure, not a certified global AC optimum.** The small crafted example supports only the need to keep the three references distinct.

## Validation evidence

Eight tests passed. They cover a zero-load feeder; a one-edge closed-form high-voltage solution; independent complex-power conservation including losses on all 192 cases; forced nonconvergence; deliberately corrupted voltages and incorrect slack; zero/NaN/infinite voltages; exhaustive QUBO expansion and slack projection; and catalogue/reference counts. Inspection revealed the validator originally omitted fixed-slack residuals and could divide by zero on failed voltage vectors. Both were corrected before recording this result.

## Limits and next work

No renewable-generation, held-out stress, contingency, unbalanced, meshed, topology-changing or dispatch scenarios; no cost uncertainty, physical unit calibration or sponsor dataset. No matching optimization-package cross-check, independently implemented external AC solver, heuristic comparison, QAOA simulator, quantum hardware or resource advantage. All scenarios are design scenarios, not unseen validation data. Full enumeration is reference construction, not an efficient search method. Tuning this instance's limit to expose screening error does not estimate real-world failure frequency.

This is only a reproducible foundation for the proposal's A/B/C protocol. Read the actual sponsor brief before adapting scope. Next technical milestones are an external electrical cross-check and fixed, separate design/stress instances, followed by equal-budget classical comparisons; only then is a quantum sampler comparison meaningful.
21 changes: 21 additions & 0 deletions submissions/mcp-hackathon/solonsky-grid-witness/source/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Aleksei Solonskii

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
65 changes: 65 additions & 0 deletions submissions/mcp-hackathon/solonsky-grid-witness/source/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: Grid Witness
emoji: 🔎
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: 6.27.0
app_file: app.py
python_version: 3.12
license: mit
---
# Grid Witness

A deterministic capability for an AI agent to challenge an optimistic grid-upgrade plan with numerical evidence. It compares exact rational lossless LinDistFlow screening against a backward/forward-sweep AC operating point and independently recomputed current, power, slack and limit residuals.

**Scope:** one fixed synthetic six-line radial chain, three load levels, 64 upgrade plans. Not real network data, not E.ON technology, not a quantum algorithm or an industrial engineering certificate. A returned operating point violating a limit is not a proof that all AC solutions are infeasible.

## Try the counterexample

Send `{"bits":[1,1,1,0,0,0]}` to `POST /v1/inspect-plan`. The cost-18 plan passes the lossless screen but its AC operating point violates the minimum-voltage limit at scale 1.2. `POST /v1/compare-budget` with `{"budget":20}` finds two cost-20 plans whose computed operating points pass all three scenarios. Budget 19 finds none. These are arbitrary synthetic cost units, not EUR or USD.

## API

- `GET /health`: versioned service health (503 if SOURCE_COMMIT not a 40-character SHA).
- `GET /.well-known/xagent-verification.json`: submission slug and same review commit.
- `GET /v1/benchmark`: full specification, summary and limitations.
- `POST /v1/inspect-plan`: exactly one `bits` field with six integer binary values. Booleans, strings, floats and extra fields are rejected.
- `POST /v1/compare-budget`: exactly one integer `budget` from 0 to 27.

POST requests require `application/json` and at most 2048 bytes. Invalid requests return HTTP 400 and a stable `invalid_request` error. Unknown routes return 404. Calls enumerate a bounded catalogue cached in memory; no unconstrained network input, arbitrary execution or model calls. No dedicated service-level rate limit; hosting provider limits and cold starts apply. Request concurrency is handled by Gradio/FastAPI; returned data is copied to prevent cache mutation. No availability SLA.

## Reproduce

Python 3.12+:

```sh
python -m venv .venv
.venv/bin/pip install -r requirements-test.txt
.venv/bin/python -m unittest discover -v
.venv/bin/python benchmark.py
```

`requirements-test.lock` records the locally tested dependency set. The numerical benchmark itself uses only the Python standard library. Sixteen tests cover the closed-form one-line case, power conservation, independent residual checks, nonconvergence, all 64 plan outputs and 512 encoded surrogate states, API validation and cost boundaries.

For the Gradio demo, install `gradio==6.27.0` and `spaces` in addition to `requirements.txt`, then set `SOURCE_COMMIT` to the source commit and run `python app.py`. On Hugging Face Spaces the platform supplies Gradio and spaces; do not add conflicting pins to requirements.txt.

## Deploy

Create a public Gradio Space on a free ZeroGPU allocation, set its **public variable** SOURCE_COMMIT to the reviewed GitHub SHA, and upload exactly that commit's files with `hf upload NAMESPACE/SPACE . --type space`. No secrets are needed. The optional hosting diagnostics handler declares a one-second ZeroGPU scheduler probe to meet free-tier hosting requirements; **all grid calculations run on CPU** and never allocate a GPU. CPU Basic creation currently requires a paid Hugging Face plan, so no paid hardware was selected.

The commit is provided at deployment rather than embedded in its own source. Verify the deployed files against the review commit as well as checking health/proof. Source commit changes require updating the deployment variable and archiving fresh verification evidence.

## Mathematical model and provenance

Adapted from a synthetic classical demonstrator prepared for Alex SOLONSKY before this hackathon API. `benchmark.py` preserves that original model. It includes an exhaustively verified QUBO encoding only to check its equivalence to the lossless surrogate; no quantum computation is performed. Grid Witness adds the HTTP/agent capability, strict validation, bounded-budget comparison, UI and API tests.

Bus 0 is 1+0j slack; edges 0–1 through 5–6 have impedance 0.01+j0.006 p.u. Upgrade bits halve impedance without changing ampacity 1 p.u. Six constant PQ loads are 0.08+j0.04 p.u., multiplied by 0.6, 1, 1.2. Squared voltage bounds are 966304/1000000 and 11025/10000. Costs are [7,6,5,4,3,2]. No renewable uncertainty, contingencies, phase unbalance, topology control, independent external solver, AC uniqueness/global optimum proof or quantum advantage claim.

## Privacy and third parties

Only six binary decisions or an integer budget enter the capability. Inputs and outputs are not saved by the application; no database, uploads, analytics, LLM calls or outbound requests occur during scientific computation. Hugging Face serves the app and may keep platform access logs. Gradio assets/runtime and its optional hosting diagnostics contact the platform. Do not send personal or operational network data.

Source: MIT. Dependencies: FastAPI MIT, Starlette BSD-3-Clause, Pydantic MIT, Uvicorn BSD-3-Clause, Gradio Apache-2.0, Hugging Face spaces Apache-2.0, HTTPX BSD-3-Clause (test only). See package distributions for complete transitive notices. No pretrained models or external datasets.

Builder: Alex SOLONSKY (Aleksei Solonskii). Support: open an issue in this repository. No connection to the cancelled EvidenceDesk project or private Life CP code.
Loading