Skip to content

fix: enforce Windows trace and UTF-8 subprocess contracts - #13

Merged
Anionex merged 1 commit into
mainfrom
codex/issues-8-9
Aug 14, 2026
Merged

fix: enforce Windows trace and UTF-8 subprocess contracts#13
Anionex merged 1 commit into
mainfrom
codex/issues-8-9

Conversation

@Anionex

@Anionex Anionex commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Fixes #8.
Fixes #9.

Depends on Anionex/agent-vision-toolkit#20. The vendored snapshot is pinned to that PR's commit and should be refreshed to the eventual merge commit if GitHub changes the SHA during merge.

Problem

Two Windows-only representation mismatches broke otherwise successful local tools:

  1. trace wrote multi-line SVG text through platform newline translation, but reported the in-memory character count. The runtime's earlier workaround accepted a CRLF-adjusted mismatch, weakening the artifact byte contract.
  2. zh-CN Windows Python pipes default to cp936, while DSH Subprocess exposes text as UTF-8. Chinese extract_fg.py summaries then became mojibake and failed the structured parser. Main already forced UTF-8 in the direct upstream adapter, but runtime preparation used a separate Python environment without the same contract.

Changes

  • sync upstream commit 8ccf9d7, where trace writes exact UTF-8 bytes and reports the actual write count
  • restore strict stat.size === reported bytes validation before SVG artifact commit
  • replace the downstream CRLF-acceptance regression with a strict rejection test
  • make the multi-line trace fixture write binary UTF-8, matching the upstream contract on Windows
  • centralize the isolated Python environment and force PYTHONIOENCODING=utf-8 plus PYTHONUTF8=1 for:
    • every upstream tool/script
    • image probes
    • generated Python helpers
    • bootstrap metadata/dependency probes
    • managed-runtime creation/install subprocesses
  • run the foreground-extraction fixture under simulated ambient PYTHONIOENCODING=cp936 / PYTHONUTF8=0, parse its real Chinese stdout, and assert the spawned override
  • refresh committed lib/ output and the upstream manifest

The vendored README change is generated by the required full upstream:sync from the newer upstream commit; no downstream README was edited manually.

Verification

Passed:

  • npx vitest run tests/runtime.spec.ts tests/runtime-install.spec.ts tests/upstream.spec.ts — 64 passed
  • npx vitest run tests --exclude tests/profile-install.e2e.spec.ts --exclude tests/tools.spec.ts — 122 passed
  • npm run verify:portable
  • npm run example:ui-restoration — initial 6.04%, final 0%
  • node --check lib/runtime-install.js lib/runtime.js lib/upstream.js
  • python3 -m py_compile vendor/agent-vision-toolkit/bin/trace tests/fixtures/upstream/bin/trace
  • git diff --check

Upstream verification is recorded in Anionex/agent-vision-toolkit#20, including the complete optional vtracer/Pillow trace path and passing Windows CI.

Not fully runnable in this detached worktree:

  • npm test reached 122 passing tests, then the available mismatched DSH source facade failed 13 lifecycle tests (FiberState.UNLOADING undefined); profile-install collection also lacked execa.
  • npm run build is blocked by the same checkout mismatch between this branch's legacy cordis type facade and the locally available newer namespaced DSH source. The changed lib/ files were regenerated with TypeScript 6.0.3 emission and independently syntax/package-verified above.

This is a non-UI runtime/process contract fix, so there is no meaningful Browser or Playwright path. The substitute coverage runs the actual Python fixture subprocess, parses Chinese output despite an ambient cp936 request, validates the staged SVG byte contract, and executes the checked-in UI-restoration pipeline unchanged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db0b8fc993

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
"upstreamVersion": "v0.1.0+snapshot.c27d1a3",
"upstreamCommit": "c27d1a300962b553c0884993c575cd3e819465ce"
"upstreamVersion": "v0.1.0+snapshot.8ccf9d7",
"upstreamCommit": "8ccf9d7d89bc395ad7dd19dde840401a5b84623d"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update external-runtime instructions to the new pin

After changing the packaged upstream commit here, README.md:265 and README.zh.md:265 still instruct external-mode users to check out c27d1a300962b553c0884993c575cd3e819465ce. Because prepareUpstreamRuntime compares the checkout HEAD against the new UPSTREAM_COMMIT and rejects any mismatch (src/runtime-install.ts:659-660), following the documented setup now always produces a runtime error; update both instructions to the new commit.

Useful? React with 👍 / 👎.

@Anionex

Anionex commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: a414aa09f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Anionex

Anionex commented Aug 14, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 7436c25ef4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Anionex
Anionex merged commit 65c9d48 into main Aug 14, 2026
2 checks passed
@Anionex
Anionex deleted the codex/issues-8-9 branch August 14, 2026 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant