Skip to content

Add typed per-space ports for folders and people - #24800

Merged
Git-on-my-level merged 16 commits into
mainfrom
pgf/a1-ports-folders-people
Nov 7, 2026
Merged

Git-on-my-level merged 16 commits into
mainfrom
pgf/a1-ports-folders-people

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Requested by David

What changed and why

Add typed folder/People preference ports, a Firestore per-space unit of work, and an independent simulation reference adapter. Preserve the application entry points, folder query/index shapes, rehome batches and People retry boundaries while adding dormant revision and mutation-replay seams.

Fix round 1 applies the lead-authorized missed caller and fixture migrations. The people-create route converts its storage entity to an explicit mapping before FastAPI response serialization; HTTP regression tests cover fresh and racing creates. Both Firestore delete/rehome paths and the simulation now stamp folder_user_set=True, per the lead ruling. The conformance matrix starts with unset/false markers and covers UoW/chunked deletion with/without a default folder.

Product invariants affected

none

How it was verified

Offline synthetic tests and an anonymous loopback Firestore emulator; no production customer-data access or GCP tier used. Tests unset GOOGLE_APPLICATION_CREDENTIALS and all CLOUDSDK_* variables.

  • Focused handoff suite: 230 passed across 17 files.
  • Domain conformance: 44 passed with sim and Firestore both required; no skips.
  • Existing folder-delete contention proof: 9 passed.
  • Full backend contract: in flight; environment checks passed and typecheck has 0 errors. Final counts will replace this line before commit.
  • Explicit keep-going root preflight: 40 passed / 3 failed / 0 skipped for time. The Firestore guard, runtime source/dependency closures for 19 images, async scan and import/module-isolation checks passed.
  • Preflight remains red: (1) four offline dev-harness route-policy entries are missing, reproduced identically on clean origin/main 876abc7; (2) upstream M9 and A1 both added .agent-artifacts/pgf-result.md, causing a synthetic-merge add/add conflict; (3) the intentionally dormant SpaceStore requires a dead-code allowance, but .github edits are forbidden. See the Fix round 1 handoff for exact evidence and commands.
  • Earlier app-client OpenAPI export was byte-identical and compatible; the fix changes response conversion, not the schema.

Postgres domain conformance waits for B1, as the brief requires. No workflow, jobstore, cell/directory or dependency change is included.

People writer audit: only database/people.py moved. Pin stages its revision/person/generation changes together and leaves person/generation unchanged on a same-value pin. Create-by-name reads all exact-name matches, returns existing projected People without a generation bump, and stages the required generation bump with a new person. Standalone learning projection remains outside the contention retry loop. The writer inventory is regenerated; non-ported writers/helpers are unchanged.

Storage/cost deltas: creation now atomically bumps People generation (the required fence-parity rule); folder PATCH adds one point read to select the legacy revision increment. Delete/rehome now stamps the explicit-choice marker, as authorized by the lead.

Blind folder metadata revisions increment by two: legacy reads expose token one, while Firestore initializes an absent numeric field from zero, so Increment(1) would reuse token one. Stamped read/CAS writes increment by one. Replay after a created folder is deleted conflicts instead of recreating it.

Tests

The domain suite covers CRUD/types/extra fields, malformed storage, keyset paging after cursor deletion and interleaved inserts, byte-order ties, CAS, mutation replay, rollback/composition, generation contention, delete/rehome, assignment counts, offset/deletion quirks and system initialization. Unit guards cover signatures/purity, transaction read ordering, retained module recipes, actual repository query recipes and observed query helpers.

Query ownership is registered on the repository methods. The original module-entry recipes remain in PORT_CALLER_DRIVERS and execute in the port surface suite; no query is skipped to accommodate the refactor.

UI evidence

UI-Evidence: none -- backend only

Failure class (fixes)

Failure-Class: none

New guards (only when adding a check or ratchet)

The parity/purity tests are contract coverage for the shared port primitive itself, rather than an incident-specific ratchet or new workflow. Existing index-guard mechanics remain intact.

Scoped cleanups (optional)

Use call-time/injected Firestore clients and typed entity attributes throughout the listed callers. Preserve lenient storage reads and strict wire validation, including unset-versus-null folder patches.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

@Git-on-my-level Git-on-my-level self-assigned this Nov 6, 2026

@cubic-dev-ai cubic-dev-ai 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.

15 issues found across 39 files

Confidence score: 2/5

  • space_store.py and people.py can run the learning projection outside the outer Firestore transaction—or open a nested ledger transaction—so a failed UoW can leave ledger and person-pointer state out of sync. Keep the projection within the same transaction boundary.
  • people.py and domain_sim/store.py handle malformed legacy revisions inconsistently with the CAS contract, so valid mutations can return a misleading revision or be rejected. Normalize non-integer revisions to 1 before checking or incrementing.
  • folders.py increments an existing revision by 2 when refresh_conversation_count receives expected_revision, which can invalidate the caller’s next CAS. Increment it once.
  • people_generation_writers.json has fingerprints that do not match the current implementations, so the inventory validation command fails. Regenerate the fingerprints.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/tests/unit/test_folder_update_missing_doc_guard.py">

<violation number="1" location="backend/tests/unit/test_folder_update_missing_doc_guard.py:3">
P2: This import runs before the test adds `backend/` to `sys.path`, so direct repository-root test invocations fail during collection with `ModuleNotFoundError`. Move the `FolderUpdate` import below the path bootstrap.</violation>
</file>

<file name="backend/docs/people-generation-writers.json">

<violation number="1" location="backend/docs/people-generation-writers.json:8">
P2: These newly added fingerprints do not match the current People implementations, so `python3 backend/scripts/people_generation_inventory.py` fails and the writer-audit inventory cannot validate this revision. Regenerate the manifest from the checked-out source after the final code changes.</violation>
</file>

<file name="backend/tests/unit/test_folder_move_deleted_folder.py">

<violation number="1" location="backend/tests/unit/test_folder_move_deleted_folder.py:276">
P3: This assertion does not enforce the new typed update response: `False` also satisfies `is not None`. Assert the returned entity's ID (or its `FolderEntity` type) so an invalid adapter return cannot pass this test.</violation>
</file>

<file name="backend/routers/search.py">

<violation number="1" location="backend/routers/search.py:102">
P2: This changes the overview API's legacy missing-icon fallback from `folder` to the domain default `📁`. Preserve the wire contract by checking whether `icon` was explicitly present before using the entity default, or normalize the entity to the API default.</violation>
</file>

<file name="backend/testing/domain_fixtures.py">

<violation number="1" location="backend/testing/domain_fixtures.py:13">
P2: Remove the four unused imports; Ruff reports them as F401 and the new fixture cannot pass the repository’s targeted lint gate as written.</violation>
</file>

<file name="backend/tests/unit/test_port_surface_parity.py">

<violation number="1" location="backend/tests/unit/test_port_surface_parity.py:35">
P2: This parity test does not verify the `SpaceTx` properties that define the adapter surface. An adapter can lose `space_id`, `folders`, or `people` and still pass this test; add explicit checks for protocol properties and their adapter attributes.</violation>
</file>

<file name="backend/tests/unit/test_folder_conversations_malformed.py">

<violation number="1" location="backend/tests/unit/test_folder_conversations_malformed.py:101">
P2: This module-scope assignment permanently mutates the cached `routers.folders` module, making router tests order-dependent in single-process runs. Load the router through `testing.import_isolation.stub_modules`/`load_module_fresh` inside fixture scope and restore or patch `FolderUpdate` only for the test.</violation>
</file>

<file name="backend/tests/unit/test_folders_safe_deserialization.py">

<violation number="1" location="backend/tests/unit/test_folders_safe_deserialization.py:7">
P2: This new module-scope import extends the deprecated hand-rolled router isolation path and loads a real `database` package before the fake package is installed, leaving collection-order-dependent module state. Migrate this router import to `stub_modules` plus `load_module_fresh` inside a fixture/function, and import the port models within that isolated setup.</violation>
</file>

<file name="backend/database/people.py">

<violation number="1" location="backend/database/people.py:66">
P2: This write chooses the increment from field presence, while `check_port_revision` treats non-int revisions as legacy revision 1. A person with `revision=None` or a string can therefore return revision 2 without reliably storing revision 2; base the transform on `type(person.get('revision')) is int` so malformed and absent revisions both stamp the legacy-safe value.</violation>

<violation number="2" location="backend/database/people.py:81">
P1: The transaction-scoped get-or-create path performs the learning projection inside the outer Firestore transaction. For a person with a `voice_learning_job`, that projection opens and may commit a nested ledger transaction, so the UoW can observe inconsistent snapshots, conflict/retry after the nested commit, or replay ledger side effects; keep projection outside the UoW transaction or make it consume the outer transaction’s snapshot.</violation>
</file>

<file name="backend/database/space_store.py">

<violation number="1" location="backend/database/space_store.py:24">
P1: This transaction-bound People repository still runs the learning projection in a separate Firestore transaction for existing people. A cross-domain UoW can therefore commit ledger/person-pointer changes before its outer body commits, breaking rollback and replay atomicity; make the projection transaction-aware or keep it outside the UoW transaction.</violation>
</file>

<file name="backend/testing/domain_sim/store.py">

<violation number="1" location="backend/testing/domain_sim/store.py:83">
P2: The simulator does not normalize malformed legacy revisions like the Firestore adapter. Normalize non-`int` revisions to `1` before CAS checks and increments, otherwise valid legacy mutations can reject or crash.</violation>

<violation number="2" location="backend/testing/domain_sim/store.py:241">
P2: The simulator crashes on folder conversations missing `created_at`, which are valid document-shaped fixtures. Exclude missing timestamps before sorting so the simulation does not diverge from the Firestore query path.</violation>
</file>

<file name="backend/database/folders.py">

<violation number="1" location="backend/database/folders.py:157">
P2: Folder pagination crashes when a legacy folder has a datetime `order` value. Encode sort values with a type tag and reconstruct them during cursor decoding, or reject unsupported cursor values before generating `next_cursor`.</violation>

<violation number="2" location="backend/database/folders.py:277">
P2: `refresh_conversation_count` skips a revision token when called with `expected_revision`: an existing revision is incremented by 2 instead of 1. Use the single-step increment for stored revisions on the expected-revision path, while retaining the `+2` legacy initialization behavior.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

if existing:
data = project_person_learning(self.space_id, data, firestore_client=self.client)
else:
data, existing = self._get_or_create_raw(draft, mutation_id=mutation_id, project=True)

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: The transaction-scoped get-or-create path performs the learning projection inside the outer Firestore transaction. For a person with a voice_learning_job, that projection opens and may commit a nested ledger transaction, so the UoW can observe inconsistent snapshots, conflict/retry after the nested commit, or replay ledger side effects; keep projection outside the UoW transaction or make it consume the outer transaction’s snapshot.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/database/people.py, line 81:

<comment>The transaction-scoped get-or-create path performs the learning projection inside the outer Firestore transaction. For a person with a `voice_learning_job`, that projection opens and may commit a nested ledger transaction, so the UoW can observe inconsistent snapshots, conflict/retry after the nested commit, or replay ledger side effects; keep projection outside the UoW transaction or make it consume the outer transaction’s snapshot.</comment>

<file context>
@@ -1,65 +1,137 @@
+            if existing:
+                data = project_person_learning(self.space_id, data, firestore_client=self.client)
+        else:
+            data, existing = self._get_or_create_raw(draft, mutation_id=mutation_id, project=True)
+        return PersonEntity.model_construct(**data)
+
</file context>

def __init__(self, space_id: str, client: Any, transaction: Any):
self.space_id = space_id
self.folders = FirestoreFolders(space_id, firestore_client=client, transaction=transaction)
self.people = FirestorePeople(space_id, firestore_client=client, transaction=transaction)

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: This transaction-bound People repository still runs the learning projection in a separate Firestore transaction for existing people. A cross-domain UoW can therefore commit ledger/person-pointer changes before its outer body commits, breaking rollback and replay atomicity; make the projection transaction-aware or keep it outside the UoW transaction.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/database/space_store.py, line 24:

<comment>This transaction-bound People repository still runs the learning projection in a separate Firestore transaction for existing people. A cross-domain UoW can therefore commit ledger/person-pointer changes before its outer body commits, breaking rollback and replay atomicity; make the projection transaction-aware or keep it outside the UoW transaction.</comment>

<file context>
@@ -0,0 +1,46 @@
+    def __init__(self, space_id: str, client: Any, transaction: Any):
+        self.space_id = space_id
+        self.folders = FirestoreFolders(space_id, firestore_client=client, transaction=transaction)
+        self.people = FirestorePeople(space_id, firestore_client=client, transaction=transaction)
+
+
</file context>

@@ -1,5 +1,7 @@
"""Unit tests for TOCTOU NotFound guard in folder update and conversation move operations."""

from database.ports.folders import FolderUpdate

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: This import runs before the test adds backend/ to sys.path, so direct repository-root test invocations fail during collection with ModuleNotFoundError. Move the FolderUpdate import below the path bootstrap.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/unit/test_folder_update_missing_doc_guard.py, line 3:

<comment>This import runs before the test adds `backend/` to `sys.path`, so direct repository-root test invocations fail during collection with `ModuleNotFoundError`. Move the `FolderUpdate` import below the path bootstrap.</comment>

<file context>
@@ -1,5 +1,7 @@
 """Unit tests for TOCTOU NotFound guard in folder update and conversation move operations."""
 
+from database.ports.folders import FolderUpdate
+
 import os
</file context>

"backend/database/people.py:get_or_create_person_by_name": "9442ad8742e2320e7b97953c867fe07e18bafbb83f3bccb0dc4d6b1167c72569",
"backend/database/people.py:set_person_pinned": "07a61bab61f1f89eaa38d4ca25136449d84450f9371f7ee1d47bad2cabc043f6",
"backend/database/people.py:set_person_pinned.apply": "1875c7948f3489fed4f29e1db4b49d3205fad2f103bddcf993fcbe00258dd664",
"backend/database/people.py:FirestorePeople.__init__": "79d88b21d261b62849fa84089fcb3c84156b6b0c54cc5f4576db7599ffc941cd",

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: These newly added fingerprints do not match the current People implementations, so python3 backend/scripts/people_generation_inventory.py fails and the writer-audit inventory cannot validate this revision. Regenerate the manifest from the checked-out source after the final code changes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/docs/people-generation-writers.json, line 8:

<comment>These newly added fingerprints do not match the current People implementations, so `python3 backend/scripts/people_generation_inventory.py` fails and the writer-audit inventory cannot validate this revision. Regenerate the manifest from the checked-out source after the final code changes.</comment>

<file context>
@@ -5,9 +5,10 @@
-  "backend/database/people.py:get_or_create_person_by_name": "9442ad8742e2320e7b97953c867fe07e18bafbb83f3bccb0dc4d6b1167c72569",
-  "backend/database/people.py:set_person_pinned": "07a61bab61f1f89eaa38d4ca25136449d84450f9371f7ee1d47bad2cabc043f6",
-  "backend/database/people.py:set_person_pinned.apply": "1875c7948f3489fed4f29e1db4b49d3205fad2f103bddcf993fcbe00258dd664",
+  "backend/database/people.py:FirestorePeople.__init__": "79d88b21d261b62849fa84089fcb3c84156b6b0c54cc5f4576db7599ffc941cd",
+  "backend/database/people.py:FirestorePeople._get_or_create_raw": "99f63d9cec65cb6d9447444f65dba3138adf0a5cd8090a605439d0280da66f42",
+  "backend/database/people.py:FirestorePeople.read_generation": "59f6f93a535e909f54f3d90138d79e4a694192d08e4447443936cffc14f2b629",
</file context>

Comment thread backend/routers/search.py
color=str(folder.get('color') or '#6B7280'),
id=str(folder.id),
name=str(folder.name),
icon=str(folder.icon or 'folder'),

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: This changes the overview API's legacy missing-icon fallback from folder to the domain default 📁. Preserve the wire contract by checking whether icon was explicitly present before using the entity default, or normalize the entity to the API default.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/routers/search.py, line 102:

<comment>This changes the overview API's legacy missing-icon fallback from `folder` to the domain default `📁`. Preserve the wire contract by checking whether `icon` was explicitly present before using the entity default, or normalize the entity to the API default.</comment>

<file context>
@@ -90,16 +91,16 @@ def count(field: str, fn: Callable[..., int], *args: Any, **kwargs: Any):
-                color=str(folder.get('color') or '#6B7280'),
+                id=str(folder.id),
+                name=str(folder.name),
+                icon=str(folder.icon or 'folder'),
+                color=str(folder.color or '#6B7280'),
                 count=folder_count,
</file context>
Suggested change
icon=str(folder.icon or 'folder'),
icon=str(folder.icon or 'folder') if 'icon' in folder.model_fields_set else 'folder',

self.store.state['receipts'][mutation_id] = (digest, deepcopy(result))

def check(self, entity, entity_id, data, expected_revision):
revision = data.get('revision', 1)

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: The simulator does not normalize malformed legacy revisions like the Firestore adapter. Normalize non-int revisions to 1 before CAS checks and increments, otherwise valid legacy mutations can reject or crash.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/testing/domain_sim/store.py, line 83:

<comment>The simulator does not normalize malformed legacy revisions like the Firestore adapter. Normalize non-`int` revisions to `1` before CAS checks and increments, otherwise valid legacy mutations can reject or crash.</comment>

<file context>
@@ -0,0 +1,358 @@
+            self.store.state['receipts'][mutation_id] = (digest, deepcopy(result))
+
+    def check(self, entity, entity_id, data, expected_revision):
+        revision = data.get('revision', 1)
+        if expected_revision is not None and revision != expected_revision:
+            raise RevisionConflict(self.store.space_id, entity, entity_id, revision)
</file context>
Suggested change
revision = data.get('revision', 1)
revision = data.get('revision', 1)
revision = revision if type(revision) is int else 1

Comment thread backend/testing/domain_sim/store.py Resolved
items = rows if limit is None else rows[:limit]
next_cursor = None
if items and len(items) < len(rows):
next_cursor = base64.urlsafe_b64encode(json.dumps([items[-1].order, items[-1].id]).encode()).decode()

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: Folder pagination crashes when a legacy folder has a datetime order value. Encode sort values with a type tag and reconstruct them during cursor decoding, or reject unsupported cursor values before generating next_cursor.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/database/folders.py, line 157:

<comment>Folder pagination crashes when a legacy folder has a datetime `order` value. Encode sort values with a type tag and reconstruct them during cursor decoding, or reject unsupported cursor values before generating `next_cursor`.</comment>

<file context>
@@ -1,322 +1,542 @@
+        items = rows if limit is None else rows[:limit]
+        next_cursor = None
+        if items and len(items) < len(rows):
+            next_cursor = base64.urlsafe_b64encode(json.dumps([items[-1].order, items[-1].id]).encode()).decode()
+        return Page(items, next_cursor)
+
</file context>

{
'conversation_count': target_count
+ sum(_typed_doc(s).get('discarded') is False for s in snapshots),
'revision': firestore.Increment(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: refresh_conversation_count skips a revision token when called with expected_revision: an existing revision is incremented by 2 instead of 1. Use the single-step increment for stored revisions on the expected-revision path, while retaining the +2 legacy initialization behavior.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/database/folders.py, line 277:

<comment>`refresh_conversation_count` skips a revision token when called with `expected_revision`: an existing revision is incremented by 2 instead of 1. Use the single-step increment for stored revisions on the expected-revision path, while retaining the `+2` legacy initialization behavior.</comment>

<file context>
@@ -1,322 +1,542 @@
+                    {
+                        'conversation_count': target_count
+                        + sum(_typed_doc(s).get('discarded') is False for s in snapshots),
+                        'revision': firestore.Increment(2),
+                    },
+                )
</file context>
Suggested change
'revision': firestore.Increment(2),
'revision': firestore.Increment(1 if expected_revision is not None and current is not None and 'revision' in current.model_fields_set else 2),

FolderUpdate(name=None, color=None, icon=None, order=None, description=None),
)
is True
is not None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: This assertion does not enforce the new typed update response: False also satisfies is not None. Assert the returned entity's ID (or its FolderEntity type) so an invalid adapter return cannot pass this test.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/unit/test_folder_move_deleted_folder.py, line 276:

<comment>This assertion does not enforce the new typed update response: `False` also satisfies `is not None`. Assert the returned entity's ID (or its `FolderEntity` type) so an invalid adapter return cannot pass this test.</comment>

<file context>
@@ -264,14 +266,14 @@ def test_update_folder_db_ignores_null_non_nullable_fields_and_allows_null_descr
+                FolderUpdate(name=None, color=None, icon=None, order=None, description=None),
             )
-            is True
+            is not None
         )
 
</file context>
Suggested change
is not None
.id == 'f1'

@Git-on-my-level
Git-on-my-level merged commit 307b4bc into main Nov 7, 2026
60 checks passed
@Git-on-my-level
Git-on-my-level deleted the pgf/a1-ports-folders-people branch November 7, 2026 09:51
Git-on-my-level added a commit that referenced this pull request Nov 7, 2026
… (A2a) (#24852)

<!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} -->
_Requested by **David**_

## What changed and why

Add typed action-item, goal and workstream ports and Firestore adapters
while retaining existing module signatures and dict/wire results. Move
task writer tickets into explicit unit-of-work commit hooks and
standalone writers, including account erasure and operator scripts.
Outbox-only claims retain their cache version; atomic bulk deletes
reject before staging when the transaction would exceed 500 writes.

A2a only: cell adapters and migrations follow in A2b. No routing,
deployment or flag changes.

## Product invariants affected

- INV-TASK-2: candidate acceptance retains its user-gesture gate and
atomic task/relationship writes.

## How it was verified

Credential-scrubbed backend Python 3.11; no production access or GCP
tier. Focused task fences: 67 passed; sim/emulator conformance: 110
passed; legacy emulator regressions: 12 passed; workflow/query/lifecycle
guards: 2,344 passed; People inventory: 4 passed; selector E2E: 8
passed. OpenAPI is byte-identical to the measured main baseline. Both
44-check repository preflights passed on frozen source.

The full 2,675-file backend run exited 1: 2,672 files passed, 3
failed/timed out (65,636 tests passed, 8 failed, one file timed out).
All three files passed isolated replays: prefetch 18 passed;
Opus-dependent empty capture 68 passed after restoring the installed
native-library lookup path; cross-service deployment audit 26 passed and
3 optional historical replays skipped. No whole-run green is claimed.
Exact commands, outcomes and integration baseline are in
`.agent-artifacts/pgf/a2a-result.md`.

## Tests

Regression coverage checks outbox-only claims versus task writes at
commit, wipe purge tickets, transaction bulk limits including
other-domain writes, standalone chunking, raw external transaction
errors, goal detach and workstream resolve/import fences, and UoW task
commit-context forwarding. Operator tests cover multi-owner migration
batches and task unlocks.

## UI evidence

UI-Evidence: none -- backend only

## Failure class (fixes)

Failure-Class: none

## Scoped cleanups (optional)

The port fence is synchronous; future async task writers must fence
their own commits. The A1 dead-code allowlist addition and A2a removal
are net-zero versus main; this fix round makes no `.github/` edits.
FirestoreActionItems.list() still reads the whole collection and must be
bounded before A2b/W5 serving migration. Redundant post-commit bumps
within one UoW are deferred to A2b.

Scope extensions: fence the historical task migration and soft-cap
operator unlock after the complete writer census found their direct
batch commits.

Line-Count-Exception: backend/database/action_items.py | 1751 -> 2183 |
A2a brief requires typed repositories beside frozen module functions,
with explicit commit hooks and atomic task budget checks.

Line-Count-Exception: backend/database/workstreams.py | 1443 -> 1964 |
A2a brief requires typed repositories beside frozen module functions and
guards for externally owned transactions.

Line-Count-Exception: backend/testing/domain_sim/store.py | 0 -> 1511 |
A2a brief requires independent workflow reference adapters in the
existing simulator.


Long-term data foundation wave A2a (follows #24800). Default-off: no
serving behavior change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/24852?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24852?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24852&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
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