Skip to content

docs(schema): align agent_ownership / agent_sharing / mcp_api_keys DDL with live schema (#770) - #788

Merged
vybe merged 3 commits into
devfrom
AndriiPasternak31/issue-770-plan
May 12, 2026
Merged

docs(schema): align agent_ownership / agent_sharing / mcp_api_keys DDL with live schema (#770)#788
vybe merged 3 commits into
devfrom
AndriiPasternak31/issue-770-plan

Conversation

@AndriiPasternak31

@AndriiPasternak31 AndriiPasternak31 commented May 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Doc-only follow-up to #770. Aligns stale DDL blocks in docs/memory/ to reflect src/backend/db/schema.py's current state. No code changes, no schema changes, no migrations.

The structural schema fix already shipped in #712 (fix(schema): backfill schema.py to match migrations.py reality, merged 2026-05-08). Every "Critical" finding from the scheduled /validate-schema report attached to #770 was already resolved by that PR — verified by tests/unit/test_schema_parity.py (4/4 PASS in origin/dev).

What this PR changes

docs/memory/architecture.md, three DDL blocks:

Table Before After
agent_ownership 4 of ~25 columns documented; owner_id TEXT, agent_name TEXT PRIMARY KEY All 25 columns documented; correct PK / FK shape (id AUTOINCREMENT, agent_name UNIQUE, owner_id INTEGER)
agent_sharing shared_by_id TEXT NOT NULL; missing allow_proactive shared_by_id INTEGER NOT NULL; allow_proactive added
mcp_api_keys Wrong column names (last_used, use_count), wrong type (user_id TEXT); missing description, key_prefix, is_active, agent_name, scope All columns aligned with schema.py:115-131

docs/memory/feature-flows/agent-sharing.md (added in commit d220ee26 after /sync-feature-flows audit):

Table Before After
agent_sharing Missing allow_proactive column allow_proactive INTEGER DEFAULT 0 added

DDL is descriptive, not byte-exact:

  • Doc retains CREATE TABLE, schema.py uses CREATE TABLE IF NOT EXISTS.
  • Doc keeps inline annotations (-- CAPACITY-001, -- #311, -- proactive-toggle (Issue #376)) for human readers — these don't exist in schema.py.

Explicit scope-callout

This PR fixes 3 DDL blocks in architecture.md (named in #770's Informational section) plus 1 sibling DDL block in feature-flows/agent-sharing.md surfaced by /sync-feature-flows. 27 other tables in architecture.md also lack DDL blocks compared to schema.py — out of scope, tracked at #787.

Also out of scope (deferred to follow-up issues):

  • feature-flows/agent-lifecycle.md references a non-existent table agent_mcp_api_keys. Fix requires prose+DDL coordination, not a one-line edit. Will be filed as its own doc-bug issue.
  • feature-flows/autonomy-mode.md shows a partial 10-column agent_ownership DDL — verified intentional (autonomy-scoped); the 10 columns match schema.py exactly.

Follow-ups

  1. Decide DDL duplication strategy: keep architecture.md DDL or link to schema.py #786 (Abilityai/trinity, P3) — Decide DDL duplication strategy: keep architecture.md DDL, link to schema.py, or auto-generate. This PR reinforces duplication; Decide DDL duplication strategy: keep architecture.md DDL or link to schema.py #786 is where the long-term call gets made.
  2. Doc completeness: 27 tables in schema.py lack DDL blocks in architecture.md #787 (Abilityai/trinity, P3) — Doc completeness for the remaining 27 undocumented tables. Blocked on Decide DDL duplication strategy: keep architecture.md DDL or link to schema.py #786.
  3. validate-schema produces false-positive 'critical' findings against already-fixed schema abilities#2 (P1, 2-week SLA, target 2026-05-25) — Fix the /validate-schema skill so it stops auto-filing priority-p1 issues for non-issues. The validator runs on a remote Trinity agent and the skill source lives in abilityai/abilities, so this can't be patched in abilityai/trinity.

A courtesy ping to the vybe remote agent owner (to pause the scheduled run while abilities#2 is open) is in the closing comment on #770.

Verification

$ uv run --with-requirements tests/requirements-test.txt pytest tests/unit/test_schema_parity.py -v
tests/unit/test_schema_parity.py::TestSchemaParity::test_no_missing_tables PASSED
tests/unit/test_schema_parity.py::TestSchemaParity::test_no_missing_columns PASSED
tests/unit/test_schema_parity.py::TestSchemaParity::test_no_missing_indexes PASSED
tests/unit/test_schema_parity.py::TestSchemaParity::test_no_missing_triggers PASSED
======================== 4 passed in 0.26s =========================

Visual diff of every updated block against schema.py lines 67-97 / 99-110 / 115-131 — every column name, type, default, and FK matches (modulo intentional CREATE TABLE vs CREATE TABLE IF NOT EXISTS and retained -- annotations).

Closes

Closes #770 — the structural fix shipped in #712; this PR addresses the named doc drift plus one sibling drift surfaced by /sync-feature-flows.

…L with live schema (#770)

Replaces stale DDL blocks in docs/memory/architecture.md to reflect
src/backend/db/schema.py's current state. The structural schema fix
already landed in #712; this addresses the doc-drift named in #770's
Informational section.

- agent_ownership: 4 → 25 columns documented (CAPACITY-001, TIMEOUT-001,
  RES-001, ROLE-001, BACKLOG-001, FILES-001, avatar, voice, guardrails)
- agent_sharing: shared_by_id type fixed (TEXT → INTEGER), allow_proactive added
- mcp_api_keys: aligned with mcp_keys.py reality (description, key_prefix,
  last_used_at, usage_count, is_active, agent_name, scope; user_id INTEGER)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
AndriiPasternak31 and others added 2 commits May 11, 2026 16:19
Surfaced by /sync-feature-flows audit on PR #788. Same drift class
as the architecture.md fix in c8d6741 — agent-sharing.md's embedded
DDL was missing the allow_proactive column added by Issue #376's
proactive-toggle feature. One-line addition matches schema.py:99-110.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two fixes in the 'Tables' section, surfaced by /sync-feature-flows
+ /validate-pr audit on PR #788:

1. agent_ownership block now signals truncation explicitly (was
   implicitly partial — 4 of ~25 columns with no `...` marker, which
   suggested completeness). Adds caveat pointing to schema.py:67-97 +
   architecture.md for full DDL.

2. agent_mcp_api_keys block renamed to mcp_api_keys. The
   agent_mcp_api_keys table does NOT exist — agent-to-agent
   collaboration uses rows in the single mcp_api_keys table, scoped
   by `scope='agent'` and `agent_name=<this agent>`. The rename_agent()
   method at line 334 already correctly uses `mcp_api_keys` — this
   fixes the inconsistency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — DDL blocks verified against schema.py, clean docs-only change. Merging.

@vybe
vybe merged commit 43f315f into dev May 12, 2026
8 checks passed
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