Skip to content
Source
Sign inSign up
samwillis/neon-glow-demo
Open History to see the last commit

PI_VALIDATION.md

173 lines9.5 KB

Pi on Neon: validation results

This records the original isolated runtime spike. The later application build, separate sandbox project, central package loader, API model proxy, and hosted create/share/remix checks are recorded in implementation.

Checked on 20 November 2026 against an isolated project in the selected personal organization, in AWS Frankfurt. Implementation and repeatable commands are in the spike.

Conclusion

The live coding path passed. Pi ran in-process inside the actual Neon Functions Node 24 runtime and called Claude Sonnet 4.6 through Neon AI Gateway. The model wrote a TypeScript module, then a second independently deployed Function restored its source and full Pi session from Neon and edited the module. Independent behavior checks passed for both versions.

This validates the embedded coding loop, file tools, temporary workspaces, completed-turn session restoration, Postgres, private Object Storage, and a small compilation step. It supports using Pi for the first implementation. It does not yet establish full app generation quality or recovery during an interrupted turn.

The updated sandbox design moves coordination behind App APIs and loads a centrally published agent package from a branch-local bootstrap. The spike used direct credentials for its isolated project's checkpoint database and storage. It proves SDK/runtime compatibility, not the new API/credential boundary, model proxy, sealed-query worker subscription, or runtime package loader.

Verified

CheckResult
RuntimeHosted Node 24.22.1
PiPublished @earendil-works/pi-coding-agent 1.5.2
DeploymentTwo distinct Function deployments, both completed
Endpoint authenticationUnauthenticated request rejected with 401
WorkspaceNew writable temporary workspace per invocation, removed afterward
Live inferenceClaude Sonnet 4.6 through Neon AI Gateway's unified chat route
File toolsModel chose write in the first Function; read and edit in the second
SessionFull Pi session serialized with its active history leaf; 7 entries restored
Durable dataPrivate Object Storage checkpoints referenced from Postgres
Cross-process continuationDifferent Function instance IDs; second source hash matches the first checkpoint
CompilationTypeScript 6.0.3 transpiles the module inside the Function
BehaviorIndependent Node checks pass tap thresholds, unchanged input state, and added reset
Local regression checksSix focused tests passed under Node 24

The live run recorded 3 checkpoints during creation and 5 during restoration and editing. The first task created an angry-potato state module: taps 1–2 stay calm, 3–4 are annoyed, and 5+ are furious. The second added reset while preserving the tap rules. Checks also verified that tapping does not mutate the input state.

Measurements

SampleMeasured worker sectionPeak process RSS
First Function: live generation, write, checkpoint, and compilation5,798 msAbout 226.5 MiB
Second Function: restored live session, read/edit, checkpoint, and compilation5,219 msAbout 224.5 MiB
Earlier offline fixture write and compilation811 msAbout 211 MiB
Earlier offline fixture read/edit and compilation796 msAbout 209 MiB

The live worker sections include model calls; the offline sections do not. These are single samples, not a latency, throughput, or concurrency benchmark. They do not include a rendered player. Peak process RSS is below the documented 2048 MiB Function limit for this small case.

Gateway access and compatibility

The initial request returned 403 with unavailable_reason: paid_plan_required, despite successful model listing. The user added AI Gateway credits to the same account, after which inference access cleared. We did not upgrade the account or purchase credits.

The next request exposed a protocol mismatch: Pi sends OpenAI's store field by default, which this Gateway endpoint rejected with 400 ... store: Extra inputs are not permitted. Setting the model's compat: { supportsStore: false } fixed the request. Both Functions were redeployed with that setting before the passing live run.

The verified Pi provider uses api: "openai-completions", the injected Gateway base URL plus /v1, and model ID claude-sonnet-4-6. Other provider protocols and model features need their own checks.

Packaging and dependency findings

Copying the initial entire dependency tree produced 18,077 files and was rejected by the installed Neon CLI's 4,096-file archive limit. The working package uses @vercel/nft to trace runtime dependencies while preserving package paths and assets. The final deployed archive contains 2,857 files and excludes env files.

The traced deployment imported successfully from a separate temporary directory under Node 24, and the actual deployed checks exercised its Pi, database, storage, and compiler paths. Tracing still reports optional-provider/native-module and OAuth-parser warnings; the raw warnings are retained in ignored local evidence. Additional model protocols or image features require their own exercised checks.

The first install selected TypeScript 7.0.2, whose package did not expose the transpileModule API and compiler enums used here. Pinning TypeScript 6.0.3 fixed the compiler check. A local test now verifies actual typed-source compilation so that this incompatibility is caught before deployment.

Pi itself did not require a CLI subprocess for the tested in-process SDK use. The spike enables only file tools and explicitly disables external resource discovery. It offers no bash tool and accepts no arbitrary user prompt.

Runtime npm check

A separate authenticated Function in the same validation project confirmed that runtime package installation works. On Node 24.22.1, Linux arm64, npm --version returned 11.19.1. The handler created a temporary workspace and package.json, installed the pinned is-number@7.0.0 package from the public npm registry, and successfully loaded and checked it in a child Node process. Installation took 1,999 ms in this sample and created a lockfile. The workspace was removed afterward. Raw source and results are retained under ignored .validation/npm-runtime/ and .validation/npm-runtime-result.json in the spike directory.

The install disabled lifecycle scripts and audit/funding requests. The child received a small explicit environment without injected service credentials. This verifies npm, subprocesses, writable temporary storage, registry access, and pure JavaScript package loading. Native addons, install scripts, realistic application builds, disk capacity, and isolation between untrusted jobs remain unverified. A microVM is per isolate, and an isolate can handle multiple requests; it is not a fresh security boundary per user or coding session. Persist source, lockfiles, and build artifacts externally; local files are disposable.

Repeat the live check

From the repository root, using the existing private configuration:

cd spikes/pi-functions
npm exec --yes --package=node@24 -- node --env-file=.env.local validate.mjs

This uses the already deployed Functions and verifies that:

  1. Pi calls the configured Gateway model and writes the requested toy module.
  2. The first compiled result satisfies the specified tap behavior.
  3. The second Function restores the source and full Pi session.
  4. Pi chooses read/edit tools and adds reset while retaining the original rules.
  5. The edited compiled result satisfies both sets of assertions.

Expect passed: true and liveModelValidated: true. Successful live validation writes ignored .validation/result.json; returned source is in created.json and edited.json in the same directory. The earlier offline probe can be repeated with validate.mjs --probe and writes result-probe.json. That probe invokes tools directly on a maintained fixture and does not validate model generation. Neither mode launches a browser.

Scope still unverified

  • Cancellation and full assistant/tool transcript recovery after an interrupted live model turn; the passed restoration starts from a completed turn.
  • React/game-library bundling, visual quality, touch rendering, and actual native or browser player behavior.
  • Image/audio tooling and its optional runtime assets.
  • Isolation for arbitrary shell commands or generated server code.
  • Multi-tenant concurrency, scheduled job recovery, and long-running resource use.
  • Branch-only coding credentials, App API authorization, and centrally loaded agent packages; these are proposed changes beyond this spike.
  • Restricted coding roles on persistent app branches, live-head updates with preserved gameplay, staging/final-object promotion, context-aware undo, cooperative recovery on the same branch, and per-isolate admission. The plans define these contracts/acceptance cases, not passed results. Branches are created only for explicit forks, not edits or execution attempts.
  • The committed parent-side fork credential barrier, exclusive invocation activation, mixed-version state mutation/receipt protocol, and Postgres-specific admission/cancellation budgets. Their acceptance cases are planned, not executed.

The project, two Pi Functions, the separate npm probe Function, small database, and private checkpoint bucket remain available for inspection. Connection credentials, endpoint secret, cloud IDs, and raw reports are kept in ignored local configuration/evidence files.