Skip to content

fix: refresh strict Gitea lookups and synchronize Windows PTY access - #23162

Merged
OrcaWin merged 11 commits into
mainfrom
nwparker/perf-09-25-gitea-strict-scan-invalidation
Sep 26, 2026
Merged

OrcaWin merged 11 commits into
mainfrom
nwparker/perf-09-25-gitea-strict-scan-invalidation

Conversation

@nwparker

@nwparker nwparker commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​397 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​386
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​292 $\color{#cf222e}{\Huge{\mathbf{−}}}$​67 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​225

Native CI prerequisite and updated merge review

This branch also contains a Windows node-pty repair that synchronizes PTY table access, with native stress tests. These additions are included in this review scope.

The extra terminal review rates the shared native change Low after a freshly rebuilt Windows addon passed 495 tests (23 skipped), including PTY table overlap, teardown and MSYS job tests. Windows job and logs. The native files were byte-identical across #23162 and #23194; #23194’s subsequent rebase also preserves every reviewed changed file. CodeRabbit withdrew and resolved the inherited clean-exit job-handle finding after checking the parent and existing contract.

The Windows evidence ran on the earlier #23194 integration head; all final-head CI and bot checks remain required before merge. System-ConPTY relay mode, Windows ARM64 and long stress soaks remain untested. The Gitea request trade-off below still excludes this PR from the no-trade-off merge batch.

Focused E2E CI prerequisite

This branch also restores Playwright file selection in the IME and golden workflows (#23270). With the locked Playwright 1.63.0 CLI, a literal -- discarded the requested filenames: the old X11 command selected 824 tests instead of four. All four corrected command shapes select only their requested files; restoring the separator makes each select the unrelated fixture too. The standalone fix passed four X11 byte tests, three native IBus tests, and three Wayland repetitions in hosted CI. This branch still requires its own final-head CI.

ELI5

After Orca creates a Gitea or Forgejo pull request, refreshing its branch can still report no PR for up to 30 seconds. Clear both lookup caches after creation so the next refresh can find it.

What Changed

Repository invalidation now clears both ordinary and strict scan keys through the existing cache mechanism. Strict lookups are used by review eligibility and deliberately keep API failures separate from accepted misses. Existing in-flight ownership checks prevent an old scan from replacing the fresh result.

Scenario Before After
Strict miss cached before creation Refresh can reuse the miss Refresh scans again and finds the PR
Old strict scan finishes after invalidation New readers can join/reuse it New readers share a fresh scan; old result cannot recache
One-page fixture, both lookup modes Three list requests across initial reads and refresh Four list requests; create remains one POST

Why

The outer branch cache already refreshes after creation; the inner strict scan also needs invalidation. Reusing its existing invalidation function preserves failure handling, TTLs and coalescing. Merging lookup modes would let swallowed API failures appear as authoritative misses.

This is a separate correctness-only PR with a request trade-off: when strict lookup is next used after invalidation, it performs one fresh scan, up to five list requests under the existing cap. Concurrent strict readers share it, and subsequent reads reuse it. Newly found reviews may also trigger the existing commit-status request. No eager fetch or performance improvement is claimed.

Linked Issue

Fixes #23161

Visual Proof

N/A — this changes main-process cache invalidation, with no layout or component change. Baseline/fixed mocked API regressions verify the behavior; no live forge or rendered UI was exercised.

Shared hourly CI prerequisite

The branch also carries the shared hourly-build fixture correction from #23274. Historical package-version inputs are explicit, with exact version/build-number assertions retained and a newer-package control. Default build commands still read package.json; the dedicated no-module-mocking lint rule stays enabled.

Windows ARM startup evidence

A subsequent Windows ARM persistence check failed before the Bun launcher emitted its boot marker. This branch includes the bounded startup-phase diagnostics from #23267; the five-second readiness assertion and production behavior are unchanged. That startup failure remains unexplained, and a later pass alone will not establish a fix.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

All four new regressions fail on baseline and pass with the fix. They cover creation, existing-PR recovery, concurrent readers and stale scans completing before/after their replacement. All 42 Gitea tests in five suites pass, including existing strict/ordinary failure isolation. Node typecheck, focused Oxlint and formatting pass. Tested on macOS with mocked Git, SSH, fetch and synthetic auth under ORCA_BACKGROUND_LAUNCH=1; no live API, native UI or credential operations.

AI Disclosure

Native stress probe review

The stress probe now checks native job membership for every ready replacement shell, preserves its original failure when exit draining also times out, and labels the required host-job capability as a runner precondition. Both 15-second deadlines and the required host-job assertion remain intact. VM fault injection demonstrates that the old probe missed six corrupted replacement slots and could mask the original error; the revised probe catches each case. Final-head Windows CI remains the native execution gate.

Review

Original Gitea-only change: low risk. That production change calls the existing invalidation mechanism for one additional key. It preserves host routing, cache limits, error semantics and unrelated repositories. The added post-create request cost is bounded by the existing scan cap; provider latency still applies. Independent review approved: four additional candidate cases pass (original: two failures, two passing controls), and all 42 permanent tests pass on an independent rerun. It verifies host isolation, strict errors, late rejection and no eager requests. Isolated-branch CI remains pending.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The Gitea cache change preserves Git commands, remote wire formats, host routing and non-git folder behavior. The native prerequisite additionally affects Windows terminals; its current-head validation remains pending as described above.

Checklist

  • Small and focused — the shared native CI prerequisite expands this branch
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 7df1255c-4357-448d-a339-112011a9bb6f

📥 Commits

Reviewing files that changed from the base of the PR and between 666a8af and 19340b6.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • .github/workflows/golden-e2e-experiment.yml
  • .github/workflows/terminal-ime-e2e.yml
  • config/patches/[email protected]
  • config/scripts/playwright-focused-workflow-selection.test.mjs
  • config/scripts/run-terminal-ibus-hangul-e2e.mjs
  • config/scripts/terminal-ime-e2e-workflow.test.mjs
  • config/scripts/windows-pty-table-stress.cjs
  • src/main/pty/node-pty-self-exit-pseudoconsole-close.test.ts
  • src/main/windows/windows-msys-job.win32.test.ts
  • src/main/windows/windows-pty-job.win32.test.ts
💤 Files with no reviewable changes (1)
  • config/scripts/run-terminal-ibus-hangul-e2e.mjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

The pull request invalidates both regular and strict Gitea pull-request scan caches and adds tests for refreshes after creation, existing-pull-request recovery, concurrent reads, and in-flight scans. It updates the Node-PTY patch to track Windows ConPTY jobs and synchronize shell and console teardown. New Windows stress coverage checks job membership and shell cleanup. Playwright workflow and runner commands omit the -- separator before spec paths, with a test verifying focused spec selection.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 19340

The Windows stress test may fail on CI hosts with restrictive job settings even when PTY behavior is correct. This is a bounded test-environment risk, not an established production failure.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 19340

The Windows process changes include ownership checks and a fallback when job tracking is unavailable. Gitea refreshes its existing lookup caches without changing who can make requests. No new security issue is established, but some Windows configurations and final-head checks remain unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The native change can affect descendants of Windows terminal shells running with the user's process privileges. Gitea invalidation affects subsequent scans for the configured repository, not a new authentication or service boundary.

Trust Boundaries and Controls

  • observed — A caller cannot select a job solely by PTY ID: native termination and listing validate the supplied shell PID against the tracked owner. An untracked job produces an unavailable outcome rather than proof of termination.
  • observed — The flagged focused-workflow test passes parsed arguments to Playwright list mode in a temporary fixture; it is not evidenced as a production public entrypoint. The flagged MSYS range changes test diagnostics, not process authority.

Resilience and Maintainability Implications

  • inferred — Separate exit and console-close state, mutex-protected ownership checks, and a duplicated shell handle reduce exit-versus-kill races. The supplied scoped tests do not force every interruption or concurrent teardown state.

Hardening Proposals

  • proposed — Before rollout, validate the final built addon under forced exit/kill overlap and assignment failure, including the Windows modes the PR identifies as untested.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The Gitea cache invalidation changes relate to the historical scope of [#23161]. The pull request also changes the node-pty native patch, adds Windows PTY stress and job tests, changes Playwright wo… Remove the unrelated Windows PTY, node-pty, Playwright workflow, and related script changes, or move them to separate pull requests.
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 8 files. (3 skipped: 3… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue [#23161] is closed and supplies historical context only. No active directly linked issue remains, so this pull request has no applicable linked-issue coding requirements.
Title check ✅ Passed The title clearly identifies the two primary changes: strict Gitea lookup refreshes and Windows PTY synchronization. It is concise and relevant, although it does not mention the additional workflow up…
Description check ✅ Passed The description follows the required template and provides clear scope, rationale, linked issue, visual-proof rationale, testing details, review notes, compatibility considerations, and checklist stat…
Full details: Out of Scope Changes check

Explanation

The Gitea cache invalidation changes relate to the historical scope of [#23161]. The pull request also changes the node-pty native patch, adds Windows PTY stress and job tests, changes Playwright workflow argument handling, and updates related test scripts. These changes do not connect to the linked issue's Gitea lookup behavior.

Full details: Docstring Coverage

Explanation

Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 8 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Minor suggestion inline.

Reviewed changes

  • Strict scan invalidation on create — invalidateGiteaPullRequestScanForRepo (src/main/gitea/client.ts:133) now also clears the ${repoKey}::strict namespace, so the review-eligibility strict lookup rescans after Orca creates or recovers a PR instead of serving a pre-create cached miss for the 30s TTL.
  • Regressions — new client-scan-invalidation.test.ts covers cold misses in both modes with coalesced readers, 409 recovery retiring a strict miss, and a stale in-flight strict scan finishing before/after its replacement. I confirmed all four fail with the new prod line reverted ([undefined,undefined,7,7] vs [7,7,7,7], null vs {number:7}, fetch count 1 vs 2), so the coverage is real rather than incidental.

The change is scoped correctly: invalidation routes through the existing invalidateGiteaPullRequestScan so failure handling, TTLs, coalescing, and the in-flight generation bump all apply unchanged, and it keeps the strict namespace separate so a swallowed transport failure cannot masquerade as an authoritative miss. The only cost is a bounded fresh strict scan on the next strict read after creation, which the PR discloses.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/main/gitea/client.ts
invalidateGiteaPullRequestScan(giteaPullRequestScanKey(repo))
const repoKey = giteaPullRequestScanKey(repo)
invalidateGiteaPullRequestScan(repoKey)
invalidateGiteaPullRequestScan(`${repoKey}::strict`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The ::strict suffix literal is now duplicated between this invalidation and the key construction in getGiteaPullRequestForBranch (client.ts:267). If the strict key shape ever changes, this line silently stops clearing the strict cache and the original stale-miss bug returns. Consider deriving both keys through one helper (e.g. giteaPullRequestScanKey(repo, { throwOnFailure })) so the two cannot drift.

@nwparker nwparker changed the title fix: refresh strict Gitea lookups after creating a review fix: refresh strict Gitea lookups and synchronize Windows PTY access Sep 26, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

Since the prior pullfrog review (which covered only the Gitea change), this delta adds a Windows ConPTY prerequisite and an i18n restore:

  • Extended node-pty table locking — config/patches/[email protected] now holds the global ptyJobMutex on every ptyHandles access (PtyStartProcess insert, PtyConnect lookup/write, PtyResize, PtyClear, and the job accessors), with get_pty_baton/remove_pty_baton renamed ..._locked to mark the caller-must-hold contract.
  • Reworked PtyKill close path — resolves conpty.dll before claiming the close, copies hpc and a DuplicateHandled shell handle under the lock, and closes the pseudoconsole outside it, so a self-exited pty no longer leaks its console and the watcher can still make progress.
  • Added a native stress probe and test — config/scripts/windows-pty-table-stress.cjs overlaps terminal cleanup with fresh spawns, driven by a new case in windows-pty-job.win32.test.ts; windows-msys-job.win32.test.ts gets diagnostic-only failure enrichment; the self-exit patch-content pins track the _locked names.
  • Restored diff-note i18n entries — the DiffCommentDraftCard catalog keys are re-added under DiffCommentPopover across all seven locales.

The native locking change is sound as written: all eight _locked call sites hold the mutex, the two-sided shellExited/consoleClosed handshake grants exactly one remover (so PtyConnect's unlocked window and both assert(removed) are safe), only non-blocking Win32 calls run under the lock, and the one blocking call (ClosePseudoConsole) is deliberately outside it. Windows native CI was still pending at this head, so this assessment rests on source review rather than a native run.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No new issues in this delta — the focused-selection fix is sound and its regression test is genuine. Not an approval: the two earlier minor threads remain open and unaddressed.

Reviewed changes

Since the prior pullfrog review (2c01e37), the only new commit is 1a521b2c "fix(ci): preserve focused Playwright file selection"; the i18n restore left the PR scope when the main merge landed those keys on main (all seven locales already carry f6c449191e / 5fa4bfebaa / 5e9b3d0c2e).

  • Removed the literal -- from focused test:e2e commands — golden-e2e-experiment.yml, terminal-ime-e2e.yml, and config/scripts/run-terminal-ibus-hangul-e2e.mjs now list spec files directly after pnpm run test:e2e, so the Playwright 1.63 CLI receives them as filters instead of discarding them and running the whole project. I reproduced the old behavior locally: with -- restored in the IME command, Playwright discovers all six written fixtures rather than the single requested file.
  • Added playwright-focused-workflow-selection.test.mjs — it parses both workflows plus the IBus runner, dedupes the four unique command shapes, replays each against the installed Playwright CLI with --list --reporter=json, and asserts the discovered suites equal exactly the requested files. The test passes at head and fails when the separator is reintroduced, so it pins real behavior rather than a tautology.
  • Follow-up pin — terminal-ime-e2e-workflow.test.mjs's runner regex now expects the separator-free args.

No cross-cutting concerns; the change is scoped to CI/script selection and verified end to end by the new test.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No new issues in this delta — the four commits since the last pullfrog review are test and diagnostic changes. Not an approval: the earlier client.ts ::strict thread remains open and unaddressed.

Reviewed changes

Since the prior pullfrog review (19340b6), four test-only commits:

  • Isolated hourly build identity inputs — getHourlyBuildIdentity now takes an optional packageVersion and falls back to package.json, so its tests no longer depend on the repo's release version; a new case pins a newer package version as the floor.
  • Retained PTY stress failure evidence — windows-pty-table-stress.cjs reports the host-job precondition (addressing the prior thread), asserts native job membership for every ready replacement shell, and preserves the original failure when exit draining also times out.
  • Preserved launcher startup-phase evidence — the Bun launcher integration test writes a per-runtime phase trace through an esbuild banner and dumps stream/trace diagnostics when the readiness wait times out.
  • Required focused commands on every platform — playwright-focused-workflow-selection.test.mjs now asserts each golden platform job's exact test:e2e file arguments, not only the command shapes it replays.

Verified locally: hourly-build-version.test.mjs (17 tests) and playwright-focused-workflow-selection.test.mjs (1 test) pass; the CI commands the test asserts match the workflows at this head.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit 8f17358 into main Sep 26, 2026
46 checks passed
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.

refresh strict Gitea lookups after creating a review

2 participants