Skip to content

feat: structlog foundation + analysis pipeline instrumentation#33

Open
Nelson Spence (Fieldnote-Echo) wants to merge 1 commit intomainfrom
feat/structlog-foundation
Open

feat: structlog foundation + analysis pipeline instrumentation#33
Nelson Spence (Fieldnote-Echo) wants to merge 1 commit intomainfrom
feat/structlog-foundation

Conversation

@Fieldnote-Echo
Copy link
Copy Markdown
Member

Summary

Phase 1 of structured logging integration. Motivated by NIST submission on structural anomaly detection — external consumers need machine-parseable provenance, and we need real visibility into instrument behavior during calibration.

What's new

  • structlog>=24.0 added as core dependency (zero transitive deps beyond stdlib)
  • src/navi_sad/logging.pyconfigure_logging(json=False, level="INFO"). Console (colored) for dev, JSON lines for production/integration. Bridges stdlib so existing logging.getLogger() calls route through structlog processors.
  • --json-logs flag on pe_recurrence_null.py and pe_confound_controls.py
  • All 3 CLI scripts migrated from logging.basicConfig() to configure_logging()

Analysis pipeline instrumented at boundaries

Module Events
loader.py artifacts_loaded, samples_filtered, reviewer_votes_loaded
prep.py series_data_prepared, subset_prepared, baseline_deviation_computed, pe_bundle_computed
permutation.py null started/complete for all 3 null types (recurrence, asymmetry, paired)
recurrence.py d_matrix_computed, head_asymmetry_computed
matching.py length_matching_complete
selection.py unanimous_selection_complete
eligibility.py eligibility_table_built

No logging inside hot loops or pure computation functions.

Phase roadmap (in plan, not in this PR)

  • Phase 2: core instrument + signal pipeline (adapter, hooks, PE features, contextvars binding)
  • Phase 3: pilot + generation pipeline
  • Phase 4: calibration instrumentation

Test plan

  • 4 new logging tests (configure modes, event capture, bound context)
  • 415 tests total, all passing
  • Lint, format, mypy clean
  • Pre-commit hooks pass
  • CI passes

🤖 Generated with Claude Code

Phase 1 of structured logging integration. Adds structlog as core
dependency and instruments the analysis pipeline at boundaries.

- Add structlog>=24.0 to core dependencies
- Create src/navi_sad/logging.py: configure_logging() with console
  (colored, dev) and JSON (production) modes. Bridges stdlib logging
  so existing logging.getLogger() calls emit structured output.
- Update all 3 CLI scripts to use configure_logging() + structlog
  bound loggers. Add --json-logs flag to analysis scripts.
- Instrument analysis pipeline boundaries (not hot loops):
  loader (artifact load, filter, reviewer votes),
  prep (series data, subset, baseline deviation, PE bundle),
  permutation (null start/complete for all three null types),
  recurrence (d matrix, head asymmetry),
  matching (length matching complete),
  selection (unanimous selection complete),
  eligibility (table built)
- Add tests for configure_logging() modes and structlog event capture

411 tests + 4 new = 415. Lint, format, mypy clean.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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