Files
rag-technical-docs-assistant/data/documents/agent-reference-map.md
T
amirhosein mazaheri baf58da562 feat(ingestion): add Phase 1 database and application foundation
Add the scoped PostgreSQL/pgvector schema, independent ingestion settings and ports, embedding profile checks, and trusted administrator bootstrap.

Include repository contracts and guidance, organized provider-free and PostgreSQL tests, deployment setup, and byte-preserving migration attributes.

Validation: 163 tests passed; all 48 PostgreSQL cases passed with pgvector Python 0.5.0 and 0.3.6. No production schema or historical metadata was changed.
2026-10-05 16:38:28 +03:30

19 KiB

Phase 1 agent reference map

Use this index to select the governing contract and inspect the real implementation before changing, testing, or reviewing behavior. Paths are relative to this file. Inventory verified on 2026-10-05; recheck it as implementation grows. Latest evidence: 163 combined tests passed, including 48 real PostgreSQL cases in both supported pgvector environments. The final acceptance section below supersedes earlier unavailable-database reports.

Authority and document resolution

Follow governing instructions and the user's current task. The plan sets Phase 1 scope; API and database specifications set contracts; the implementation guide sets workflows. The Persian report explains scenarios. Architecture supplies context only. Code and README describe the prototype, not approval to override the Phase 1 contracts.

The six requested unsuffixed filenames do not exist. The only corresponding copies are the (1).md files linked below. Content confirms the 2026-10-05 simplified design: independent immutable uploads, direct document references, no content versions, and retained technical revisions. English specifications identify revision 1.1 and proposed status; the Persian report explains the same lifecycle in sections 9-11. No competing copies were found. Preserve their names and untracked status unless the user requests otherwise.

Section numbers and heading names below are verified against these files; no inferred fragment anchors are used.

Requested document Actual file Authority and sections to consult
RAG-AI-Phase1-Delivery-Plan.md Delivery plan Scope, sequence, acceptance: 3. Included and Deferred Scope; 6. Document Lifecycle and Updates; 8. Delivery Schedule and Checkpoints; 9. Acceptance Criteria; 10. Demonstration Script
RAG-Phase1-Implementation-Guide.md Implementation guide Modules/workflows: 3. Modules and ports; 5. Identity and request context; 6. Document upload and ingestion; 7. Selection, revisions and revocation; 8. Text turn execution; 9. Live lifecycle; 10. Internal search contract; 12. Tests and handoff; 13. Decisions still requiring confirmation
RAG-Phase1-API-Catalog.md API catalog Routes/DTOs/permissions/errors/replay: 1. Transport and common conventions; 2. Endpoint inventory; 4. Documents and selected knowledge; 6. Conversations and text; 7. Voice contract — provisional signaling, fixed ownership rules; 9. Error envelope and mapping
RAG-Phase1-Database-Design.md Database design Schema/constraints/transactions: 4. Knowledge tables; 5. Conversation and evidence tables; 6. Live and audit tables; 7. Transaction boundaries and invariant enforcement; 8. Migration plan; 9. Essential database validation
RAG-Phase1-Scenario-Report-FA.md Persian scenarios Business examples: sections 4-8 (upload, text, missing knowledge, duplicate submission, voice), 9-11 (replacement, revisions, worker crash), 13 (delete), 15 (acceptance), 16 (open decisions)
RAG-AI-Architecture.md Architecture Context/future direction: 4. Backend Modules and Dependency Rules; 6. Search Tool Contract; 7. Dynamic Document Lifecycle; 17. Migration from the Existing Repository; 19. Open Decisions and Owners

Reading by workflow

  • implement-feature: Plan 3/8/9 for boundaries and acceptance; guide 3 and the affected workflow in 5-10; API endpoint and error sections; database affected tables plus 7/8. Use Persian scenarios to clarify observable behavior and architecture 17 for migration context.
  • write-tests: Plan 9/10; guide 12 and affected workflow; API replay/error/permission rules; database 7/9 for races and constraints; Persian scenarios 4-11/13/15 for concrete cases. Consult architecture only for relevant context.
  • review-change: Plan 3/9 to avoid roadmap findings; guide 5-10 for changed boundaries; exact API contracts and database 7/8/9. Use Persian scenarios for trigger/impact and architecture dependency rules only where relevant.

Actual implementation and commands

Existing path Observed responsibility
Application entry point FastAPI routes, CORS, static health response
API directory and schemas Prototype chat transport and DTOs
Services Document loading/chunking and Chroma/FastEmbed retrieval
Agent and tools LangGraph text loop, in-memory history, retrieval tool
Configuration and environment example Settings and provider configuration
README Prototype startup instructions; not Phase 1 implementation evidence
Document processor Recursively ingests Markdown under this documentation directory

Ingestion foundation now exists: manifest, settings/types/ports, database access, initial migration, Alembic environment, trusted bootstrap, and tests. Read foundation setup before migration/bootstrap/database testing. Only the seven requested foundation tables are implemented; no auth sessions, conversation or Live tables. There is still no lockfile, CI, frontend, ingestion intake CLI, concrete FileStore/embedding adapter or worker. Redis/broker and a new orchestration framework are unnecessary.

Command from repository root Verification status
git status --short Executed for working-tree inspection
git diff --check Executed for tracked whitespace validation; untracked new files need separate inspection
rg --files --hidden -g '!.git/**' Executed for file discovery
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload README example and entry point verified statically; runtime not verified
python -m app.services.agent.exec README example and CLI entry point verified statically; provider smoke harness, not automated regression tests; not run

Runtime prerequisites remain unverified: dependencies, configured credentials, approved corpus, writable vector storage, and provider/model access. Importing the application creates settings/retrieval singletons and can load embeddings/index documents. Do not use imports as a supposedly network-free smoke test. README installation now uses pyproject.toml extras. Foundation imports are independent of those prototype prerequisites. Verified foundation commands are listed below; no worker is implemented; see the latest local database acceptance evidence below.

Gaps and decisions

  • Required document content is available under suffixed names; no reference-dependent workflow is currently blocked by missing content. If a linked document later disappears, mark only dependent contract work blocked, report its exact path, and continue unrelated work without inventing it.
  • Material implementation gap: Chroma/local Markdown/in-memory history and the prototype chat DTO differ from the Phase 1 PostgreSQL/pgvector, uploaded documents, authenticated durable turns, and separate worker target. README production-readiness claims are not acceptance evidence. Skill creation does not implement that migration.
  • Open decisions: approved formats/size limits, model IDs and vector dimension, live provider/signaling/control proof, hosting/connectivity, account/session/retention policy, quality threshold, and delivery date. See guide 13 and plan 2. Do not turn proposals into recorded approvals.
  • Live SDP signaling is provisional; resolve compatibility before freezing frontend contracts. Broader architecture features must not override Phase 1 exclusions such as model selectors and guaranteed voice transcripts.
  • Documentation shares the prototype ingestion directory, so this index may enter its Markdown corpus. Use a deliberately isolated, approved corpus for real-provider evaluation and report this limitation; do not silently change product ingestion during skill authoring.

Skill discovery

Skills are stored at repository-root .agents/skills/<name>/SKILL.md, the repository location documented in official Codex skill guidance. No equivalent project-owned skills or prior AGENTS.md files were found.

Use $implement-feature, $write-tests, or $review-change in Codex. Automatic discovery was verified on 2026-10-05: all three repository skills appeared in this session's available-skills catalog after creation. In another client/session where selection is unavailable, explicitly ask Codex to read the relevant SKILL.md by repository path and follow it. No global installation or optional UI metadata is required.

Ingestion foundation commands and evidence (2026-10-05)

  • python -m venv .venv and .venv/Scripts/python -m pip install -e ".[test]": executed successfully with Python 3.14.6.
  • .venv/Scripts/python -m pytest -m "not postgres": 13 passed; no real providers.
  • .venv/Scripts/alembic history: initial revision discovered successfully.
  • .venv/Scripts/python -m pytest -m postgres: requires TEST_DATABASE_URL targeting a dedicated database ending in _test. PostgreSQL tests use disposable schemas and real independent connections. Ordinary-suite missing configuration skips them with a non-acceptance reason; add --require-postgres to the acceptance command so missing configuration fails.
  • .venv/Scripts/alembic upgrade head: operator command, not yet executed against PostgreSQL. Requires explicit INGEST embedding identity/dimension; initial vector(D) and profile are frozen in the database. Equal dimensions with a different model fail compatibility.
  • .venv/Scripts/python -m app.bootstrap: trusted initial organization/admin command; requires explicit display/settings arguments and an interactive password prompt or --password-stdin. No HTTP authentication is implemented.
  • docker info --format '{{.ServerVersion}}': failed both inside and outside the sandbox because Docker Desktop WSL bootstrap could not start. PostgreSQL/pgvector acceptance is unverified in this environment.
  • git diff --check: tracked whitespace validation only; newly added files also need separate inspection.

The ingestion pipeline plan remains an untracked specification; its later phases are not implemented by foundation work. All seven tables use the database contract's direct document identities, scoped FKs, state constraints and uniqueness. The initial revision already exists and must be treated as potentially applied. Repair work does not assume it is unapplied: preserve it byte-for-byte and use forward revisions for any future persisted changes. Processing-profile snapshots contain character units and embedding identity without secrets. Compatibility and native vector registration are explicit functions; importing ingestion modules opens no database/provider connection or corpus.

  • Final .venv/Scripts/python -m pytest: 13 passed, 31 PostgreSQL tests skipped because TEST_DATABASE_URL was absent. .venv/Scripts/python -m pip check: no broken requirements. Database migration/constraint/concurrency/bootstrap runtime remains unverified.

Phase 1 repair evidence (2026-10-05)

Scope is foundation repair only. No intake, worker, HTTP authentication, conversation/Live tables or chat behavior was added.

  • Settings reject credential-bearing or unsupported endpoint URLs, preserving supported endpoint identity. Error strings and structured validation errors omit raw input values. Credentials remain separate SecretStr values. Every floating-point duration rejects NaN and both infinities in direct and environment construction.
  • PostgreSQL fixture support keeps public out of disposable search paths. pgvector resides in the dedicated test_vector namespace; an existing extension elsewhere is refused, not relocated. Alembic explicitly scopes version_table_schema. Every foundation relation is checked before test connections are used and before migration/downgrade. Isolation regressions create their own temporary database to prove public tables/data survive setup, mutation, downgrade/upgrade and teardown.
  • Manifest support remains pgvector >=0.3.6,<1. Vector acceptance handles both NumPy (0.3.6) and Vector (0.5.0) results. The minimum was installed in .venv/minimum; package imports/provider-free checks are not real database adaptation proof.
  • Initial revision SHA-256 remains 9B33C32CB7CC8AB67DDD523D8FF3DA3AB6D1CB3B8D986C3652DADAD3764EE567. No revision file or persisted schema was changed; no forward data migration was needed for these code/config/test repairs. Historical URL-secret cleanup is unresolved if an older deployment actually persisted such inputs.
  • Provider-free commands .venv/Scripts/python -m pytest -m "not postgres" and .venv/minimum/Scripts/python -m pytest -m "not postgres": 88 passed in each environment (pgvector 0.5.0 and 0.3.6).
  • Explicit PostgreSQL acceptance commands in both environments, -m postgres --require-postgres --tb=no, fail fixture setup when TEST_DATABASE_URL is absent. Docker info still fails inside and outside the sandbox with DockerDesktop/Wsl/ExecError and WSL bootstrap exit 0x40010004. No PostgreSQL migration/constraint/isolation/concurrency/vector evidence is claimed.
  • README now agrees with requires-python >=3.11. Pipeline inventory and AGENTS.md point to the actual manifest, migrations and tests.

Final repair checks:

  • .venv/Scripts/python -m pytest: 88 passed, 48 skipped. Skips are PostgreSQL cases with missing TEST_DATABASE_URL and do not count as acceptance.
  • .venv/Scripts/python -m pytest -m postgres --require-postgres --tb=no -q and the same command using .venv/minimum/Scripts/python: 48 setup errors in each environment, zero PostgreSQL passes/skips; database configuration is absent. An earlier run before constraint coverage expansion had 34 setup errors.
  • .venv/Scripts/python -m pip check and .venv/minimum/Scripts/python -m pip check: no broken requirements.
  • .venv/Scripts/alembic history: unchanged initial revision discovered.
  • git diff --check: passed; new-file syntax/whitespace inspection is separate.

Final foundation acceptance evidence (2026-10-05)

Remaining settings defects were reproduced first: malformed port values leaked dummy secrets into Pydantic output/context, malformed URL structure escaped as SQLAlchemy ArgumentError, and valid ambient limit overrides broke baseline tests. Settings now converts parser failures to a generic validation error outside the parser handler and raises sanitized ValidationError outside its handler, retaining no raw parser/input exception chain. Regressions inspect str/repr/json, errors and context/cause, exercise valid Psycopg URLs and rerun the ordinary suite with external overrides. Fixtures clear ambient INGEST_* variables per test without changing production loading or TEST_DATABASE_URL.

Docker became available. A dedicated temporary PostgreSQL/pgvector container, rag-foundation-acceptance-7e382b6f, ran on localhost:54918 with the dedicated rag_foundation_test database. The server was PostgreSQL 16.15; pgvector extension 0.8.7. Python adapter versions were 0.5.0 and minimum 0.3.6. Prerequisite check verifies connectivity, dedicated database configuration, CREATE/DROP DATABASE and extension privileges, and the safe extension namespace before the suite. Both environments passed it. No existing deployment/database or metadata was changed.

Final commands/results:

  • .venv/Scripts/python -m pytest -m "not postgres" -q: 115 passed, 48 deselected.
  • .venv/minimum/Scripts/python -m pytest -m "not postgres" -q: 115 passed, 48 deselected.
  • .venv/Scripts/python -m pytest -m postgres --require-postgres -q: 48 passed, 115 deselected.
  • .venv/minimum/Scripts/python -m pytest -m postgres --require-postgres -q: 48 passed, 115 deselected.
  • .venv/Scripts/python -m pytest --require-postgres -q: 163 passed.
  • .venv/Scripts/python -m tests.postgres_prerequisites and .venv/minimum/Scripts/python -m tests.postgres_prerequisites: passed.
  • Both environments' python -m pip check: no broken requirements.
  • .venv/Scripts/alembic history: initial revision discovered. All final test runs had zero failures, setup errors or skips.

First real-DB run: 46 passed/2 failed in 0.5.0; first 0.3.6 run after initial test repairs: 47 passed/1 failed. Repaired test SQL JSON binding, replaced search-path-dependent deparsed constraint comparisons with complete stable catalog comparisons, and used 0.3.6's supported NumPy native input. Assertions continue to prove numeric vector values and unchanged public relations/data. Public preservation, scoped downgrade/upgrade, constraints, profile checks and concurrent bootstrap now have real PostgreSQL evidence.

The initial revision remains byte-for-byte unchanged with SHA-256 9B33C32CB7CC8AB67DDD523D8FF3DA3AB6D1CB3B8D986C3652DADAD3764EE567. No persisted schema change or forward migration was needed. Historical credential remediation is conditional on identifying an affected deployment and explicit authorization; see setup instructions for rotation and targeted forward metadata migration while preserving agreed embedding identity. No remediation is claimed.

Remaining limits: local acceptance does not prove production deployment, real-provider compatibility/quality or any later ingestion phase. The standalone operator migration/bootstrap commands remain separately documented; the suite executes the real Alembic migration path and bootstrap database function.

Final cleanup/inspection: the dedicated database reported zero leftover disposable schemas, zero generated foundation_*_test databases and zero public application tables. The temporary acceptance container and its anonymous test volume were removed; no other container was touched. git diff --check passed, syntax and new-file whitespace checks passed, and the original migration hash was preserved.

Test organization: tests/unit contains provider-free configuration, endpoint, database URL, import and test-environment cases. tests/integration contains PostgreSQL migrations/profile, constraints, concurrency, vector and isolation cases, with database-only fixtures and a directory-wide postgres marker. tests/support contains reusable PostgreSQL and row helpers; tests never import helpers from another test module. Shared settings fixtures remain in root conftest.py. The tests.postgres_prerequisites command remains unchanged.

Organization validation: .venv/Scripts/python -m pytest --require-postgres -q: 163 passed. .venv/minimum/Scripts/python -m pytest -m postgres --require-postgres -q: 48 passed, 115 deselected. Both prerequisite commands passed on a temporary dedicated PostgreSQL/pgvector container. Final runs had no failures/errors/skips. The first moved-helper run exposed a repository-root path error, which was fixed before these final checks. Initial migration hash, test syntax/whitespace and git diff --check passed. See test layout.