LoopForge icon indicating copy to clipboard operation
LoopForge copied to clipboard

[Bug]: MySQL TEXT artifact exceeds 64 KiB and leaves SOP node running

Open playboy662 opened this issue 2 weeks ago • 3 comments

Component / host

Platform — web / API

Edition

Platform

LoopForge version

Platform, Docker Compose with MySQL 8. Observed in a deployment based on the LoopForge 0.4.0 image.

What happened?

A SOP script exited with code 0 and passed its artifact contract check. It generated a required JSON artifact of 124,245 bytes. The platform failed to archive it because MySQL stores it in run_artifacts.content, a TEXT column limited to 65,535 bytes. The node remained in running and the following approval node never became available. The live trace included an artifact.published event while no artifact row had been saved.

Expected behavior is to archive a valid artifact and continue. If persistence fails, the node should become recoverably failed with a clear error. The publication event should be emitted only after the write succeeds.

Reproduction

  1. Run LoopForge Platform with MySQL and confirm run_artifacts.content is TEXT.
  2. Add a script node that writes a synthetic JSON artifact larger than 65,535 bytes. For example, use Path("large-artifact.json").write_text(json.dumps({"payload": "x" * 120000})) after importing json and Path.
  3. Declare large-artifact.json as a required application/json artifact, then place an approval node after the script.
  4. Run the SOP and compare the script result, artifact row, and node state.

Sanitized diagnostics

The column is defined as `type:text` in `internal/repo/models.go`. The node success path calls `updateRun`, which discards the write error returned by the lower-level state update after it is logged. That path then emits the artifact publication event.

Workaround verified locally: widen the column to `MEDIUMTEXT` while retaining its charset, collation, and nullability. Pause and resume the affected script node. The complete 124,245-byte artifact was archived and the approval became available without regenerating the earlier artifacts.

Suggested fix: update the schema for new installations, provide a manual widening migration for existing MySQL databases, and handle artifact persistence failures in the node completion path.

Safety checks

  • [x] I removed credentials, private endpoints, internal identifiers, and personal data.
  • [x] I searched existing issues for duplicates.

playboy662 avatar Nov 19 '26 07:11 playboy662

Thanks for the report. I understand that a required JSON artifact larger than the MySQL TEXT limit was not archived, the script node stayed in running after the script itself exited 0, and the following approval node never became available.

This is noted and will be reviewed along with the existing issue queue. The version, reproduction steps, and actual versus expected results are already in the report. No fix date is promised here.

cocofhu00 avatar Nov 19 '26 08:11 cocofhu00

Independent reproduction on LoopForge v0.4.1-rc.1 (Docker Compose, MySQL 8.4), same failure mode, larger artifact:

  • A SOP clarify node produced requirement.md, 84,741 bytes (1,352 lines); the executor exited 0 and submitted the gate result.
  • The platform failed to persist the node terminal state: put run: run_artifacts write: Error 1406 (22001): Data too long for column 'content' at row 1.
  • The node then stayed running indefinitely. The web UI showed no error at all — the only evidence was the platform log line, and the live trace still showed an artifact.published event for the artifact even though no row was written (internal/engine/node_execute.go observes that event unconditionally after e.updateRun, which discards the PutRun error in internal/engine/run_state.go). So the page gives no hint that persistence failed.
  • Workaround confirmed: widen run_artifacts.content to MEDIUMTEXT, then restart the platform. The engine's recovery path marked the clarify node succeeded without re-running the model (the ~174k tokens spent on the requirement document were preserved) and the following design node continued.

Checked main @a917e04: still unfixed there (runArtifactRow.Content is type:text, no widening migration). PR #992 implements the schema fix plus the terminal-write failure handling (node becomes failed with the real reason and a node.commit.failed error telemetry, instead of hanging), which matches this diagnosis.

linus-liu-web avatar Nov 21 '26 10:11 linus-liu-web

A refreshed fix is up as #1184 (based on the earlier #992): run_artifacts.content becomes MEDIUMTEXT with an idempotent migrations/040_run_artifacts_content_mediumtext.sql, and a rejected terminal write now fails the node with the store error (plus a node.commit.failed event) instead of leaving it running; artifact.published is only emitted after the state is stored. Validated against MySQL 8.4: the legacy TEXT column reproduces error 1406, the migration applies twice without error, and a 74,768-byte artifact round-trips.

linus-liu-web avatar Nov 21 '26 11:11 linus-liu-web