Files

59 lines
5.1 KiB
Markdown

# Phase 5 - Shared RAG and declared-source integration
Paste the following into a fresh implementation session in this repository.
```text
Implement Phase 5 only: Shared RAG and declared-source integration.
Prerequisite:
Phase 4 context safety accepted. Existing shared search and evidence policy remain authoritative.
Required visible outcome:
Document questions work with valid used sources, and a repeated interrupted question reuses one original retrieval.
Execution rules:
- Read docs/plans/local-s2s-adapter-plan.md and docs/plans/local-s2s-adapter-progress.md first. Read applicable AGENTS.md, repository skills and governing API/database/workflow sections. Inspect current code; historical defaults are not current evidence.
- Implement only this phase. Check actual prerequisite artifacts, not just the existence of code. State observed, simulated, unverified and blocked outcomes separately.
- Preserve OpenAI/Gemini behavior, original operational/rollback containers/images, frozen old profiles and unrelated working-tree changes. No database reset, compose down, pruning or implicit provider switch.
- Keep existing browser PCM24k/application events, backend-derived identity, one canonical search implementation, document/chunk references and authorization/revision checks.
- Make the smallest scoped change. No plugin framework, full runtime rewrite, new broker or unrelated refactor. Update intentional contracts and affected consumers coherently; never edit applied migrations.
- Ordinary tests are provider-free. DB acceptance requires a verified disposable TEST_DATABASE_URL and --require-postgres; never production. Do not run a parallel application API against the operational database.
- Reuse explicit authorization already present. Paid requests, downloads and operational switching need the applicable bounded authorization. Without it, finish independent offline preparation, identify the exact missing prerequisite and keep dependent live acceptance open.
- Do not print keys/full environments/raw provider payloads or real user speech. Consent-controlled fixture artifacts are separate from default logs.
- Never fake provider events, terminal success or history acknowledgements. Unsupported capabilities fail safely. Do not introduce automatic cross-provider fallback.
- Before finishing: inspect diff, run meaningful checks, record exact commands/results and demo steps, update the progress ledger and list all not-run checks. Do not accept a phase with required live/human checks unrun. Do not begin the next phase.
Required work:
1. Expose search_knowledge, reuse_last_evidence and report_used_sources schemas to the LLM. Execute through current dispatch, ToolContext, DurableTools and SearchService.
2. Preserve backend identity, eligibility, calibration, references, handoff/delivery revisions and access checks; no engine DB credentials or independent retrieval.
3. Validate streamed tool arguments after successful terminal validation; correlate call/item/response identities and deduplicate replays.
4. Preserve pending same-topic search with original deadline; revalidate reuse, discard changed-topic results, never use old assistant prose as evidence.
5. Validate current-turn source reports and repair invalid metadata privately. Only used sources reach UI; metadata reports create no retrieval row.
6. Exercise no_evidence versus technical error, limited tools, revocation/deactivation, interrupted source delivery and known name/percentage/date mistakes.
Acceptance criteria:
- All three tools use existing authority and canonical retrieval.
- No stale/inactive/deleted/revoked evidence is emitted, including reuse/delivery races.
- Repeated same-topic continuation causes no duplicate search; labels map to original document/chunk IDs.
- Evaluation checks actual answer facts, not only valid citation membership.
Relevant paths (verify actual locations before editing):
Local tool mapping, current runtime dispatch, durable_tools.py and shared knowledge services only as needed for a demonstrated integration change.
Validation:
Existing sources and retained-search tests extended to local, isolated PostgreSQL evidence/revocation acceptance and bounded live RAG fixtures.
Visible demonstration:
Ask hours/Thursday, the named deputy in the letter and incentive conditions; interrupt a search and repeat it while showing one retrieval and revalidation.
Explicit stop/narrow condition:
Do not loosen cutoff/authorization filters or introduce another search service to hide model failures.
Deliver:
1. Scoped code/configuration and necessary tests/contracts where this phase requires implementation; Phase 0 remains an audit.
2. docs/evaluation/local-s2s/phase-05.md with exact commands, results, actual/simulated/unverified evidence, fingerprints, not-run checks and risks.
3. Updated docs/plans/local-s2s-adapter-progress.md with a candid acceptance verdict.
4. Exact demo instructions and rollback relevance. Preserve the operational provider unless this phase explicitly authorizes switching and session authorization exists.
Do not implement the next phase. Do not mark acceptance complete with mandatory live or human checks unrun.
```