loopx icon indicating copy to clipboard operation
loopx copied to clipboard

[Bug]: Windows host cannot publish the OpenViking history-conclusion corpus (staged document readback fails)

Open JasonBuildAI opened this issue 1 month ago • 0 comments

Preflight

  • [x] I searched existing issues and discussions for this behavior.
  • [x] This report is not an unpatched security vulnerability.
  • [x] The report and attachments contain no credentials or private/internal material.

Issue origin

Observed or reproduced in a real environment

LoopX version or commit

3054cdcc1

Host or runtime surface

Not host-specific

LoopX area

Capability or extension (providers, adapters, skills)

Problem

On a Windows host the bundled openviking-semantic-preference history-conclusion exporter can never publish a corpus: every export aborts with RuntimeError: staged history document failed readback: <name>, and no generation is written or replaced.

Who is affected: Windows users of the extension-owned loopx-openviking-history-export entry point (the documented way to produce the public-safe run-conclusion corpus for OpenViking ingest), and anyone running the repository contract smoke on Windows, where 14 cases fail with the same error. POSIX hosts are unaffected.

Cause, confirmed by reproduction: _publish_generation stages each document with (staged / name).write_text(data.decode("utf-8"), encoding="utf-8"). CPython's text layer translates \n to the platform line separator (\r\n on Windows) for newline=None writes, while _validate_staged_generation requires (staged / name).read_bytes() == expected and the manifest pins the sha256 of those same source bytes. The byte-exact readback contract and the newline-translating write cannot both hold on Windows.

Minimal reproduction

  1. On a native Windows host, check out 3054cdcc1 and install the test extra.

  2. Build a minimal runtime root with one substantive run record: registry.json = {"schema_version":"loopx_registry_v0","goals":[]}, and goals/demo-goal/runs/index.jsonl containing one line:

    {"generated_at":"2026-08-04T01:02:03Z","classification":"example_conclusion","recommended_action":"freeze the cross-market alert contract","state":{"progress":["Validated the residual model on untouched folds"]},"agent_id":"codex"}

  3. Run the shipped entry point:

    loopx-openviking-history-export --goal-id demo-goal --registry-path <root>\registry.json --runtime-root <root> --out-dir <out>

  4. Observe exit status 1 and the traceback below, with no history-conclusions generation created.

The contract smoke reproduces the same failure without any runtime setup: python examples/loopx-history-conclusion-recall-smoke.py (14 cases fail, all with this error).

Expected behavior

The export publishes the staged generation, prints the JSON receipt, and leaves documents whose bytes match both the byte-exact staged readback and the manifest sha256.

Actual behavior

  File ".../loopx/extensions/openviking_semantic_preference/history_export.py", line 438, in export_goal_conclusions
    retired = _publish_generation(
  File ".../loopx/extensions/openviking_semantic_preference/history_export.py", line 300, in _publish_generation
    _validate_staged_generation(
  File ".../loopx/extensions/openviking_semantic_preference/history_export.py", line 218, in _validate_staged_generation
    raise RuntimeError(f"staged history document failed readback: {name}")
RuntimeError: staged history document failed readback: 2026-08-04T01-02-03Z-example_conclusion-3a573e39c46c139b.md

Additional context

Related merged work in the same file: #6168 (stdio UTF-8 pinning) and #5779 (symlinked export roots). This is a distinct residual in the publish path, not in stdio or path containment.

The same host-newline class is already guarded elsewhere in the repository (tests/test_local_state_migration.py::test_registry_writes_pin_bytes_across_host_newline_translation), and byte-exact publishers elsewhere use write_bytes for this reason.

Reported by an AI agent running under human direction and review; the reproduction above was executed on a native Windows host against main.

JasonBuildAI avatar Oct 11 '26 17:10 JasonBuildAI