Skip to content

test(core): measure native ConPTY codepage initialization - #847

Open
agenteinstinct1-max wants to merge 10 commits into
dev-vibecodedfrom
diag-native-codepage
Open

agenteinstinct1-max wants to merge 10 commits into
dev-vibecodedfrom
diag-native-codepage

Conversation

@agenteinstinct1-max

@agenteinstinct1-max agenteinstinct1-max commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes #846, which only asks for the missing measurement. This PR does not fix or explain any underlying defect. Refs #810 (not closed: its production defects remain).

Development link: #846 is linked in this PR's Development sidebar, because "Closes" in the body is not recognized for a non-default base branch.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a Windows-only measurement of native ConPTY codepage initialization: 3 new files under packages/core/test/pty (native-codepage-probe.test.ts, native-codepage-probe-helper.ps1, native-codepage-probe.md), 2337 additions, 0 deletions. The 6 native cases run in normal Windows CI and skip elsewhere. They record what each backend delivers with no output decoder applied. No production code, workflow, dependency or package-script changes. Base: 2ab1fca on dev-vibecoded. Current head: e0dc889 (chain 34853f8 -> dada8f1 -> d4b71de -> e0dc889 over previous head 217ba5e; the later commits harden probe liveness: fail closed on unknown PTY liveness and pending death, isolate the native Node probe, and tighten stream/cleanup contracts).

It does not claim a cause or a fix.

Interpretation limits: before-exit latency of the standalone box-drawing case is UNVERIFIED; ConPTY may consume OSC title sequences, so absence in output is ambiguous; raw CP437 payload is recorded separately from UTF-8 and wide output.

How did you verify your code works?

  • Linux host qualification of the strict suite on the exact head (writer-run): 42 passed, 6 native skipped, 184 assertions.
  • The 6 native cases skip on Linux (0 of 6 executed on the qualification host). On previous head d4b71de's fresh Windows CI they DID execute: the 3 node-backend cases failed (~20s timeouts, exitCode null, no cpStages recorded) and the 3 bun-backend cases completed (exitCode 0, cpStages recorded). Native behavior is not claimed green; the fresh Windows run on the current head e0dc889 is pending.
  • Previous head 217ba5e fresh CI: Windows job RED (native probe: node backend timed out with ERR_SOCKET_CLOSED; bun and baseline backends reported startupParserDisabled=true); Linux green. That RED is what the strict repair commits address; whether it is resolved can only be shown by the fresh Windows CI run on the new head.
  • Earlier external review verdicts (Arena sessions) covered earlier trees only, not the current head. A published Kilo review or independent exact-head review plus fresh all-green CI is still required before merge.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Update 3 (head e0dc889, on top of d4b71de)

Adds bounded evidence diagnostics to the probe (still measurement only, no cause or fix): late-stderr capture, runtime phase markers, PowerShell-side phases, and a startup-failure observed-exit PID bookkeeping guard. +422/-20 across the 3 probe files. Writer host qualification on the exact head (Linux): 48 passed, 6 native skipped, 0 failed, 219 assertions; strict target typecheck exit 0. The 6 native cases skip on Linux (0 of 6 executed on the qualification host); on d4b71de's Windows CI they executed (3 node-backend failures, 3 bun-backend results, detailed below); the fresh Windows run on this head is pending and native behavior is not claimed green.

The previous head d4b71de fresh CI failed and is causally unresolved: Windows core 9 fail (3 native node-backend probe timeouts ~20s with no cpStages, 6 host-side node-runtime-bridge tests failing (5 at "node PTY bridge exited before spawn with code 1", plus the asynchronous EPIPE control failing expect(report.epipe).toBe(true))), Linux TUI 1 fail (scrollback-history "missing HISTORY-MARK-001", socket closed). These failures are not claimed fixed by this commit; the new instrumentation exists to gather evidence, and fresh CI on this head may fail usefully. No assertions were weakened. Residual limits (writer manifest): observed ChildProcess exit bookkeeping is not an OS ownership handle and a reap-before-event race remains; descendants of an already-exited bridge are unknown, not claimed clean; Windows native phase markers and the taskkill tree path were not executed on the Linux host. An exact named semantic review must cover the whole unreviewed 217ba5e..e0dc889 chain, not just this delta; this plus fresh all-green CI is required before merge.

Update 4: partial host invocation correction

Head 65c54dae86998d2ad0523897c6db6f2bf8ca0a4b corrects five host invocation cases to use the actual Node bridge executable path; the literal default remains unchanged. Sentinel, negative controls and mutation controls were added. Author qualification: 49 host PASS, 6 native SKIP, 233 assertions, strict type check 0 errors. This is a partial host invocation fix only, not an AddType, late-pipe, EPIPE or barrier fix. Windows may remain RED. No broader source-cause claim beyond the exact beta12 executable lookup mechanism. Prior e0 results above remain historical. Fresh exact-head CI and full named review of the 217-to-65 chain are still required; no merge approval.

Update 5: partial fd3 asynchronous control and bounded queue condition

Head 884d49333a8e91b8f41c6b2ae36a97b92bf19c9a adds a genuine asynchronous Node pipe control on fd3, not native stdin proof; the original stdin handler is unchanged. The early-queue check now waits for the actual queue condition with a 5-second bound. Author qualification: 51 host PASS, 6 native SKIP, 248 assertions, strict type check 0 errors; mutation controls RED. This candidate has not executed on Windows. Native AddType, late-grandchild stderr, abandoned-entry barrier and owned-default paths remain OPEN. The outer 5-second backstop may beat the 4+1-second cleanup budget: this fails closed but is not join proof. Earlier head results above are historical. Full named whole-chain review and fresh all-green CI remain required. No merge approval.

Update 6: partial late-stderr fixture correction

Head 26d79d9f107353d57b7d517e019ec3ef9a1a5601 changes the late fixture to require START before observed bridge exit before a fresh-token marker, with a bounded owned loopback and cleanup. Author qualification: 51 host PASS, 6 native SKIP, 263 assertions, strict type check 0 errors. Mutations: marker-before-exit RED, never-START RED, split marker GREEN; no-detach mutation is GREEN on Linux and non-discriminating. Native AddType remains OPEN. No Windows execution or OS-level reap proof is claimed for this candidate. Previous results above are historical. Exact whole-chain named review and fresh all-green CI are still required; no merge approval or additional completed merge.

@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown

Thanks for updating your PR! It now meets our contributing guidelines. 👍

resolve(result)
})
try {
stdin.write(JSON.stringify({ type: "write", requestId, data }) + "\n")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: stdin.write() return value (backpressure signal) is ignored. For sustained high-volume writes this could allow unbounded buffer growth in the bridge's stdin pipe. Consider checking the returned boolean and applying backpressure.

return { run, outcome: () => outcome }
}
function parseJsonLines(output: string, prefix: string) {
const values: unknown[] = []

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: parseJsonLines regex \\{.*?\\} is non-greedy and stops at the first }. It cannot parse JSON objects with nested braces. If CP stage payloads ever include nested structures, they will be silently skipped.

try {
for (const _response of processed.responses) {
let writeResult = { ok: false, message: "", timedOut: false }
const writeAndWait = proc!.writeAndWait

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Non-null assertion proc! bypasses TypeScript null-checking. Same pattern at lines 1071 and 1103. While proc is assigned before use in the current flow, the assertion removes type safety and could mask undefined access if control flow changes.

@kilo-code-bot

kilo-code-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Incremental review focused on changes from 65c54dae86998d2ad0523897c6db6f2bf8ca0a4b to 26d79d9f107353d57b7d517e019ec3ef9a1a5601 in packages/core/test/pty/native-codepage-probe.md and packages/core/test/pty/native-codepage-probe.test.ts (test-only diagnostic/probe changes). No new, confirmed issues were identified on changed lines from the available diff and current PR state.

Gap: targeted re-verification reads for prior suggestions on unchanged code were not completed in this run, so unverified previous findings are not carried forward.

Files Reviewed (2 files)
  • packages/core/test/pty/native-codepage-probe.md
  • packages/core/test/pty/native-codepage-probe.test.ts
Previous Review Summaries (4 snapshots, latest commit 65c54da)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 65c54da)

This review did not finish. The model reached its output limit before it
could write the review — a reasoning model can spend the whole budget thinking.
Re-run the review, or lower the model's thinking effort, and it should get
further. Any inline comments below are from an earlier review.

Previous review (commit 65c54da)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 3
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/core/test/pty/native-codepage-probe.test.ts 497 stdin.write() return value (backpressure signal) is ignored inside writeAndWait, which can allow unbounded buffer growth under sustained writes.
packages/core/test/pty/native-codepage-probe.test.ts 764 parseJsonLines regex \{.*?\} is non-greedy and cannot parse JSON objects with nested braces, so nested payloads may be skipped.
packages/core/test/pty/native-codepage-probe.test.ts 1141 Non-null assertion proc! bypasses null-checking (similar pattern elsewhere); this can mask undefined access if control flow changes.
Files Reviewed (3 files)
  • packages/core/test/pty/native-codepage-probe.test.ts - 3 issues
  • packages/core/test/pty/native-codepage-probe-helper.ps1 - 0 issues
  • packages/core/test/pty/native-codepage-probe.md - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit e0dc889)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 3
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/core/test/pty/native-codepage-probe.test.ts 422 stdin.write() return value (backpressure signal) is ignored inside writeAndWait. For sustained high-volume writes this could allow unbounded buffer growth in the bridge's stdin pipe.
packages/core/test/pty/native-codepage-probe.test.ts 689 parseJsonLines regex \{.*?\} is non-greedy and stops at the first }. It cannot parse JSON objects with nested braces. If CP stage payloads ever include nested structures, they will be silently skipped.
packages/core/test/pty/native-codepage-probe.test.ts 1066 Non-null assertion proc! bypasses TypeScript null-checking. Same pattern at lines 1071 and 1103. While proc is assigned before use in the current flow, the assertion removes type safety and could mask undefined access if control flow changes.
Files Reviewed (3 files)
  • packages/core/test/pty/native-codepage-probe.test.ts - 3 issues
  • packages/core/test/pty/native-codepage-probe-helper.ps1 - 0 issues
  • packages/core/test/pty/native-codepage-probe.md - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit d4b71de)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 3
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/core/test/pty/native-codepage-probe.test.ts 422 stdin.write() return value (backpressure signal) is ignored inside writeAndWait. For sustained high-volume writes this could allow unbounded buffer growth in the bridge's stdin pipe.
packages/core/test/pty/native-codepage-probe.test.ts 689 parseJsonLines regex \{.*?\} is non-greedy and stops at the first }. It cannot parse JSON objects with nested braces. If CP stage payloads ever include nested structures, they will be silently skipped.
packages/core/test/pty/native-codepage-probe.test.ts 1066 Non-null assertion proc! bypasses TypeScript null-checking. Same pattern at lines 1071 and 1103. While proc is assigned before use in the current flow, the assertion removes type safety and could mask undefined access if control flow changes.
Files Reviewed (3 files)
  • packages/core/test/pty/native-codepage-probe.test.ts - 3 issues
  • packages/core/test/pty/native-codepage-probe-helper.ps1 - 0 issues
  • packages/core/test/pty/native-codepage-probe.md - 0 issues

Fix these issues in Kilo Cloud


Reviewed by free · Input: 42.9K · Output: 2.8K · Cached: 120.8K

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(core): measure native ConPTY codepage initialization

1 participant