[Senate] Add linting and formatting infrastructure done

← Code Health
Add pyproject.toml with ruff config (conservative — only flag clear issues, not style preferences). Add ruff check to quality_gates.py pre-merge gate. Focus on: unused imports, undefined variables, f-string issues, security issues (S101-S110). Do NOT enforce style formatting initially — too disruptive. ## REOPENED TASK — CRITICAL CONTEXT This task was previously marked 'done' but the audit could not verify the work actually landed on main. The original work may have been: - Lost to an orphan branch / failed push - Only a spec-file edit (no code changes) - Already addressed by other agents in the meantime - Made obsolete by subsequent work **Before doing anything else:** 1. **Re-evaluate the task in light of CURRENT main state.** Read the spec and the relevant files on origin/main NOW. The original task may have been written against a state of the code that no longer exists. 2. **Verify the task still advances SciDEX's aims.** If the system has evolved past the need for this work (different architecture, different priorities), close the task with reason "obsolete: " instead of doing it. 3. **Check if it's already done.** Run `git log --grep=''` and read the related commits. If real work landed, complete the task with `--no-sha-check --summary 'Already done in '`. 4. **Make sure your changes don't regress recent functionality.** Many agents have been working on this codebase. Before committing, run `git log --since='24 hours ago' -- ` to see what changed in your area, and verify you don't undo any of it. 5. **Stay scoped.** Only do what this specific task asks for. Do not refactor, do not "fix" unrelated issues, do not add features that weren't requested. Scope creep at this point is regression risk. If you cannot do this task safely (because it would regress, conflict with current direction, or the requirements no longer apply), escalate via `orchestra escalate` with a clear explanation instead of committing.

Completion Notes

Auto-completed by supervisor after successful deploy to main

Git Commits (3)

[Senate] Recover 3 orphan task specs from quarantined worktrees2026-04-20
[Senate] Recover 3 orphan task specs from quarantined worktrees2026-04-20
[Senate] Fix ruff config for modern ruff, remove dead imports [task:9076b7ed-f770-4a79-aff9-5e8946118045]2026-04-19
Spec File

Goal

Add conservative linting via ruff. Focus on catching real bugs, not enforcing style.
Integrate with existing quality_gates.py.

Acceptance Criteria

pyproject.toml with ruff config (conservative rules only)
☐ Rules enabled: F (pyflakes — unused imports, undefined vars), E9 (syntax errors), S1 (security basics)
☐ Rules NOT enabled initially: style formatting, line length, import ordering
quality_gates.py extended with gate_lint_check() for pre-merge
☐ Baseline: run ruff on core files, fix critical issues only

Ruff Config

[tool.ruff]
target-version = "py311"
line-length = 120
select = ["F", "E9", "S1"]  # Pyflakes, syntax errors, security basics
ignore = ["S101"]  # Allow assert statements
exclude = ["archive/", "migrations/", "scripts/"]

[tool.ruff.per-file-ignores]
"test_*.py" = ["S"]  # Allow security rules in tests

Approach

  • Create pyproject.toml with conservative config
  • Run ruff check on entire codebase — catalog findings
  • Fix only critical issues (F821 undefined names, E999 syntax errors)
  • Add gate_lint_check() to quality_gates.py for core files only
  • Do NOT enforce on standalone scripts initially
  • Work Log

    2026-04-19 10:45 UTC — Slot minimax:67

    • Verified task already done on main: pyproject.toml with ruff config exists, quality_gates.py has gate_ruff_check()
    • Checked for regressions: ruff config on main has deprecated top-level TOML structure
    • Fixed: pyproject.toml uses modern [tool.ruff.lint] section (ruff 0.15.11 compatible)
    • Fixed: removed invalid extend-ignore-names key from pyflakes section
    • Fixed: scripts/quality_gates.py had unused datetime imports (F401) — removed
    • Fixed: added E401 to global ignore (style, not bug) and per-file ignore for tools.py
    • ruff now passes on pyproject.toml, scripts/quality_gates.py, and tools.py
    • api.py has unused imports (F401) and try-except-pass (S110) — known, not fixed per conservative scope
    • Spec file renamed from 9076b7ed_f77_linting_spec.md → 9076b7ed_f77_spec.md per audit requirements
    • Committed and pushed

    Payload JSON
    {
      "_reset_note": "This task was reset after a database incident on 2026-04-17.\n\n**Context:** SciDEX migrated from SQLite to PostgreSQL after recurring DB\ncorruption. Some work done during Apr 16-17 may have been lost.\n\n**Before starting work:**\n1. Check if the task's goal is ALREADY satisfied (run the relevant checks)\n2. Check `git log --all --grep=task:YOUR_TASK_ID` for prior commits\n3. If complete, verify and mark done. If partial, continue. If not done, proceed.\n\n**DB change:** SciDEX now uses PostgreSQL. `get_db()` auto-detects via\nSCIDEX_DB_BACKEND=postgres env var.",
      "_reset_at": "2026-04-18T06:29:22.046013+00:00",
      "_reset_from_status": "done"
    }

    Sibling Tasks in Quest (Code Health) ↗