[Forge] Generate code_proposal artifacts from recurring broken-link / 5xx clusters done

← Continuous Proposal Generation
Cluster recurring failures from link_checker and error logs, emit code_proposal artifacts with target files and est LoC.

Completion Notes

Auto-completed by supervisor after successful deploy to main

Git Commits (2)

Squash merge: orchestra/task/a4c450f7-biomni-analysis-parity-port-15-use-cases (87 commits) (#717)2026-04-27
[Forge] Add code_proposal_generator: cluster broken-link/5xx, emit proposals [task:93832453-9413-4313-8add-c526caf2f7b7] (#657)2026-04-27
Spec File

Goal

The link_checker and the daily 5xx error log produce a steady stream of
broken-link and crash specs (see the dozens of _broken_links_in_ and *_502_spec.md files under docs/planning/specs/). Cluster recurring
failures by stack trace / route / link target, and emit code_proposal
artifacts (kind registered at scidex/atlas/artifact_registry.py:100) that
describe a concrete fix: target files, proposed change, estimated LoC. The
proposal becomes a first-class artifact — humans and agents can discuss it
before any code is written, and the eventual PR cites it as parent.

Acceptance Criteria

☐ CLI: python3 -m scidex.forge.code_proposal_generator --window-days 3
--min-cluster-size 3 --dry-run.
☐ Without --dry-run, registers code_proposal artifacts with required
metadata: feature_summary, target_files, proposed_changes, plus
optional est_loc.
☐ Each proposal is linked back to its source error/log artifacts via
artifact_links link_type='derives_from' (sources may be error_log
or link_check_result artifact rows).
☐ When the LLM judges a cluster as "trivial fix", proposal flags
metadata.severity='small' and the existing Senate auto-merge bot picks
it up via _quality_to_priority.
☐ Dedup: skip when an open code_proposal already targets the same
sorted target_files array.
☐ Smoke: feed 10 mock broken-link clusters into the generator; 10 proposals
registered; rerun is a no-op (dedup count = 10).

Approach

  • Build the clusterer in scidex/forge/code_proposal_generator.py: source
  • from link_check_results and error_logs tables; bucket by route or
    exception class.
  • Prompt the LLM with a structured "diagnose-then-prescribe" template.
  • Register the artifact + links + optional spawned-task pointer.
  • Wire a nightly cron via quest_engine.
  • Dependencies

    • scidex.atlas.artifact_registrycode_proposal kind ready.
    • Existing link_checker and error-log tables.

    Work Log

    • 2026-04-27: Implemented scidex/forge/code_proposal_generator.py.
    - Clusterer reads from artifacts table (types link_check_result/error_log), link_check_results table (graceful fallback when absent), and spec files under docs/planning/specs/ (skips status: completed).
    - LLM diagnosis via scidex.core.llm.complete with structured "diagnose-then-prescribe" template; falls back to deterministic stubs when LLM unavailable.
    - Registers code_proposal artifacts via artifact_registry.register_artifact; required metadata fields: feature_summary, target_files, proposed_changes; optional est_loc.
    - Dedup: checks existing code_proposal artifacts with matching sorted target_files before registering; also catches ArtifactValidationError (title uniqueness) as a safe dedup fallback.
    - Severity small uses quality_score=0.35 → Senate _quality_to_priority maps to priority 64; auto-merge bot picks it up.
    - artifact_links with link_type='derives_from' created for each source artifact ID.
    - --dry-run and --mock flags fully functional.
    - Smoke test passed: --mock run 1 → 10 registered; run 2 → skipped_dedup=10.

    Sibling Tasks in Quest (Continuous Proposal Generation) ↗

    Task Dependencies

    ↓ Referenced by (downstream)