Hackathon project
FORGE — Autonomous Physical Systems Engineer
AI proposes. Physics verifies.
Built for the Meta Global AI Developer Hackathon 2026
An autonomous engineering system that combines AI-powered visual perception, agentic design exploration, and deterministic physics verification to analyze mechanical systems and propose validated improvements.
My role
Solo project. Backend architecture, Meta Model API integration (Muse Spark and SAM 3.1), the deterministic physics engine, the agent loop, tests, the Next.js frontend and deployment.
- backend tests passing
- 277
- Meta models integrated
- 2
- max redesign attempts per run
- 3
- API endpoints, plus /health
- 8
Responsibilities by layer
- API
- Python, FastAPI, Pydantic
- AI
- Meta Model API, Muse Spark (tool calling), SAM 3.1 (component detection), OpenAI Python SDK
- Physics engine
- Pure-Python physics engine (ratio, RPM, direction, constraints)
- Frontend
- Next.js, TypeScript, Vercel
- Testing
- Pytest, Node test runner
How FORGE reaches a verified result
1Observe
SAM 3.1 detects mechanical components in the uploaded image.
2Confirm
The user confirms physical values. Detections alone are never treated as facts.
3Evidence boundary
Only confirmed observations become a physical model; anything else is refused with reasons.
4Propose
For a redesign objective, Muse Spark calls test_gear_design with a candidate.
5Verify
Python computes ratio, RPM and direction; constraint code decides PASS or FAIL.
6Explain
A plain-language explanation is written from the verified evidence.
A verified run from the live demo
- Gears
- 20T → 60T
- Input speed
- 1200 RPM
- Output speed
- 400 RPM
- Gear ratio
- 3 : 1
- Direction
- Reversed
The problem
Language models can describe how a gear train works, but they should not be trusted to calculate its output and call the result correct. A confident wrong number is worse than no number.
FORGE keeps a hard line between the two: AI observes and proposes, deterministic Python computes, and only a deterministic check can mark a result as verified. The initial domain is deliberately narrow: simple gear trains (shafts, external gear meshes, RPM, ratio and rotation direction).
Perception with SAM 3.1
In the Real Image mode, a user uploads a JPEG or PNG of a mechanism. The backend sends it to SAM 3.1 through the Meta Model API and returns the detected components, with SAM's confidence score when it provides one.
Detections are treated as observations, not facts. The user confirms the physical values (for example, tooth counts) before anything is verified.
The evidence boundary
A deterministic builder turns perception output into a physical model, or refuses to. Only CONFIRMED values can cross. OBSERVED, INFERRED and UNRESOLVED values never do, whatever their confidence: confidence is metadata, not verification.
When something is missing, no model is built and every reason comes back as a structured issue. The demo's Uncertain Gear Pair scenario shows this: one tooth count is only inferred, so verification is blocked.
Bounded autonomous redesign
Given an objective such as a maximum output RPM, Muse Spark proposes a candidate design by calling a single tool, test_gear_design, with two tooth counts (10–120) for a fixed two-gear mesh. Input RPM, topology and the constraint are fixed context it cannot change.
The backend runs the physics and the constraint check. A failure goes back to the model as evidence and it may propose again, up to three attempts. Only a deterministic PASS produces a VERIFIED result, even if the model's text claims success.
Deterministic physics engine
Plain Python modules with no AI dependencies: gear ratio, output RPM, output direction after each external mesh, topology compilation from shafts and meshes, and constraint evaluation. Every number in a result traces back to one of these functions.
Explanations grounded in results
After the outcome is final, the backend writes a plain-language engineering explanation from the structured evidence. It is string formatting over values already computed: no extra model call and no effect on the result it describes.
Testing and deployment
The backend suite (277 pytest tests) runs without network access: the Meta clients sit behind small protocols, so tests inject fakes instead of calling the API. Frontend helpers have their own tests with Node's test runner.
The Next.js frontend is deployed on Vercel and calls the FastAPI backend, which is deployed separately with origin-restricted CORS and a health endpoint. The single Meta API key lives only on the backend.
REST API (selected endpoints)
| Method | Path | Purpose | Auth |
|---|---|---|---|
| POST | /api/v1/image-analysis/analyze | Upload an image; SAM 3.1 detects components | Public |
| POST | /api/v1/image-analysis/confirm | Confirm physical facts, then verify with physics | Public |
| POST | /api/v1/forge/autonomous-redesign | Bounded Muse Spark redesign loop | Public |
| POST | /api/v1/forge/analyze | Muse Spark analysis with tool calls | Public |
| POST | /api/v1/pipeline/run-fixture | Full pipeline on a demo scenario | Public |
| POST | /api/v1/perception/build-physical-system | Evidence boundary: perception to physical model | Public |
| POST | /api/v1/experiments/gear-train | Deterministic gear-train experiment | Public |
| POST | /api/v1/experiments/physical-system | Experiment on a compiled physical system | Public |
A small decision in code
The model never decides success. A run is only marked as passing when the physics experiment succeeded and every constraint passed; an error or an empty constraint list is never a pass.
def _is_passing(experiment: ExperimentResult) -> bool:
return (
experiment.status == ExperimentStatus.SUCCESS
and bool(experiment.constraint_results)
and all(constraint_result.passed for constraint_result in experiment.constraint_results)
)Decisions and trade-offs
AI chooses what to test, never the result
Physical numbers only come from named Python tools executed by the backend. There is no code path where model text is accepted as a measurement.
Confidence is not verification
A 99% detection is still an observation. Requiring confirmation costs a step for the user, but it stops a plausible guess from becoming a verified claim.
A narrow, bounded agent
One tool, two integers, three attempts. A small action space makes the agent's behavior easy to test and impossible to drift outside the objective.
Injected model clients
Muse Spark and SAM sit behind protocols, so the full suite runs offline and deterministically, and the AI layer can be swapped without touching the physics.
Current scope
FORGE is a hackathon prototype with a deliberately narrow domain. What it does not do yet:
- Physics covers gear trains only: ratio, RPM and direction; no torque, loads or materials yet
- Autonomous redesign changes the two tooth counts of a fixed two-gear mesh
- Demo Scenarios use hand-authored perception fixtures; the Real Image mode uses SAM 3.1
- No accounts or persistence: each run is independent
