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.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: implement-feature
|
||||
description: "Implement or modify a scoped application capability in this repository, including necessary regression tests. Use for behavior changes; exclude tests-only requests, review-only requests, and skill authoring."
|
||||
---
|
||||
|
||||
# Implement a Phase 1 feature
|
||||
|
||||
Read applicable AGENTS.md instructions and the [shared reference map](../../../data/documents/agent-reference-map.md). Use its implement-feature reading route and current implementation inventory; planned modules are not proof of existing code.
|
||||
|
||||
## Workflow
|
||||
|
||||
1. Identify the requested behavior, acceptance criteria, and Phase 1 boundary. Select the relevant plan, workflow, API, and database sections. Use scenario examples for observable behavior, not as a replacement for contracts.
|
||||
2. Inspect Git status, affected code, callers, tests/fixtures, and integration boundaries. Preserve unrelated changes. Recheck the map's inventory before choosing commands or introducing tooling.
|
||||
3. State a short plan proportional to the change and continue without routine permission requests. Isolate genuinely missing product decisions; continue independent work while requesting the needed decision.
|
||||
4. Implement the smallest complete behavior across affected transport, application, persistence/provider, and UI boundaries. Do not create layers or edit consumers the task does not affect. Preserve provider-neutral application interfaces and one retrieval implementation for text and Live.
|
||||
5. For affected flows, implement permissions, state transitions, error mapping, bounded failure handling, and concurrency/replay contracts together. Read the precise contract before choosing status codes, schema fields, locking, or retry behavior.
|
||||
6. Add meaningful tests for changed behavior and regressions using existing fixtures and conventions. Test externally observable results or invariants, not private implementation wording. No test harness exists in the initial inventory; do not claim a runner is available without checking.
|
||||
7. Run targeted repository checks and necessary integration checks. Verify PostgreSQL-specific behavior on isolated PostgreSQL/pgvector when applicable; mocks are not database constraint evidence. Keep ordinary tests deterministic and network-free. Treat real-provider quality evaluation as separate, authorized work with prerequisites.
|
||||
8. For an intentional contract change, update API/schema documentation, affected consumers, and tests coherently. Do not rewrite expected behavior to hide a defect. Update the map when source locations or verified commands change.
|
||||
9. Inspect the final diff for unrelated edits, leaked secrets, broken links, and incomplete behavior. Report actual checks and limitations.
|
||||
|
||||
## Relevant contract checks
|
||||
|
||||
Select checks according to the affected flow; do not mechanically expand scope.
|
||||
|
||||
- Upload/retry: independent identity, stable replay, changed-payload conflict, same-document retry, no searchable partial chunks.
|
||||
- Worker: durable claim, lease/token fencing, duplicate-free atomic publication, bounded retries, provider calls outside long transactions.
|
||||
- Search: backend-derived scope, ready/active/undeleted filtering, compatible embeddings, document/chunk evidence identities.
|
||||
- Conversations: owner checks, deduplicated turns/provider work, source references unique across the turn, stale-context invalidation and finalization races.
|
||||
- Live: shared retrieval, trusted tool dispatch, duplicate events, observable close/failure, server-side secrets; consult provisional provider contracts before implementation.
|
||||
|
||||
## Stop or narrow work
|
||||
|
||||
If a required reference is missing, mark its dependent work blocked and name the missing path. If authoritative contracts conflict, surface the concrete conflict instead of inventing policy. Missing provider access blocks live validation, not unrelated implementation. Do not claim release readiness from mocks or absent checks. Do not implement deferred roadmap features to complete a scoped task.
|
||||
|
||||
## Report
|
||||
|
||||
State changed behavior and acceptance coverage, list affected files, give exact checks with outcomes, and identify remaining decisions, unrun checks, or risks. Separate completed implementation from unverified runtime behavior. Do not invoke other skills recursively.
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: review-change
|
||||
description: "Review a repository diff, implementation, or proposed merge for actionable defects and Phase 1 contract violations. Review-only by default; use when review is requested, not to implement features or write tests."
|
||||
---
|
||||
|
||||
# Review a Phase 1 change
|
||||
|
||||
Read applicable AGENTS.md instructions and the [shared reference map](../../../data/documents/agent-reference-map.md). Follow its review-change reading route, including Phase 1 exclusions and the distinction between the prototype and planned design.
|
||||
|
||||
## Workflow
|
||||
|
||||
1. Resolve the requested scope and base. Inspect Git status and the actual diff, including relevant untracked files when in scope. For a merge review, establish the intended target and merge base; do not silently assume a branch. If the base cannot be determined, ask a focused question and continue independent inspection.
|
||||
2. Read affected surrounding code, callers, tests, and governing document sections. For an implementation review without a diff, state the inspected paths. Distinguish pre-existing gaps from defects introduced by the change.
|
||||
3. Check correctness, authorization, API/schema contract alignment, data integrity, failure behavior, and relevant concurrency/retry semantics. Inspect consumers when contracts intentionally change.
|
||||
4. For changed retrieval or lifecycle code, trace a concrete failure path for inactive/deleted document exposure, forged scope, stale context, invalid citations, or duplicate provider work. Check document/chunk identity and provider/application boundaries.
|
||||
5. For changed jobs or persistence, check claim/lease fencing, atomic publication, lock order, replay uniqueness, and interruption recovery against database contracts. Do not infer constraint correctness from mocks.
|
||||
6. For changed conversations or Live code, check owner authorization, turn/source mapping, epoch rechecks, shared retrieval, duplicate tool events, and close/failure states. Treat live signaling as provisional until the documented provider proof exists.
|
||||
7. Validate suspected findings using targeted read-only inspection or checks safe for the requested scope. Do not execute production writes. Ordinary app imports can initialize embeddings/storage; inspect command side effects first. If a check needs repository mutation or unavailable services, report the limitation.
|
||||
8. Prioritize actionable defects over style. Require a reproducible trigger or concrete failure path and material impact. Do not invent findings to populate the report.
|
||||
9. Report findings before the summary, ordered by severity. State review scope, checks performed, and untested risks even when no defects are found.
|
||||
|
||||
## Scope and stopping conditions
|
||||
|
||||
Default to review-only: do not modify files or fix defects unless the user requests fixes. Do not recursively invoke implementation or testing skills. Missing references or unresolved contract decisions limit only dependent conclusions; disclose the exact gap and continue unrelated review.
|
||||
|
||||
Do not report deferred roadmap features as bugs. Use the Phase 1 plan to distinguish missing scoped functionality from intentional exclusions, and the current task to distinguish introduced defects from unrelated prototype limitations. Existing code is not authority for conflicting contracts; documentation changes cannot excuse an unintended bug.
|
||||
|
||||
## Findings format
|
||||
|
||||
For each finding include:
|
||||
|
||||
- Severity: critical, high, medium, or low, proportionate to impact and likelihood.
|
||||
- Actual file and line/location, with the smallest useful affected location.
|
||||
- Concrete trigger and failure path.
|
||||
- User/data/security impact.
|
||||
- Recommended correction direction and supporting contract or observed check.
|
||||
|
||||
Close with scope/base, checks and their outcomes, and residual risks. If no actionable defects are found, say so explicitly without implying comprehensive correctness or execution of unavailable tests.
|
||||
@@ -0,0 +1,55 @@
|
||||
---
|
||||
name: write-tests
|
||||
description: "Create or improve tests for repository behavior, regressions, or release risks. Also use for real-question RAG evaluation before a demo; keep real-provider evaluation optional and separate from ordinary tests."
|
||||
---
|
||||
|
||||
# Test Phase 1 behavior
|
||||
|
||||
Read applicable AGENTS.md instructions and the [shared reference map](../../../data/documents/agent-reference-map.md). Follow its write-tests reading route. The initial repository has no automated test runner or fixtures; inspect current files before selecting a harness or reporting commands.
|
||||
|
||||
## Automated test workflow
|
||||
|
||||
1. Read intended behavior, affected contracts, existing implementation, and tests before choosing assertions. Identify the failure or release risk and acceptance criterion.
|
||||
2. Choose the smallest useful level: unit, integration, contract, or end-to-end. Reuse the repository's runner, naming, fixtures, and dependency conventions. If still absent, establish a minimal suitable harness within the requested test scope and explain the choice; do not present an invented command as existing.
|
||||
3. Select relevant success, failure, and boundary cases. Assert behavior and important invariants rather than mechanically enumerating combinations or mirroring implementation details.
|
||||
4. Mock external providers at adapter/transport boundaries where appropriate. Do not mock the behavior under test. Avoid importing application singletons that can index files, download embeddings, or contact providers during collection.
|
||||
5. Use an isolated PostgreSQL/pgvector test environment for database-specific constraints, vector queries, transactions, or races. Verify the target is a disposable test database before destructive fixtures. A fake database or SQLite is not evidence for PostgreSQL semantics; never use production.
|
||||
6. Keep ordinary automated tests deterministic and network-free by default. Control time, retries, and randomness through injected dependencies where supported; use explicit synchronization for concurrency assertions.
|
||||
7. Run targeted tests and inspect failures. Do not weaken assertions, skip regressions, or change expected behavior solely to make the suite pass.
|
||||
8. Distinguish product bugs, test defects, and unavailable environments. Report product bugs exposed by tests without silently expanding a tests-only request into a production fix. Explain any regression test that remains failing.
|
||||
9. Inspect the diff and record actual results, including tests not run and why. Do not claim mock output establishes real-model quality.
|
||||
|
||||
## Choose relevant cases
|
||||
|
||||
- Upload: admin authorization, invalid files, empty/failed extraction, no partial publication; same upload replay and changed-payload conflict.
|
||||
- Search: authorized ready/active/undeleted scope, forged model scope arguments, compatible embedding profile, source document/chunk identity.
|
||||
- Worker: expired leases, stale claim rejection, retry on the same document/job, duplicate-free publication, deletion during processing.
|
||||
- Turns: conversation ownership, repeated chat replay, changed-payload conflict, concurrent submissions, interruption/recovery, evidence mapping across multiple searches.
|
||||
- Revocation: document deactivation/delete, stale context, epoch race during finalization, retained historical answers without reuse.
|
||||
- Live: dispatch through shared retrieval, duplicate/conflicting tool events, trusted state transitions, close/control failure and revocation.
|
||||
|
||||
Read the precise API/database rules for the cases selected. Do not silently treat the prototype's current behavior as the contract.
|
||||
|
||||
## Real-provider RAG evaluation
|
||||
|
||||
This is optional and separate from the default automated suite. Use when real-output quality is requested or release readiness requires it, with authorized environment and data access.
|
||||
|
||||
1. Check credentials without exposing them, approved corpus, runnable service, selected text/embedding/live profiles, and authorized network/cost limits. For voice, require an actual browser/microphone/WebRTC interaction or explicitly label voice not run.
|
||||
2. Prepare a small, isolated corpus and questions with expected facts and evidence identities. Cover Persian paraphrases, direct facts, missing knowledge, ambiguous questions, follow-ups, and inactive-document cases as relevant. The plan proposes 15-20 questions; do not invent a passing quality threshold.
|
||||
3. Bound requests, tool calls, retries, time, and spend using existing authorization. Stop when the agreed bound or provider failure is reached; do not loop indefinitely or upload sensitive data to unapproved destinations.
|
||||
4. Check extraction separately: recovered text, sections/pages actually available, empty extraction, and chunk boundaries.
|
||||
5. Check retrieval separately: expected evidence is returned, excluded documents remain absent, and document/chunk IDs resolve. Record observed evidence rather than treating plausible prose as successful retrieval.
|
||||
6. Check answers separately: factual support, uncertainty on missing knowledge, follow-up consistency, and citation identity. Prefer fact/evidence assertions over exact full-answer wording.
|
||||
7. Run and report text and voice separately. Voice requires a real backend tool call and spoken result; text-only execution is not voice evidence. Distinguish retrieved voice sources from verified spoken citations.
|
||||
8. Label model-based judging and human checks explicitly. They are assessment methods, not deterministic proof. Record corpus/profile, question, expected evidence, observed extraction/retrieval/answer/source outcome, and failure category; report metrics only from executed cases with denominators.
|
||||
9. If credentials, corpus, service, authorization, or voice interaction are unavailable, mark the affected evaluation not run with the precise prerequisite. Never substitute cached or mock results as real execution.
|
||||
|
||||
Protect secrets and sensitive text in artifacts. Preserve only approved evidence and redacted diagnostics. Do not change application features just to complete an evaluation.
|
||||
|
||||
## Stop or narrow work
|
||||
|
||||
Missing authoritative behavior blocks dependent assertions; name the missing reference or product decision and continue independent cases. A provider outage or missing database is an environment limitation, not a passing result. A discovered product bug stays reported unless fixing it is within the user's scope.
|
||||
|
||||
## Report
|
||||
|
||||
Give tested behavior and level, changed test files, exact commands/outcomes, and defects or environment limitations. For real-provider work, add executed case counts, evidence-based observations, text/voice status, judging method, and unrun checks. Do not invoke other skills recursively.
|
||||
Reference in New Issue
Block a user