Files
SuperBizAgent-java/openspec/changes/session-run-trace-isolation/phase-1-evidence.md
T

104 lines
2.5 KiB
Markdown

# Phase 1 Evidence: Schema and Compatibility Foundation
## Scope Completed
- Added Flyway migration `V011__add_session_run_isolation.sql`.
- Added `chat_session` and `diagnosis_run` tables.
- Added nullable `run_id` columns and indexes to `agent_step` and `tool_invocation`.
- Backfilled compatibility runs from existing `diagnosis_session` rows.
- Backfilled existing step/tool rows where a matching `diagnosis_session.session_id` exists.
- Added `ChatSession`, `DiagnosisRun`, `ChatSessionRepository`, and `DiagnosisRunRepository`.
- Added run-scoped query/count methods to `AgentStepRepository` and `ToolInvocationRepository`.
- Added `DiagnosisRunRepositoryTest`.
## Verification
### Maven
```text
mvn -q "-Dtest=DiagnosisRunRepositoryTest" test
```
Result: passed.
```text
mvn -q "-Dtest=DiagnosisSessionRepositoryTest,AgentStepRepositoryTest,ToolInvocationRepositoryTest,DiagnosisRunRepositoryTest" test
```
Result: passed.
### Database Inspection
Checked with `scripts/query_mysql.py`.
```text
SELECT installed_rank, version, description, success
FROM flyway_schema_history
ORDER BY installed_rank DESC
LIMIT 5;
```
Relevant result:
```text
version = 011
description = add session run isolation
success = 1
```
```text
SELECT COUNT(*) AS chat_sessions FROM chat_session;
```
Result:
```text
chat_sessions = 83
```
```text
SELECT COUNT(*) AS diagnosis_runs,
SUM(CASE WHEN run_id IS NULL THEN 1 ELSE 0 END) AS null_run_ids
FROM diagnosis_run;
```
Result:
```text
diagnosis_runs = 83
null_run_ids = 0
```
```text
SELECT (SELECT COUNT(*) FROM agent_step WHERE run_id IS NULL) AS agent_step_null_run_id,
(SELECT COUNT(*) FROM tool_invocation WHERE run_id IS NULL) AS tool_invocation_null_run_id;
```
Result:
```text
agent_step_null_run_id = 0
tool_invocation_null_run_id = 1
```
The one remaining null `tool_invocation.run_id` is historical orphan data:
```text
id = 3
session_id = f9d2290d
tool_name = lookup_knowledge
created_at = 2026-06-26 14:17:35
```
It has no matching `diagnosis_session`, so V011 cannot safely infer a compatibility run. This matches the OpenSpec wording "when possible" for historical backfill.
### Logs
`logs/application.log` shows Hibernate using the new `run_id` fields in `agent_step` and `tool_invocation` inserts/selects during the repository verification.
## Notes
- Phase 1 intentionally does not switch Chat, Trace, Feedback, or AIOps write paths.
- New columns remain nullable until later phases switch new writes and verify coverage.