Skip to content

fix(nightshift): populate runs and session_outcomes from fix pipeline (fixes #467)#472

Open
mickume wants to merge 1 commit intodevelopfrom
fix/467-night-shift-doesnt-populate-runs-or-session-outcomes-tables
Open

fix(nightshift): populate runs and session_outcomes from fix pipeline (fixes #467)#472
mickume wants to merge 1 commit intodevelopfrom
fix/467-night-shift-doesnt-populate-runs-or-session-outcomes-tables

Conversation

@mickume
Copy link
Copy Markdown
Contributor

@mickume mickume commented Apr 17, 2026

Summary

The night-shift fix pipeline was only writing telemetry to audit_events. After 9 fix pipelines and 37 sessions, both runs (0 rows) and session_outcomes (0 rows) remained empty.

Three root causes fixed:

  1. _emit_session_event only called emit_audit_event; record_session was never invoked.
  2. create_run/update_run_totals/complete_run were never called.
  3. NightShiftEngine._process_fix never passed conn to FixPipeline, so DB access was impossible.

Closes #467

Changes

File Change
agent_fox/nightshift/fix_pipeline.py Add conn param; _record_session_to_db helper writes full SessionOutcomeRecord (18 cols); _try_complete_run helper; _emit_session_event now also writes to session_outcomes; process_issue calls create_run/complete_run at lifecycle boundaries
agent_fox/nightshift/engine.py Pass conn=self._conn to FixPipeline
tests/unit/nightshift/test_fix_pipeline.py 5 regression tests for DB telemetry writes

Tests

  • test_session_outcomes_written_for_each_session: record_session called ≥3× for triage+coder+reviewer
  • test_runs_row_created_even_on_empty_body: create_run/complete_run called at all exit paths
  • test_session_outcome_has_run_id_and_archetype: all records carry correct run_id and archetype
  • test_no_db_writes_when_conn_is_none: backward compat — no DB calls when conn=None
  • test_engine_passes_conn_to_fix_pipeline: engine wiring verified

Verification

  • All existing tests pass: ✅
  • New tests pass: ✅ (5/5)
  • Linter / formatter: ✅
  • No regressions: ✅

Auto-generated by af-fix.

…fixes #467)

The fix pipeline was only writing to audit_events. Two tables remained
empty after every night-shift run:

- session_outcomes: _emit_session_event only called emit_audit_event;
  record_session_outcome / record_session were never invoked.
- runs: create_run / update_run_totals / complete_run were never called.
- engine.py did not pass conn to FixPipeline, so even if the write code
  had existed it would have had no DB access.

Fix:
- Add conn parameter to FixPipeline.__init__; NightShiftEngine._process_fix
  now passes self._conn.
- Add _record_session_to_db helper that builds a full SessionOutcomeRecord
  (all 18 columns) and calls engine.state.record_session + update_run_totals.
- Add _try_complete_run helper (best-effort complete_run wrapper).
- _emit_session_event now also calls _record_session_to_db after emitting
  the audit event.
- process_issue calls create_run at start and _try_complete_run at every
  exit point.

All DB writes are best-effort (exceptions logged and swallowed) consistent
with the existing pattern. When conn=None the new code paths are no-ops,
preserving backward compatibility.

Five regression tests added covering: session_outcomes written per session,
runs row lifecycle, correct run_id/archetype fields, conn=None no-op, and
engine wiring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant