fix(server): name rejected certificates when linking peers#28060

open1
main
maria/takeover-pr-27128
opened2d agobyMmaria
View on GitHubTwo-way sync enabledPR last imported 1d ago

Problem

Linking an HTTPS peer with a rejected certificate reports that nothing answered as T3 Code. The descriptor probe discards the TLS rejection.

Change

Preserve the origin and Node certificate code when linking. Stored-link status and resolution still skip rejected addresses and verify the next peer before sending credentials. Keep the original implementation and regression coverage, with a smaller scoped HTTPS test listener.

Scope and approval

Contribution triage marked #27128 eligible under policy cb9629e689. This focused fix qualifies under the obvious-bug exception: a rejected peer certificate names the wrong failure cause. Scope remains in peer probing and its regression coverage.

Verification

  • The real self-signed HTTPS regression fails on current main with not_a_t3_environment and passes with this fix.
  • Blacksmith: 66 peer tests passed; final simplified listener: 13 module tests passed; vp run check:changed passed formatting, lint, knip, GraphQL, affected typechecks and 14 tests.
  • Real Chrome client: Settings โ†’ Connections โ†’ Link, matching address and data before/after. The error now includes DEPTH_ZERO_SELF_SIGNED_CERT.
  • Two independent code reviews approved head 8c7c1134dc. CI test checks and lint passed. Build and Typecheck is blocked by a main regression: AgentSessionScanner.ts:1203 constructs a TranscriptCandidate without required homePath (TS2741). The same omission exists on current main; this PR does not touch that file. CI log. Macroscope approved, and CodeRabbit returned no actionable code findings. Its description warning is addressed by the scope rationale above.
  • Unverified: native desktop/mobile clients and non-loopback remote TLS. Mixed picked-machine probe results retain their existing generic message.

Evidence

before: linking misidentifies a rejected certificate as no T3 environment

after: linking names the rejected certificate and TLS code

Takeover

Replaces #27128, with thanks to eyeveil for the original implementation.

Built with GPT-6.1-Sol in the Codex harness on T3 Code.

Checks

2 failing ยท 21 successful ยท 8 skipped
Some checks failed

Failing2

8c7c113

Added 1 commit

  • fix(server): name rejected certificates when linking peers8c7c113
Synced from GitHub

Approvability

Verdict: Approved at 8c7c113

Macroscope's review found this PR approvable โ€” Peer-link failures now identify rejected certificates and their TLS error codes. Existing certificate verification, peer identity checks, and credential-handling safeguards remain unchanged.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Thread transfer impact

โœ… Thread transfer remains within every enforced ceiling.

โ„น๏ธ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiBโœ…
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiBโœ…
CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiBโœ…
CodexLive turn WebSocket decoded21.6 KiB21.6 KiB0 B (0.0%)24.4 KiBโœ…
CodexLive turn messages220 (0.0%)8โœ…
ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiBโœ…
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiBโœ…
ClaudeLive turn WebSocket wire1.3 KiB1.3 KiB0 B (0.0%)2.0 KiBโœ…
ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiBโœ…
ClaudeLive turn messages220 (0.0%)8โœ…

Baseline: 80fd67e ยท PR result: 8c7c113 ยท Source CI: failure

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Aauditbenchaireviewed2d ago
Synced from GitHub

Open in Audit Bench Ai

๐Ÿค– Automated review by Audit Bench Ai, not a personal review. It was posted through the GitHub account connected to Audit Bench Ai. Install the Audit Bench Ai GitHub App to have reviews posted by a separate bot account.

No actionable comments were generated in this review. ๐ŸŽ‰

Merge risk: ๐ŸŸข Low ยท up to 8c7c113

The change specifically targets TLS certificate rejections during descriptor probing, while existing link resolution safely catches rejections via Effect.orElseSucceed.

Merge readiness: โ›” Not ready to merge

Pre-merge checks: โœ… 9 ยท โŒ 1

โŒ Failed checks: 1 error

Check nameStatusExplanationResolution
CI checksโŒ2 of 33 failing: Check, Build and Typecheck.Open the failing runs on GitHub and fix them before merging.
โœ… Passed checks: 9 passed
Check nameStatusExplanation
Merge conflictsโœ…Merges cleanly into main.
Secretsโœ…No keys, passwords or tokens in the changed code.
Blocking issuesโœ…No critical or high-severity issues in the changed lines.
Testsโœ…Tests were changed alongside the code.
PR sizeโœ…173 lines changed.
Title checkโœ…The title clearly states that rejected certificates will be named when linking peers.
Description checkโœ…The description clearly explains the problem, proposed solution, and verification results.
Linked issues checkโœ…The PR replaces PR #27128 and directly implements the stated certificate error handling fix.
Out of scope changes checkโœ…All changes are focused on certificate error extraction and test coverage for peer links.
๐Ÿ“ Walkthrough

This PR improves peer linking error reporting when connecting to an HTTPS peer with an untrusted or invalid TLS certificate. Instead of silently discarding the TLS error and reporting that no T3 environment answered, the server now traverses the error cause chain to identify Node certificate errors and surface them explicitly. Existing behavior for stored link fallback and peer resolution is preserved via fallback handling in answersAs.

FileChanges
apps/server/src/peer/PeerLinks.test.tsAdds unit and integration tests verifying TLS certificate error extraction and peer linking behavior against an untrusted HTTPS server.
apps/server/src/peer/PeerLinks.tsExtracts TLS certificate error codes from failure causes and fails describe with an explicit message instead of returning empty results.
โ„น๏ธ Review info
  • Commit: 8c7c113
  • Verdict: โœ… Pass
  • Findings: none
  • Review: local checks plus AI review of the changed lines
  • Scope: Reviewed 2/2 selected files (of 2 total): 2 reviewed by AI, 0 from cache, 0 passed local checks with nothing risky enough to send to AI. Found 0 finding(s), No secrets found.

๐Ÿ’ฌ Reply to any inline comment and Audit Bench Ai will recheck that code and answer in the thread. Mention @auditbench in the conversation to ask about the whole PR.

๐Ÿ› ๏ธ Open the full report and fix with AI

Thanks for using Audit Bench Ai! Free pull request reviews for open source: paste any public PR at auditbenchai.com/scan.

Reviewed by Audit Bench Ai ยท AI code review for security, logic and performance ยท Review any public PR free

Synced from GitHub

Review in Change Stack โ†’

No actionable comments were generated in the recent review.

External image Recent review info
External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between 94a53a2f79c3b61f3a94ac6a97311ce0deb69306 and 8c7c1134dcf3edc51d51ed2522dc066ae5fd3515.

External image Files ignored due to path filters: 2
  • apps/server/src/peer/fixtures/localhost-cert.pem is excluded by !**/*.pem
  • apps/server/src/peer/fixtures/localhost-key.pem is excluded by !**/*.pem
External image Files selected for processing: 2
  • apps/server/src/peer/PeerLinks.test.ts
  • apps/server/src/peer/PeerLinks.ts

Limit details: Youโ€™ve used all 10 included reviews currently available.

Walkthrough

PeerLinks now detects recognized TLS certificate errors, reports them during linking, and treats failed probes as no match during environment checks. Status and resolution checks use environment identity verification, allowing resolution to continue to a later candidate after a certificate rejection.

Changes: Peer link TLS handling

Layer / File(s)Summary
Certificate error detection and probe handling
apps/server/src/peer/PeerLinks.ts, apps/server/src/peer/PeerLinks.test.ts
certificateErrorCode searches nested error causes for recognized TLS certificate codes. describe reports certificate failures and maps ordinary probe failures to no descriptor. Tests cover the error codes and untrusted-certificate behavior.
Candidate environment checks
apps/server/src/peer/PeerLinks.ts, apps/server/src/peer/PeerLinks.test.ts
statusOf and resolve use answersAs to verify the expected environment ID. Tests verify that resolution tries a later address after an untrusted certificate.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

Suggested labels: bugfix, size:M

Suggested reviewers: juliusmarminge

Merge Risk: External image Minimal ยท up to 8c7c1

No merge-blocking risk was identified in the certificate-handling change.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the main change: naming rejected TLS certificates when linking peers. It uses a conventional commit format.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Description checkPassedThe pull request description includes all required sections: Problem, Change, Scope and approval, and Verification. It describes the failure, the fix, approval basis, focused test results, observed beโ€ฆ
Full details: Description check

Explanation

The pull request description includes all required sections: Problem, Change, Scope and approval, and Verification. It describes the failure, the fix, approval basis, focused test results, observed behavior, blocked checks, unverified areas, and evidence. It also includes the required agent and harness details.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix ยท Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Aauditbenchaireviewed2d ago
Synced from GitHub

Open in Audit Bench Ai

๐Ÿค– Automated review by Audit Bench Ai, not a personal review. It was posted through the GitHub account connected to Audit Bench Ai. Install the Audit Bench Ai GitHub App to have reviews posted by a separate bot account.

No actionable comments were generated in this review. ๐ŸŽ‰

Merge readiness: โ›” Not ready to merge

Pre-merge checks: โœ… 5 ยท โŒ 1

โŒ Failed checks: 1 error

Check nameStatusExplanationResolution
CI checksโŒ2 of 34 failing: Check, Build and Typecheck.Open the failing runs on GitHub and fix them before merging.
โœ… Passed checks: 5 passed
Check nameStatusExplanation
Merge conflictsโœ…Merges cleanly into main.
Secretsโœ…No keys, passwords or tokens in the changed code.
Blocking issuesโœ…No critical or high-severity issues in the changed lines.
Testsโœ…Tests were changed alongside the code.
PR sizeโœ…173 lines changed.
โ„น๏ธ Review info
  • Commit: 8c7c113
  • Verdict: โœ… Pass
  • Findings: none
  • Review: local checks plus AI review of the changed lines
  • Scope: Reviewed 2/2 selected files (of 2 total): 0 reviewed by AI, 2 from cache, 0 passed local checks with nothing risky enough to send to AI. Found 0 finding(s), No secrets found.

๐Ÿ’ฌ Reply to any inline comment and Audit Bench Ai will recheck that code and answer in the thread. Mention @auditbench in the conversation to ask about the whole PR.

๐Ÿ› ๏ธ Open the full report and fix with AI

Thanks for using Audit Bench Ai! Free pull request reviews for open source: paste any public PR at auditbenchai.com/scan.

Reviewed by Audit Bench Ai ยท AI code review for security, logic and performance ยท Review any public PR free