Skip to content

Photon Platform Promises

Define intent once. Deliver everywhere.

This document defines what Photon promises its users. Every feature, interface, and architectural decision must trace back to one of these promises. If a change doesn't serve a promise, it doesn't belong. If a promise isn't validated, it's just marketing.

Overview

#IntentPromisesAssertionsPriority
1Single File, Full Stack312P0 — Core
2Human + Agent, Same Surface311P0 — Core
3Zero Config312P0 — Core
4Format-Driven Rendering312P1 — Essential
5Stateful by Annotation311P1 — Essential
6Composable28P1 — Essential
7Portable27P2 — Important
8Resilient by Default29P2 — Important
9Secure by Default27P2 — Important
10Standards-Aligned327P2 — Important
Total26116

How to Read This

  • Intents are foundational — they define what Photon is
  • Promises are specific commitments derived from intents
  • Assertions are testable statements that validate each promise
  • Targets indicate where the assertion must hold (CLI, Beam, MCP, Runtime)

How to Use This

  • Adding a feature? — Which promise does it fulfill?
  • Designing an interface? — Which intents does it serve?
  • Reviewing a PR? — Do any promises regress?
  • Planning a release? — Are all core promises validated?

Intent 1: Single File, Full Stack

Write one TypeScript file. Get a CLI app, an MCP server, and a web application.

This is Photon's defining promise. A .photon.ts file is not a library, not a framework plugin, not a config file. It's a complete application expressed as a single class.

P1.1 — One file, three interfaces

A single .photon.ts file produces a working CLI tool, MCP server, and Beam web UI without any additional files, config, or build step.

#AssertionTarget
1Running photon <name> <method> executes the method and prints outputCLI
2Connecting via MCP STDIO lists tools matching public methodsMCP
3Opening Beam shows the photon in the sidebar with all methodsBeam
4The same method returns identical data across all three interfacesAll

P1.2 — No boilerplate

No decorators, no registration, no server setup. A public method is a tool.

#AssertionTarget
1A class with zero imports and one async method works as a photonRuntime
2No tsconfig.json requiredCLI
3No package.json required in photon directoryCLI
4Adding a new method requires only writing the method — no registrationRuntime

P1.3 — TypeScript is the only language

JSDoc annotations are the configuration surface. Types are the schema.

#AssertionTarget
1TypeScript return types generate MCP outputSchema automaticallyMCP
2Parameter types generate form fields in BeamBeam
3JSDoc @param descriptions appear in CLI help and Beam labelsCLI, Beam
4Constraint tags (@min, @max, @pattern) validate on all surfacesAll

Intent 2: Human + Agent, Same Surface

The same code serves humans and AI agents equally. No special agent API, no separate human UI. One method, two audiences.

P2.1 — Methods work for both audiences

Every method is simultaneously a CLI command, an MCP tool, and a Beam action.

#AssertionTarget
1A human can invoke any method via Beam UI without typing JSONBeam
2An agent can invoke the same method via MCP tools/callMCP
3CLI photon <name> <method> --param value works for scripts and humansCLI
4Output is structured data — renderable for humans, parseable for agentsAll

P2.2 — Annotations guide both audiences

@readOnly, @destructive, @locked inform both human UX and agent behavior.

#AssertionTarget
1@readOnly methods show no confirmation in Beam, auto-approve in MCPBeam, MCP
2@destructive methods show confirmation in Beam, flag in MCP schemaBeam, MCP
3@locked serializes access — human and agent wait their turnRuntime
4@auth identifies the caller whether human (OAuth) or agent (Bearer)Runtime

P2.3 — Text-first, always

Every method must work as plain text. Visual rendering is progressive enhancement.

#AssertionTarget
1Every method produces readable output in a terminal (no Beam required)CLI
2@format tags enhance display but the underlying data is always text/JSONAll
3@ui custom HTML is optional — removing it doesn't break the methodBeam

Intent 3: Zero Config

Install and run. No setup wizard, no config files, no environment prep. It works on first contact.

P3.1 — Instant start

From install to working photon in under 60 seconds.

#AssertionTarget
1bun add -g @portel/photonphoton beam shows working UICLI, Beam
2No ~/.photon/ directory required before first runCLI
3Marketplace photons are pre-cached or fast-fetched on first bootBeam
4photon install <name> → immediately usable, no restart neededCLI

P3.2 — Dependencies resolve themselves

npm packages, CLI tools, MCP servers, other photons — all auto-managed.

#AssertionTarget
1@dependencies axios installs axios on first run without user actionRuntime
2@cli ffmpeg blocks loading with clear error if ffmpeg is missingRuntime
3@photon todo auto-installs from marketplace if not presentRuntime
4@mcp slack injects MCP client or null if server unavailableRuntime

P3.3 — Configuration from code, not files

Constructor parameters + environment variables. No .rc files, no YAML.

#AssertionTarget
1Constructor params auto-map to PHOTON_NAME_PARAM env varsRuntime
2Beam shows a settings panel auto-generated from constructor paramsBeam
3apiKey param renders as password field, masked in UIBeam
4Defaults work — a photon with optional params runs without any configAll

Intent 4: Format-Driven Rendering

Annotate your output once. Every target renders it appropriately. One annotation, three surfaces.

P4.1 — Formats render on all targets

Every @format tag must produce correct output on CLI, Beam, and MCP.

#AssertionTarget
1@format table renders as ASCII table in CLI, HTML table in BeamCLI, Beam
2@format markdown renders styled in Beam, formatted in CLICLI, Beam
3@format chart:bar renders interactive chart in Beam, data table in CLICLI, Beam
4Unknown @format falls back gracefully (never silently drops data)All

P4.2 — Auto-UI from signatures

Forms, validation, layouts generated from method signatures and tags.

#AssertionTarget
1A method with number param shows numeric input in BeamBeam
2@min 0 @max 100 enforces range in Beam form AND CLI validationBeam, CLI
3@choice ["a","b","c"] renders dropdown in Beam, validates in CLI/MCPAll
4Optional params show as non-required fields; required params are enforcedAll

P4.3 — Custom UI as progressive layer

@ui HTML replaces auto-generated view but the method still works without it.

#AssertionTarget
1@ui dashboard loads custom HTML from <photon>/ui/dashboard.htmlBeam
2Removing the @ui tag still shows auto-generated result viewBeam
3Custom UI receives theme CSS variables from host (light/dark)Beam
4Same method works identically via CLI and MCP without the UI fileCLI, MCP

Intent 5: Stateful by Annotation

Add @stateful to your class. Get persistence, events, memory, and cross-client sync — no database, no infra, no wiring.

P5.1 — Persistence without infrastructure

State survives restarts. Memory persists across calls. No database required.

#AssertionTarget
1this.memory.set(k, v) persists to disk, survives process restartRuntime
2@stateful class state is isolated per named instanceRuntime
3protected settings = {...} auto-generates settings tool + persistsRuntime
4State works identically whether accessed via CLI, Beam, or MCPAll

P5.2 — Real-time events with zero wiring (CloudEvents 1.0)

this.emit() fires events that reach every connected client automatically.

#AssertionTarget
1this.emit('update', data) reaches Beam UI via SSEBeam
2@stateful methods auto-emit execution events (method, params, result)Runtime
3Multiple Beam tabs see the same state (cross-client sync)Beam
4this.render() pushes live output to both CLI and BeamCLI, Beam

P5.3 — Observable by default

Activity log, audit trail, execution history — automatic for stateful photons.

#AssertionTarget
1Beam shows activity log with timestamped method callsBeam
2Returned objects carry __meta (non-enumerable) with audit dataRuntime
3Execution events include method name, params, result, and timestampRuntime

Intent 6: Composable

Photons call photons. Small, focused tools compose into complex workflows.

P6.1 — Photon-to-photon calls

@photon injects other photons as dependencies. this.call() invokes them.

#AssertionTarget
1@photon todo injects a working todo instance into constructorRuntime
2this.call('todo', 'add', { text }) executes the target methodRuntime
3Transitive @photon deps auto-resolve from same marketplace sourceRuntime
4.on('todo:completed') receives events from composed photonsRuntime

P6.2 — Marketplace as composition layer

Install, compose, extend. The ecosystem is the feature set.

#AssertionTarget
1photon install <name> works from marketplace or GitHubCLI
2Installed photons appear in Beam sidebar immediatelyBeam
3photon search <query> finds relevant photonsCLI
4Private marketplace sources are supported for team-internal photonsCLI

Intent 7: Portable

Build once, run anywhere. Standalone binary, edge deployment, containerized.

P7.1 — Standalone binary

photon build compiles to a single executable. No runtime dependencies.

#AssertionTarget
1photon build <name> produces executable binaryCLI
2Binary runs without Node.js, npm, or Photon installedRuntime
3@dependencies are bundled into the binaryRuntime
4Cross-platform targets: macOS ARM/Intel, Linux x64/ARM64CLI

P7.2 — Deploy anywhere

Same photon deploys to bare metal, Docker, Cloudflare, AWS Lambda.

#AssertionTarget
1Photon works as MCP server in Claude Desktop, ChatGPT, CursorMCP
2Beam serves the web UI with zero additional infrastructureBeam
3Deployment guides exist for Docker, Cloudflare, Lambda, systemdDocs

Intent 8: Resilient by Default

Methods handle failures gracefully. Retry, timeout, circuit break, rate limit — all via annotations, no try/catch boilerplate.

P8.1 — Middleware from annotations (Resilience4j/Polly vocabulary)

Functional tags compose into a Koa-style middleware pipeline with phase ordering.

#AssertionTarget
1@retryable 3 retries failed calls up to 3 timesRuntime
2@timeout 5000 kills execution after 5 secondsRuntime
3@cached 60 memoizes results for 60 secondsRuntime
4@throttled 10/min rate-limits to 10 calls per minuteRuntime
5@circuitBreaker 5 30s fast-rejects after 5 failures, resets after 30sRuntime
6Multiple tags compose: @retryable 3 + @timeout 5000 both applyRuntime

P8.2 — Scheduled and async execution

Background tasks and cron without infrastructure.

#AssertionTarget
1@scheduled 0 * * * * runs method every hourRuntime
2@async returns execution ID immediately, runs in backgroundRuntime
3@webhook exposes method as HTTP endpointRuntime

Intent 9: Secure by Default

Authentication, encryption, and access control are built-in primitives, not afterthoughts.

P9.1 — OAuth without boilerplate (MCP OAuth 2.1 / RFC 9728)

Built-in OAuth 2.1 with PKCE, RFC 9728 Protected Resource Metadata, and transport-agnostic @auth enforcement via elicitation.

#AssertionTarget
1@auth required enforces authentication on the methodRuntime
2this.caller provides authenticated identity (id, name, claims)Runtime
3OAuth tokens auto-refresh with 5-minute bufferRuntime
4Token vault uses AES-256 encryption, per-tenant isolationRuntime

P9.2 — Identity-aware coordination

Locks and permissions know who's calling.

#AssertionTarget
1@locked with @auth assigns lock to specific caller IDRuntime
2Only the lock holder can execute — others get clear "wait" messageRuntime
3Webhook secrets enforce X-Webhook-Secret header validationRuntime

Intent 10: Standards-Aligned

Follow established protocols. Don't reinvent what already works. Adopt standards that enable interoperability without sacrificing simplicity.

Photon's features align with industry standards where they exist, and stay custom only where no standard applies or where the Photon-specific design is genuinely stronger.

P10.1 -- CloudEvents for event emission

@stateful events use the CNCF CloudEvents 1.0 envelope format, making them consumable by any CloudEvents-aware sink (Kafka, EventBridge, NATS).

#AssertionTarget
1@stateful method execution emits specversion: '1.0' in event payloadRuntime
2Events include id, source, type, and time fieldsRuntime
3source follows photon/{name} formatRuntime
4type follows photon.{name}.{method}.executed formatRuntime

P10.2 -- OpenTelemetry for observability

@async execution IDs are valid W3C trace IDs. OTel spans carry photon context.

#AssertionTarget
1@async returns a 32-hex-char trace ID compatible with OTelRuntime
2Response includes _traceparent in W3C format 00-{traceId}-{spanId}-01Runtime
3OTel span attributes include photon.trace_id when async ID is providedRuntime
4OTel span attributes include photon.stateful when the tool is @statefulRuntime
5parseTraceparent accepts valid W3C format and rejects malformed/all-zeroRuntime
6Tool-call telemetry emitted as OTel metrics (photon.tool.duration histogram, photon.tool.calls, photon.tool.errors counters)Runtime
7Request context available via AsyncLocalStorage during tool executionRuntime
8Nested this.call() forwards _meta.traceparent so child spans chain under the parent traceRuntime
9OTel Logs bridge forwards every Logger record when @opentelemetry/api-logs is installed, no-op otherwiseRuntime
10initOtelSdk boots @opentelemetry/sdk-node automatically when OTEL_EXPORTER_OTLP_ENDPOINT is set; no-op otherwiseRuntime
11AG-UI RUN_ERROR events carry code, retryable, runId, threadId so clients can classify and auto-retry failuresRuntime
12AG-UI events include rawEvent.traceparent when emitted inside a request context, correlating UI events to OTel spansRuntime
13MCP initialize advertises experimental['ag-ui'].features (structured-errors, trace-correlation, proxy-mode, local-mode) for capability negotiationRuntime

P10.3 -- Established patterns for resilience, auth, and storage

Middleware follows Resilience4j/Polly vocabulary. Auth follows MCP OAuth 2.1. Memory follows Deno KV minimal surface.

#AssertionTarget
1MemoryBackend interface includes list(prefix?) matching Deno KV surfaceRuntime
2MiddlewareContext includes caller for auth-aware custom middlewareRuntime
3Circuit breaker state is inspectable via /api/health/circuits endpointBeam
10/api/health returns liveness/readiness with per-subsystem status (runtime/photons/circuits) and 503 when any subsystem is degradedBeam
4formatToolError classifies PhotonCircuitOpenError as circuit_open with retryable: trueRuntime
5formatToolError marks ValidationError as non-retryableRuntime
6wrapError preserves the root cause via Error.cause for OTel recordExceptionRuntime
7MCP tool error responses include structuredContent.error with type, retryable, message so agents can make typed retry decisionsRuntime
8formatToolError classifies PhotonRateLimitError as rate_limited with retryable: true and a dedicated photon.rate_limit.rejections counter is emittedRuntime
9@bulkhead N caps concurrent executions per tool at N and throws PhotonBulkheadFullError (classified as bulkhead_full, retryable, counted as photon.bulkhead.rejections)Runtime

Validation

Each assertion maps to one of:

  • Visual — Screenshot + lookout validate() (Beam targets)
  • CLI — Command execution + exit code + output check (CLI targets)
  • MCP — HTTP/STDIO request + response validation (MCP targets)
  • Runtime — Unit/integration test (Runtime targets)

Every assertion in this document must be backed by automation before it is treated as launch-safe.

bun run test:promises validates the current release-gate subset and emits a machine-readable coverage report (promise-report.json) showing which intents are currently exercised by that suite. Assertions outside that subset must be covered by dedicated tests before they should be described as validated.

Promise Priority

PriorityIntentsRelease gate?
P0 — Core1, 2, 3Yes — blocks release
P1 — Essential4, 5, 6Yes — blocks release
P2 — Important7, 8, 9, 10Warning only

Evolution

This document evolves with the platform:

  1. New feature → Must trace to an existing promise or establish a new one
  2. New promise → Must include testable assertions across relevant targets
  3. Broken promise → Either fix the code or explicitly retire the promise
  4. Retired promise → Move to an appendix with rationale

The promises are the stable contract. The implementation changes; the intents endure.

Released under the MIT License.