THE_PROJECT Built the Bouncer Before the Building

A spec-first personal AI agent where the most finished code is a gateway that verifies credentials nothing can yet issue.

9 min read • View on GitHub • More from Prajwal-H-Rao

A wide editorial illustration of a building under construction with scaffolding and open floors, where every doorway is tagged with a small placeholder label. At the entrance stands a fully finished, ornate doorman's gatehouse with a stern uniformed doorman holding a ledger and a stamp, checking a visitor's papers while the unfinished building recedes behind him.
The gate is finished. The building is not. THE_PROJECT's only complete component is the API gateway that guards everything else.
Key Takeaways

Open session-token.ts in the API gateway and the first thing you read is an admission. The gateway holds no signer. It cannot mint a session token. It can only check one.

The service that would issue those tokens, the identity service, is a .gitkeep file. So is the agent runtime, the policy engine, the model gateway, and every domain service. THE_PROJECT has one contributor and one star, and its most carefully written code is a doorman standing in front of an empty building.

// The gateway holds no signer.
// The identity service mints the tokens. This file only verifies them.
//
// Token format:
//   v1.<base64url(JSON claims)>.<base64url(HMAC-SHA256("v1." + payload))>

This is not an oversight. It is a deliberate ordering. The gateway has to be correct before the thing it guards exists, which means it ships untestable end to end. There is no issuer to generate fixtures against. The verifier was written to a spec, not to a running system.

That single line is the whole repo in miniature. Almost nothing runs. The part that does run is the part that says no.

What NOVA Is Meant to Be

THE_PROJECT is the repository name. The product is NOVA, a self-hosted personal AI agent. The README lists the surface it is aiming at: inbox, calendar, tasks, notes, expenses, trips, automations, and resume-driven job discovery.

Three design rules govern it. Local models come first, with Ollama and qwen3.5:2b as the starting target. Every external action passes a policy check, an approval step, and an audit record. Services stay small instead of collapsing into a monolith.

The intended user is a technically capable individual who wants a personal assistant whose data and actions stay under their control. Not a team. Not an enterprise. One person, their own hardware, their own rules.

The Plan Is the Product

The nova/ directory is a monorepo inside the repo, with its own apps/, services/, packages/, infra/, and docs/. In placeholder form it is deliberately wide and shallow. Dozens of .gitkeep files reserve space for services that do not exist yet. A layout checker, check_layout.py, runs in CI to enforce the shape before the code arrives.

The plan is enormous and dated. docs/plan/ holds 22 files, including a claims ledger and a coverage map. The build is split into 11 phases and 390 tasks. changes/ holds roughly 20 dated entries between 2026-10-11 and 2026-10-22, one file per decision or change.

A close-up illustration looking down at an angle onto a drafting table. A large blueprint is divided into eleven numbered bands and hundreds of small ruled boxes, and a small articulated mechanical arm with a pen fills in one box at a time. Beside the blueprint sits a neat stack of dated slips representing the change log, and a magnifying glass rests over a single sheet marked source of truth.
The process is the artifact. A spec declared source of truth, an 11-phase plan, and dated change slips, with a mechanical arm filling the boxes one at a time.

The most interesting artifact is the contract the AI agents work under. AGENTS.md and .opencode/agents/the-project.md define what an agent may do. A graphify skill under .opencode/skills/ gives the tooling a reusable capability. One change entry records tuning the custom primary agent itself, which is a quiet signal that the tooling is being shaped as carefully as the product.

This is what spec-first development looks like when an AI agent is doing the typing. The spec is declared the source of truth. The plan comes before the code. The change log reads like a ship's log. And the reason the gate is the only finished thing is that the gate was specified first.

Inside the Gateway

proxy.ts is the one function that answers every request exactly once, in a fixed order. Next.js 16 renamed the middleware convention to proxy, and this file matches /api/:path*.

The order is the design. Trace resolution runs first, so every answer, including errors, carries trace headers. Then a pre-auth rate limit keyed by address. Then a branch: /api/internal/ goes one way, everything else goes another. Internal requests verify a service JWT. Session requests verify a session token, apply a per-user rate limit, and check CSRF on unsafe methods. Then the request is passed downstream, or it fails closed with a fixed 503.

The request chain in proxy.ts. Every request is answered exactly once, in a fixed order, and the client's context headers are deleted before anything downstream sees them.

The trick sits in the final step. Both pass() and passService() begin by deleting every context header the client might have sent, then re-set only the values the gateway itself verified. A client cannot claim to be a user. It cannot claim a tenant, a channel, or a trace ID. passService also deletes the raw authorization header so the service token never leaks into handler context.

function pass(request, claims) {
  const headers = new Headers(request.headers);
  // WHY: a client must never set the context headers. The proxy owns them.
  headers.delete("x-nova-user-id");
  headers.delete("x-nova-tenant");
  headers.delete("x-nova-channel");
  headers.delete("x-nova-trace-id");
  headers.delete("authorization");
  headers.set("x-nova-user-id", claims.sub);
  // ...set only verified values, then forward
}

The token format is custom and short: v1.<base64url( claims)>.<base64url(HMAC-SHA256)>. The verifier splits it into exactly three parts, checks the version string, and requires canonical base64url by re-encoding and comparing, which blocks malleable encodings where two different strings decode to the same bytes.

The comparison step is the one people get wrong. Both the expected HMAC and the supplied signature are hashed with SHA-256 before timingSafeEqual. Each digest is 32 bytes, so the comparison never throws on a length mismatch and never leaks a length. Then each claim is type-checked, and expiry is enforced. CSRF is bound to a claim inside the session and to the nova_csrf cookie, with an Origin check on the side.

One more decision is worth naming. The internal and session branches split on path, not on credential type. Internal routes never see a session. Human routes never accept a service token as a session. That removes a whole class of confusion before it can be written.

What the Gate Doesn't Do

The honesty in this repo is part of its character, so the gaps deserve the same treatment as the strengths.

The Honest Comparison

Where NOVA sits depends on what you are actually buying. The real bet is local models, an approval gate on every action, an audit record on every action, and data that never leaves your hardware. The price of that bet is visible in the last column.

Where your data livesWho approves actionsAudit trailModel choiceDoes it run today?
Hosted assistants (Google, Microsoft, Apple)Vendor cloudThe vendor's policy, tuned by youPartial, vendor-heldVendor models onlyYes
Open agent frameworks (LangChain, AutoGPT lineage)Wherever you deploy itYou, in code you writeWhatever you buildAny, if you wire itYes
Self-hosted automation suites (n8n, Home Assistant lineage)Your serversYou, per workflowRun logs, if enabledMostly API modelsYes
NOVAYour serversAn approval gate per action, by designAn audit record per action, by designLocal models first (Ollama)No

That last cell is the point. Everything else in the NOVA row is a promise written into a plan. The plan is unusually good. It is still a plan.

What to Watch

A spec this detailed and a gate this careful are a strong start, but they are not the test. The test is the runtime. The interesting question is not whether the gateway can verify a token. It is whether the rest of the system shows up and earns the gate that was built for it.

If the identity service ships, the verifier finally gets an issuer and the whole chain becomes testable end to end. If the runtime ships, NOVA becomes the thing it promised: an agent that asks permission before it acts. That is the one result that would prove the thesis. Everything else is scaffolding, and there is a lot of scaffolding.