Skip to content

Rewrite SPEC.md as a full normative system specification (+ v0.2 production-hardening spec) - #2

Closed
mosesman831 wants to merge 24 commits into
mainfrom
cursor/full-axion-spec-6aaa
Closed

Rewrite SPEC.md as a full normative system specification (+ v0.2 production-hardening spec)#2
mosesman831 wants to merge 24 commits into
mainfrom
cursor/full-axion-spec-6aaa

Conversation

@mosesman831

@mosesman831 mosesman831 commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

What

Replaces the previous high-level SPEC.md (a ~150-line brand/architecture overview) with a complete, normative specification of every aspect of the Axion Worker, written against the actual code in src/, then extends it with a fully specified v0.2 production-hardening milestone and a conformance-invariants appendix. No code changes.

Part 1 — full normative spec of the shipped system (spec 1.0.0)

  • Contracts made explicit for the first time: route evaluation order and exact match rules; the auth resolution algorithm with the upstream header allowlist; the full proxy request lifecycle including which error responses carry x-axion-session; SSE detection, tee semantics, SseLineParser record/field rules, and UTF-8 decoder flush requirements; the background-extraction never-break-the-proxy contract.
  • Lens fully specified: all 13 patterns with their regex sources, types, baselines and capture semantics; the scan → sort → dedupe → confidence → shape pipeline; the additive confidence algorithm with clamp bounds, the 80-char marker window, and worked examples.
  • PolyVerdict fully specified: trigger precedence and the malformed-header fallthrough, the enforce loop step-by-step, request mutation rules, fence-stripping and balanced-span JSON extraction, the supported schema-keyword table, a complete type-coercion matrix, union-type handling, error message formats, the exact retry-hint text, both provider success shapes, and the 422 contract.
  • State layer: DO internal API, storage schema, consistency/ordering guarantees, and the single-key 128 KiB growth ceiling called out as a normative limitation.
  • Operational sections: complete error-handling matrix, security threat model, latency table, numeric-constants table, observability, testing/CI, and a compatibility/versioning policy.
  • Planned layers (§26): concrete non-normative design sketches for Loop, Gate, the belief graph, and semantic PolyVerdict — clearly marked as having no runtime.

Part 2 — v0.2 production-hardening specification (spec 1.1.0, §27)

A new major section specifying the next milestone to implementation precision — normative when built, nothing implemented today. Governed by five explicit rules (default-off, additive-only, invariant-preserving, fail-open on infra / fail-closed on auth, invalid config never breaks requests):

  • Access control: beliefs-API read key with constant-time comparison and dashboard key flow; proxy access keys closing the open-relay gap; admin key + DELETE /api/beliefs/:id.
  • Rate limiting: token-bucket algorithm in a dedicated Durable Object, client identity ladder, fail-open budget, 429 shape, and x-axion-ratelimit-* headers.
  • Storage v2: per-batch keys removing the 128 KiB session ceiling, retention count cap with truncated disclosure, TTL via DO alarms, lazy idempotent v1→v2 migration, and privacy controls (AXION_STORE_RAW_TEXT, x-axion-no-store).
  • Read API v1.1: cursor pagination, since/type/minConfidence filters, O(page) reads.
  • Ops: /healthz; a structured log-event schema with a full event table and redaction rules; Analytics Engine metrics; HMAC-signed webhook export with at-least-once semantics and an OTel attribute mapping.
  • Surface growth: CORS allowlist + preflight; OpenAI Responses and Gemini adapter specs; dashboard v2 (live polling, recent-sessions MRU, offline vendored React, search/export, a11y).
  • Enforce hardening: per-attempt timeout, attempt-count override header, outcome headers, usage aggregation across attempts, schema size cap; plus request body/session-id limits and a consolidated v0.2 route table.

Part 3 — Appendix C: conformance checklist

Twenty testable invariants (I1–I20) of the shipped system — zero-buffering, no Bearer undefined, header allowlist, session-header echo rules, enforce idempotency, DO-id non-leakage, UTF-8/SSE correctness, log redaction, no-invalidation-claims — each cross-referenced to its normative section and suitable as a standing regression test.

Companion doc updates

  • TECHNICAL.md and SPEC-PolyVerdict.md defer to SPEC.md as the normative source; README.md points to it.
  • Existing threat-model and known-constraint entries now cross-reference their specified §27 remediations.

BUILD-SPEC.md remains untouched as the locked product-decision record; the spec is consistent with D1–D8, and §27 explicitly notes that BUILD-SPEC non-goals bind the current build while §27 defines the next milestone's contract.

Open in Web Open in Cursor 

LatticeAG and others added 24 commits June 28, 2026 20:07
- Hero section with centered title, tagline, and by LatticeAG
- shields.io badges: CF Workers, TypeScript, MIT, Open Source
- ASCII architecture diagram showing proxy + 3 layers + belief graph
- Quick start: clone, install, run, configure base_url, deploy
- Three layers table (Lens/Loop/Gate with phase and description)
- Integration examples: Claude Code, Codex, Cursor, Hermes
- Tech stack, roadmap (Phase 1-3), project structure
- Monospace-forward, no emoji, minimal monochrome aesthetic
- Footer: LatticeAG — Agents, together. with GitHub link
- CF Worker proxy with SSE streaming (zero added latency)
- Belief extraction engine (regex patterns: causal, assumption, intention, evidence)
- Durable Object session state (belief DAG in memory)
- React dashboard with LatticeAG dark-theme branding
- Belief timeline with type colors, confidence bars, filters
- wrangler.toml, tsconfig, vitest config, package.json

By LatticeAG — Agents, together.
- README rewritten to match PolyGnosis premium structure
- TECHNICAL.md deep-dive: architecture, data flow, module details, type system
- MIT License added
- Subagent fixes: lens extraction, proxy routes, stream test
- README.md: badge link, clone URL, and footer link now point to LatticeAG/Axion
- TECHNICAL.md: provenance author/GitHub updated to LatticeAG/Axion
- src/dashboard/app.js: footer link updated to LatticeAG/Axion
- package.json: add author=LatticeAG, license=MIT, and repository URL
Spec the highest-priority fixes for OSS deploy of Phase 1 Lens,
with PolyVerdict sequenced as opt-in enforce mode after the observe
path is honest and usable. No runtime code changes yet.

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
All product decisions locked: passthrough auth, flat timeline,
OpenAI+Anthropic adapters, paste-session dashboard, PolyVerdict
opt-in enforce mode (syntax+coerce+retry). Ready to build.

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
Replace the session <select> with a text input + Load button. Prefill
from ?session= query or the axion.sessionId localStorage key on mount.
Rename the 'Wrong beliefs only' filter to 'Low confidence only'
(confidence < 0.4) and guard BeliefCard against missing confidence.

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
Add 'test' (vitest run) and 'check' (tsc --noEmit && vitest run) npm
scripts, a GitHub Actions CI workflow running npm run check on Node 20
for pull_request and push to main, plus .dev.vars.example,
CONTRIBUTING.md, and SECURITY.md. SECURITY documents that the beliefs
API is unauthenticated in Phase 1 and the session id is a capability URL.

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
- Split because-of / because into two patterns (group 1) so causal beliefs
  are extracted from "Because of ..." sentences
- Set evidenceGroup: 1 on all evidence patterns (belief + evidence hold cited text)
- Replace midpoint confidence interpolation with additive delta modifiers,
  clamped to [0.1, 1.0]
- Allow end-of-string as a clause terminator in patterns
- Add thorough extract.test.ts (vitest)

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
…helpers

Implements BUILD-SPEC section 7 (opt-in enforce path):
- schema.ts: zero-dep JSON Schema subset validator + type coercion
  (type/properties/required/items/enum, nested, unknown keywords ignored),
  plus stripMarkdownFences and parseJsonFromAssistant.
- enforce.ts: detectSchemaTrigger (x-axion-schema header + response_format
  json_schema), enforceOnce, OpenAI/Anthropic retry-hint injection,
  MAX_ENFORCE_ATTEMPTS=3, and a pure runEnforceLoop driver.
- types.ts, index.ts: shared types and re-exports.
- schema.test.ts: valid/missing-required/coerce/enum/nested/fence-strip (28 tests).

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
- content.ts: extractOpenAIAssistantText, extractAnthropicAssistantText,
  extractAssistantText (transport-aware dispatcher)
- stream.ts: parseAnthropicSseData, final TextDecoder flush,
  provider-aware tee (backward-compatible openai default)
- providers/: ProviderAdapter interface, openai + anthropic adapters,
  matchProvider registry
- content.test.ts + stream.test.ts coverage

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
DO stores sessionName and returns flat ExtractedBelief[]; extraction
passes sessionId into the lens. Includes pure flatten helpers + tests.

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
Integrate OpenAI + Anthropic observe paths with passthrough auth,
content-normalized Lens extraction, and opt-in PolyVerdict schema
enforcement. Truth-align README/SPEC/TECHNICAL/PLAN with shipped code.

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
…ion-plan-3949

docs: Axion + PolyVerdict production readiness plan
Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
…s to SPEC.md

Co-authored-by: Moses Man <mosesman831@users.noreply.github.com>
@cursor cursor Bot changed the title Rewrite SPEC.md as a full normative system specification Rewrite SPEC.md as a full normative system specification (+ v0.2 production-hardening spec) Jul 16, 2026
@mosesman831
mosesman831 deleted the cursor/full-axion-spec-6aaa branch August 14, 2026 08:38
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.

2 participants