Skip to content

Add ARE Spectacle v2 runtime: core engine, services, storage, API, and tests#1

Open
clairetech2025-max wants to merge 2 commits into
mainfrom
codex/refactor-are-spectacle-v2-architecture
Open

Add ARE Spectacle v2 runtime: core engine, services, storage, API, and tests#1
clairetech2025-max wants to merge 2 commits into
mainfrom
codex/refactor-are-spectacle-v2-architecture

Conversation

@clairetech2025-max

Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a complete local, governed append-only memory runtime with deterministic intent classification, lane routing, governance controls, TrailLink provenance, and durable SQLite-backed storage.

Description

  • Add the TurnEngine pipeline (app/core/turn_engine.py) implementing prepare/execute/finalize stages and integrating classifiers, routers, recall, relevance, planner, visor/rail builders, governance (Sentinel/Lycanthrope), write barrier, and TrailLink edge creation.
  • Implement a suite of services under app/services/ (intent classifier, lane router, recall, relevance gate, answer planner, contradiction checker, gyro ARE, sentinel, lycanthrope, traillink, visor builder, intake/scrub/parser, write barrier, recognition rail) used by the engine.
  • Provide durable storage via app/storage/sqlite_store.py with schema creation and methods for durable_records, trail_edges, session_events, and session_state, plus SessionStore and GravelStore helpers, and tracing via app/tracing/veritas.py.
  • Expose a FastAPI app (app/main.py and app/api/routes.py) with endpoints (/health, /ingest, /query, /gyro, /prompt-prefix, /trace/{id}, /report/{id}), add README.md and .gitignore, and include unit tests in tests/test_turn_flow.py with a conftest path shim.

Testing

  • Ran pytest -q against tests/test_turn_flow.py which exercises classification, lane routing, recall and end-to-end TurnEngine behavior using ephemeral SQLite via tmp_path.
  • All tests in tests/test_turn_flow.py (4 tests) passed.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7b7a11e50c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/services/write_barrier.py Outdated
Comment on lines +15 to +17
for record in records:
self.store.append_record(record)
committed.append(record.record_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Wrap multi-record writes in a single transaction

WriteBarrier.commit persists each record independently, and SQLiteStore.append_record uses its own connection/transaction per call, so a failure on a later insert leaves earlier inserts committed. In a finalize batch this creates partial turns (for example, only some of the expected durable records exist), which breaks the write-barrier all-or-nothing behavior and can leave provenance/session state inconsistent. Commit the whole batch in one transaction (or roll back on error) instead of per-record commits.

Useful? React with 👍 / 👎.

Comment thread app/api/routes.py Outdated
@router.post("/prompt-prefix")
def prompt_prefix(body: QueryBody) -> dict:
result = engine.run_query(QueryRequest(query=body.query, session_id=body.session_id))
return {"trace_id": result["trace_id"], "visor": result["trace"]["events"][-2]}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Return the execute payload in /prompt-prefix

This endpoint returns events[-2] as visor, but in TurnEngine.run_query the event order is prepare_turn, execute_turn, governance, finalize_turn, so -2 is the governance event rather than prompt-context data. Clients calling /prompt-prefix therefore receive policy/posture metadata instead of the expected prefix/visor payload and will construct incorrect prompts.

Useful? React with 👍 / 👎.

@Blackstormhorse2

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants