Skip to content

fix(desktop): verify single-stanza APT source identity - #12363

Merged
morluto merged 12 commits into
morluto:mainfrom
ShuaixinHuang:fix/apt-single-stanza-identity
Nov 20, 2026
Merged

morluto merged 12 commits into
morluto:mainfrom
ShuaixinHuang:fix/apt-single-stanza-identity

Conversation

@ShuaixinHuang

@ShuaixinHuang ShuaixinHuang commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Validate URI and suite identity for single-URI deb822 source stanzas when matching APT index targets.

Problem

entryForTarget treated every stanza with one URI and one suite as an exact match. A .sources stanza with one URI therefore returned a repository entry even when APT's observed Repo-URI belonged to another source or the observed release differed from the authored suite. Package attribution and replay could attach an APT index to the wrong declaration.

One-line entries retain their existing exact-single-entry behavior. Deb822 entries now use the same observed URI and release checks as multi-value stanzas.

Validation

  • The new regression failed on main for a mismatched URI and mismatched release.
  • After the fix, aptRepositories.test.ts and AptRepositoryInventory.test.ts passed: 51 tests.
  • git diff --check passed.
  • Formatting passed with oxfmt.

No target or external provider was used.

Review follow-up

e4fdc8f937 matches both URI and suite templates using APT::Architecture and keeps the authored spellings. The source parser also carries its format fact directly to match selection. Offline APT 2.6.1 and 3.2.0 passed the configured-architecture and unavailable-configuration cases. All 124 targeted tests passed with seven platform skips. check:fast and docs:check passed.

Follow-up validation: the APT lookup identity now removes an empty authority port while retaining the authored URI. The source-matching regression and all 40 APT repository tests passed.

Author readiness

Human owner: @ShuaixinHuang

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Summary

Validate URI and suite identity for single-URI deb822 source stanzas when matching APT index targets.

Problem

entryForTarget treated every stanza with one URI and one suite as an exact match. A .sources stanza with one URI therefore returned a repository entry even when APT's observed Repo-URI belonged to another source or the observed release differed from the authored suite. Package attribution and replay could attach an APT index to the wrong declaration.

One-line entries retain their existing exact-single-entry behavior. Deb822 entries now use the same observed URI and release checks as multi-value stanzas.

Validation

  • The new regression failed on main for a mismatched URI and mismatched release.
  • After the fix, aptRepositories.test.ts and AptRepositoryInventory.test.ts passed: 51 tests.
  • git diff --check passed.
  • Formatting passed with oxfmt.

No target or external provider was used.

Review follow-up

e4fdc8f937 matches both URI and suite templates using APT::Architecture and keeps the authored spellings. The source parser also carries its format fact directly to match selection. Offline APT 2.6.1 and 3.2.0 passed the configured-architecture and unavailable-configuration cases. All 124 targeted tests passed with seven platform skips. check:fast and docs:check passed.

Empty-port identity: APT 2.8.3 indextargets reports Repo-URI: https://vendor.invalid/archive/ for URIs: https://vendor.invalid:/archive. Lookup omits an empty or all-zero port and keeps the authored URI. entryForTarget asserts the structured entry, and repository facts assert the authored URI, suite, and signing key. oxfmt, npm run check:fast, and the focused tests passed (56 tests) at 1c20192d8. Merged origin/main.

Port suffixes: APT 2.8.3 parses the host's last colon suffix with atoi into an unsigned 32-bit port. https://vendor.invalid:80abc/archive reports Repo-URI: https://vendor.invalid:80/archive/, and :https is portless. IPv6 brackets stay in place. The authored URI is unchanged. entryForTarget and repository facts assert those structured values, including the signing key. oxfmt, npm run check:fast, and the focused tests passed (75 tests) at 27ea7d34f.

Architecture tokens and bounded ports: APT 2.8.3 expands $(ARCH) to x86_64. That GNU CPU name is kept; a slash-bearing value is not. Port magnitudes stop growing at the signed 64-bit limit, and the unsigned port matches APT for long, signed, and overflowing suffixes. oxfmt, npm run check:fast, and the focused tests passed (93 tests) at 7a0863c7f.

Empty file://: APT 2.8.3 reports Repo-URI: file:// for URIs: file://, and file:/ for file:///. A Packages index with that Repo-URI keeps the authored URI and suite. file:///srv still becomes file:/srv/. oxfmt, npm run check:fast, and the focused tests passed (96 tests) at 11f1d171b.

Scheme shorthand: APT 2.8.3 reports Repo-URI: http://127.0.0.1:18743/archive/ for URIs: http:127.0.0.1:18743/archive. The comparison uses that form and the entry keeps the authored URI. copy:/srv and file:// stay as before. Bracket removal copies each host character once; a 16384-pair bracket host still returns the authored URI and suite. oxfmt, npm run check:fast, and the focused tests passed (101 tests) at d3d54bb1e.

Maintainer follow-up

Commit 3a1cb5b34a preserves the concrete suite APT observed during capture and shares the replay identity across package attribution, source deduplication, and export. Older captures with only an unresolved suite template request recapture. Offline APT checks covered replay across different architecture settings and confirmed delimiter-only file URIs, authority shorthand, and bracketed host normalization.

The focused suite passed with 248 tests and 11 skips. check:fast and docs:check passed. Validation used offline APT with no AgentEnv run.

Author readiness

Human owner: @ShuaixinHuang

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.
Open in Web Open in Cursor 

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T02:06:17.099742Z 3a1cb5b New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

The PR checks single-stanza deb822 sources against APT’s observed URI and suite. The latest changes preserve the concrete suite for export while keeping the authored value.

  • Deb822 sources match only the APT index URI and suite they actually declare.
  • APT exports replay the concrete suite selected during capture.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Authored source] --> C[Match APT target]
  B[APT URI and selected suite] --> C
  C --> D[Capture authored values and observed identity]
  D --> E[Shared replay identity]
  E --> F[Attribute package indexes]
  E --> G[Deduplicate exported sources]
  G --> H[Declare AptSource]
Loading

Reviews (10) · Last reviewed commit: "fix(desktop): replay the APT suite selec..." · Reviewed by Greptile

Comment thread src/domain/desktop/aptRepositories.ts Resolved

@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: 55b141b035

ℹ️ 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 src/domain/desktop/aptRepositories.ts Resolved

@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: e4fdc8f937

ℹ️ 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 src/domain/desktop/aptRepositories.ts Resolved
ShuaixinHuang and others added 3 commits November 19, 2026 23:35
Assert entryForTarget and repository facts keep the authored empty-port URI while matching the portless Repo-URI APT 2.8.3 emits, including the signing key.

Co-authored-by: morluto <[email protected]>

@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: 1c20192d81

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/desktop/aptRepositories.ts Resolved
Match deb822 Repo-URI identity to APT's unsigned port: the host's last colon suffix is atoi'd, zero is omitted, and IPv6 brackets stay intact while the authored URI is kept.

Co-authored-by: morluto <[email protected]>

@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: 27ea7d34f5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/desktop/AptRepositoryInventory.ts Resolved
Comment thread src/domain/desktop/aptRepositories.ts Resolved
Keep x86_64 as an APT architecture token for $(ARCH) identity, and stop growing a port magnitude once it passes the signed 64-bit limit.

Co-authored-by: morluto <[email protected]>

@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: 7a0863c7f9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/desktop/aptRepositories.ts Resolved
An empty host with no path stays scheme://, matching APT 2.8.3. A path after that host still drops it, so file:///srv remains file:/srv.

Co-authored-by: morluto <[email protected]>

@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: 11f1d171b5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/desktop/aptRepositories.ts Resolved
Comment thread src/domain/desktop/aptRepositories.ts Resolved
APT 2.8.3 rewrites http:127.0.0.1:18743/archive to an http:// Repo-URI. Identity comparison follows that form and keeps the authored URI. Bracket removal copies each host character once.

Co-authored-by: morluto <[email protected]>

@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: d3d54bb1e3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/domain/desktop/aptRepositories.ts Resolved
@morluto
morluto merged commit 192934c into morluto:main Nov 20, 2026
41 checks passed
morluto added a commit that referenced this pull request Nov 20, 2026
Refs #12694. Preserve authored spelling beside the effective suite and component values shared by attribution and export. This candidate is based on the suite ownership work in #12363.
@morluto morluto added the area: tests Test suite and verification label Nov 22, 2026
@morluto morluto added the bug Something isn't working label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants