3.7 KiB
3.7 KiB
S4.3 — Organization/user repository packet
Date: 2026-08-15 Status: implementation and offline-dialect remediation complete locally; exact-current independent review passed; runtime cutover intentionally not started
Scope
- Added
backend/app/repositories/contracts.pywithOrganizationRepositoryandUserRepositoryProtocols. - Added
backend/app/repositories/sqlalchemy.pywith SQLAlchemy adapters for organization/user CRUD and tenant-scoped user listing. - Added
backend/app/repositories/groups.pywith tenant-scoped group/persona CRUD, org checks before persona creation, and controlled group updates. - Added
backend/app/repositories/sessions.pywith tenant-scoped session/message reads and mutations; message sequence is explicit and database-unique. - Added repository errors for missing entities and immutable/unknown update fields.
- Added
backend/tests/test_repositories.pycovering organization active filtering, updates, user auth-field preservation, tenant scope, duplicate-email rejection, and transaction ownership. - Added
backend/tests/test_group_repositories.pycovering group/persona visibility, cross-org access denial, controlled updates, and cross-org persona-creation rejection. - Added
backend/tests/test_session_repositories.pycovering session/message scope, one-shot uniqueness, message sequence uniqueness, and cross-org mutation denial.
Repositories flush but do not commit. The caller owns the transaction boundary so future services can atomically persist multiple aggregates. JSON stores remain authoritative; no route/factory cutover was made.
TDD evidence
- RED: repository contract test collection failed with
ModuleNotFoundError: app.repositoriesbefore implementation. - First GREEN attempt exposed SQLite timezone metadata normalization; the test now compares the instant after normalizing SQLite’s naive representation while PostgreSQL remains timezone-aware.
- Focused repository tests:
8 passed. - Full backend suite after the cross-tenant lookup and offline-dialect remediations:
209 passed. - Offline Alembic MySQL regression: RED before the shared validator; GREEN after
test_alembic_offline_path_rejects_unsupported_dialectswas added.
Verification
python -m compileall -q app migrations tests: passed.git diff --check: passed.- Repository added-line security scan:
repository_added_line_findings=[]. - No production database, JSON store, credentials, deploy, or live service was touched.
Remaining gates
- Fresh exact-current reviewer
deleg_40e8edf9returned valid five-key JSON withpassed=true, empty blocking arrays, and five non-blocking suggestions afterdeleg_c2e728d8found and the local tree remediated an offline unsupported-dialect path. The prior valid reviewerdeleg_cf56b7d3correctly failed on the now-remediated unscopedUserRepositorylookup. - PostgreSQL execution and repository wiring are not verified.
- JSON importer, parity/count/hash comparison, rollback rehearsal, and runtime cutover remain blocked by later S4 packets.
- Do not delete JSON stores or switch production dependencies until those gates pass.
Independent review verdict
deleg_40e8edf9— valid exact-current review;passed=true;security_concerns=[];logic_errors=[].- Verified: keyword-only tenant scoping, non-disclosing cross-tenant reads, immutable auth-field handling, flush-only transaction ownership, tenant/uniqueness constraints, ORM/Alembic parity, SQLite/PostgreSQL partial-index rendering, and online/offline MySQL rejection before SQL rendering.
- Non-blocking suggestions: add explicit before-commit and immutable-field regression assertions, document global username/email uniqueness intent, map duplicate-key errors, and run live PostgreSQL smoke before cutover.