Skip to content

Harden server/sketch runner, prune dead code, add agent docs#4

Merged
vecnode merged 1 commit into
mainfrom
harden-and-document
Jun 28, 2026
Merged

Harden server/sketch runner, prune dead code, add agent docs#4
vecnode merged 1 commit into
mainfrom
harden-and-document

Conversation

@vecnode

@vecnode vecnode commented Jun 28, 2026

Copy link
Copy Markdown
Owner

What & why

Production hardening pass over the app, removal of dead/demo code, and new contributor/agent documentation.

Hardening — src/main.cpp

  • Request-size cap (5 MiB) enforced at the transport layer (set_payload_max_length) and inside the save handler (returns 413 rather than writing unbounded data to disk).
  • Request timeoutsset_read_timeout(10s) / set_write_timeout(30s) so a slow or oversized client can't tie up the loopback server.
  • No internal error leakage/api/save-script previously returned ex.what() to the client; it now logs to stderr and returns a generic message.
  • Charset on responses; explicit loopback-only comment; Asio thread is now joined on the early bind-failure return.

Hardening — public/script.js

  • Tightened the sketch iframe sandbox from allow-scripts allow-same-originallow-scripts. User sketches now run in an opaque origin and cannot reach the local HTTP API, cookies, or storage. p5.js still loads and error reporting via postMessage still works.

Dead code removed

  • Deleted the unused /api/hello endpoint.
  • Removed the Boost.Asio heartbeat that spammed [asio] heartbeat to stdout every 5s. The io_context thread is kept as an idle infrastructure placeholder (per maintainer preference) with an explanatory comment.
  • Replaced the broken build_and_distribute.bat (# To do is not a valid batch comment — it would error if run) with a clean documented stub.

Documentation

  • AGENTS.md — canonical guide: architecture, HTTP route contract, sketch-sandbox + loopback security model, build/run, dependencies, gotchas.
  • CLAUDE.md — points to AGENTS.md plus Claude/Windows-specific notes (kept DRY).
  • README.md — rewritten for production (features, roadmap, prerequisites, build instructions, dependency table, layout, troubleshooting).

Reviewer notes

  • Verified by reconfiguring and building the neo-processing Debug target on Windows/MSVC — compiles and links cleanly, and the re-embedded script.js is included. (The pre-existing build cache pinned an uninstalled Windows SDK; that was environment drift, fixed by reconfigure, unrelated to these edits.)
  • No automated test suite exists; behaviour was verified by build.
  • Do not re-add allow-same-origin to the sketch iframe or change the bind from 127.0.0.1 without a replacement isolation strategy.

🤖 Generated with Claude Code

Server (src/main.cpp):
- Cap request bodies at 5 MiB (transport + handler), add read/write
  timeouts, and stop leaking internal error text to clients.
- Remove the dead /api/hello endpoint and the noisy Asio heartbeat
  (kept the io_context as an idle infra placeholder).
- Join the Asio thread on the early bind-failure return.

Frontend (public/script.js):
- Tighten the sketch iframe sandbox to allow-scripts only (opaque
  origin) so user code can't reach the local API, cookies, or storage.

Tooling/docs:
- Replace the invalid build_and_distribute.bat stub with a clean one.
- Add AGENTS.md and CLAUDE.md describing the architecture, HTTP
  contract, and security model.
- Rewrite README.md for production.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vecnode vecnode merged commit 69bc86f into main Jun 28, 2026
@vecnode vecnode deleted the harden-and-document branch June 28, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant