Skip to content

feat(overseer): event_attention sidecar + principal/namespace - #114

Open
heavygee wants to merge 2 commits into
feat/overseer-converse-focusfrom
feat/overseer-rfc-v2-align
Open

feat(overseer): event_attention sidecar + principal/namespace#114
heavygee wants to merge 2 commits into
feat/overseer-converse-focusfrom
feat/overseer-rfc-v2-align

Conversation

@heavygee

@heavygee heavygee commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fork-local event_attention sidecar for the attention triad (sparse INSERT OR IGNORE backfill, logged parity check, reads via LEFT JOIN/COALESCE, stop writing legacy events.attention_* columns; do not DROP them on the live table).
  • namespace + structured principal_json on every event write; refuse non-human principals with no resolvable human owner (day-one kill criterion). Multi-user claims still gated on isolation tests - we are not claiming that yet.
  • Privileged-reader discipline: ledger text may order/present only; write tools still need a fresh hub grant (allowWrites / conversational focus). System prompt + write-auth test encode salience ≠ authority.

Stacked on #113 (feat/overseer-converse-focus). RFC: Discussion #1332 / B7 fork attention out of upstream RFC.

Test plan

  • bun test hub/src/store/eventAttention.test.ts
  • bun test shared/src/eventPrincipal.test.ts shared/src/overseerWriteIntent.test.ts
  • bun test hub/src/sync/overseerEntity.test.ts (incl. namespace isolation)
  • hub tsc --noEmit
  • Boot against live :3006 DB copy or remat: confirm parity log mismatches: 0 and ~3.2k sidecar rows from ~5.3k events
  • Converse write still requires focus/allowWrites; poisoned work-ad summary does not unlock ping

Made with Cursor

heavygee and others added 2 commits August 4, 2026 19:30
Move attention triad to fork-local event_attention (sparse backfill, parity
check, stop writing legacy columns). Record namespace + structured principal
on every write; refuse non-human principals without a human owner. Encode
salience≠authority for privileged overseer reads (fresh hub grant only).

Co-authored-by: Cursor <cursoragent@cursor.com>
Parse stays lenient (historical/foreign rows); serialize omits the field so
unvalidated pointers never accumulate. Parse/isValidGrantingEventId require
a positive integer PK candidate (not Number.isFinite).

Co-authored-by: Cursor <cursoragent@cursor.com>

@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: 078c2530be

ℹ️ 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 hub/src/store/events.ts
);
CREATE INDEX IF NOT EXISTS idx_events_session_ts ON events(related_session_id, ts DESC);
CREATE INDEX IF NOT EXISTS idx_events_type_ts ON events(event_type, ts DESC);
CREATE INDEX IF NOT EXISTS idx_events_namespace_ts ON events(namespace, ts DESC);

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 Add tenancy columns before creating their index

When an existing installation opens a database created by the parent schema, events has no namespace column, and CREATE TABLE IF NOT EXISTS does not add it. This index statement therefore raises no such column: namespace before ensureEventsTenancyColumns() can run, preventing the hub from starting on every such upgrade. Move the guarded ALTER TABLE calls before any DDL that references the new columns.

Useful? React with 👍 / 👎.

Comment thread hub/src/store/events.ts
Comment on lines 355 to +356
const id = Number(result.lastInsertRowid)
upsertEventAttention(db, 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.

P2 Badge Make event and attention writes atomic

If the process exits or the sidecar statement fails after the events insert commits but before this call completes, the event remains permanently non-salient: its legacy flags were deliberately written as zero, startup backfill cannot reconstruct them, and an idempotent retry returns the existing row without repairing the sidecar. Wrap the base insert and sidecar upsert in one database transaction so attention events cannot silently become zero-flag events.

Useful? React with 👍 / 👎.

Comment thread hub/src/store/events.ts
Comment on lines +468 to +470
if (options.namespace) {
clauses.push("COALESCE(e.namespace, 'default') = ?")
params.push(options.namespace)

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 Preserve legacy events for non-default namespaces

On an upgraded database, all historical events have namespace = NULL; this predicate classifies every such row as default, so an Overseer for any non-default namespace loses its entire historical event stream even when related_session_id identifies one of its sessions. It also prevents the subsequent eventInCallerScope() legacy fallback from ever inspecting those rows. Allow NULL rows through for related-session scope checking, or backfill their namespace from the referenced session.

Useful? React with 👍 / 👎.

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