[Forge] Image generation service with MiniMax + GLM providers done coding:7 image_generation:5

← Visual Artifacts
Build image_generator.py: provider abstraction over MiniMax image-01 (primary, free subscription) and GLM CogView-4 (fallback). Core generate_image() function saves to site/figures/, registers as artifact. Error handling with automatic fallback. CLI interface for testing. ## 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 (6)

[Forge] Fix image_generator.py PostgreSQL compatibility [task:d8fbc165-807c-4a63-b4a7-e87d5d8a62bb]2026-04-20
[Verify] image_generator.py implemented on main — verified 2026-04-20 [task:d8fbc165-807c-4a63-b4a7-e87d5d8a62bb]2026-04-20
[Verify] image_generator.py already on main — verified 2026-04-19 [task:d8fbc165-807c-4a63-b4a7-e87d5d8a62bb]2026-04-19
[Forge] Fix image_generator.py PostgreSQL compatibility [task:d8fbc165-807c-4a63-b4a7-e87d5d8a62bb]2026-04-20
[Verify] image_generator.py implemented on main — verified 2026-04-20 [task:d8fbc165-807c-4a63-b4a7-e87d5d8a62bb]2026-04-20
[Verify] image_generator.py already on main — verified 2026-04-19 [task:d8fbc165-807c-4a63-b4a7-e87d5d8a62bb]2026-04-19
Spec File

[Forge] Image generation service with MiniMax + GLM providers

ID: d8fbc165-807 Priority: 80 Type: one_shot Status: done

Goal

Build image_generator.py: provider abstraction over MiniMax image-01 (primary, free subscription) and GLM CogView-4 (fallback). Core generate_image() function saves to site/figures/, registers as artifact. Error handling with automatic fallback. CLI interface for testing.

Acceptance Criteria

☑ Concrete deliverables created
☑ Work log updated with timestamped entry

Work Log

  • 2026-04-20 12:50:00Z — Verified: implementation already on origin/main at scidex/forge/image_generator.py (blob c9cc7b06). Contains:
- MiniMax image-01 provider (_minimax_generate()) as primary (free subscription)
- GLM CogView-4 provider (_glm_generate()) as fallback
- Core generate_image() saves to site/figures/, registers via register_artifact()
- Automatic fallback on provider failure
- CLI interface via if __name__ == "__main__" argparse
- Scientific image types: pathway_infographic, hypothesis_visual, protocol_illustration, debate_card, entity_portrait
- Quality evaluation via evaluate_image_quality()
- Batch operations via batch_generate_for_analysis() and batch_generate_entity_portraits()
- Evidence: git ls-tree origin/main:scidex/forge/ | grep image confirms file exists

2026-04-21 01:10 PT — Slot minimax:62

  • Issue found: image_generator.py on main uses SQLite patterns incompatible with PostgreSQL (sqlite3 import, row_factory, ? placeholders, PRAGMA journal_mode, kg_edges table name vs knowledge_edges, CURRENT_TIMESTAMP)
  • Fix applied (scidex/forge/image_generator.py):
- Replaced import sqlite3 + from scidex.core.database import get_db (top-level) with lazy imports inside each function using get_db()
- Removed db.row_factory = sqlite3.Row (not needed for dict(row) access in PostgreSQL)
- Changed ? placeholders to %s (PostgreSQL)
- Replaced CURRENT_TIMESTAMP with NOW()
- Renamed kg_edges table → knowledge_edges (correct SciDEX table name)
- Fixed _fetch_kg_edges: uses source_id, relation, target_id columns instead of old subject, predicate, object
- Fixed _fetch_hypothesis and _fetch_analysis to use %s placeholders
- Fixed evaluate_and_update_artifact: removed PRAGMA journal_mode = WAL
- Fixed import: from artifact_registry importfrom scidex.atlas.artifact_registry import
- Removed unused psycopg2.sql import
  • Tested: python3 tests/test_image_generator_prompts.py → 8/8 passed
  • Commit: [Forge] Fix image_generator.py PostgreSQL compatibility [task:d8fbc165-807c-4a63-b4a7-e87d5d8a62bb]
  • Result: Done — PostgreSQL compatibility fix applied, all tests pass

Payload JSON
{
  "requirements": {
    "coding": 7,
    "image_generation": 5
  },
  "_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 (Visual Artifacts) ↗