Skip to content

pkg reads the canonical purl it writes, and carries the namespace to the driver - #871

Merged
David-Noble-at-work merged 3 commits into
developfrom
fix/813-canonical-purl-form
Sep 9, 2026
Merged

David-Noble-at-work merged 3 commits into
developfrom
fix/813-canonical-purl-form

Conversation

@David-Noble-at-work

@David-Noble-at-work David-Noble-at-work commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

pkg.Resource emitted purl.String() as a resource's identity and could not read that form back: buildCandidate cut a package string at its first colon and handed the prefix to the platform's type resolver, so pkg:winget/Vim/Vim?scope=machine was refused as an unknown package manager named pkg. This is the fix, in two halves.

  • The parse. The pkg: scheme is checked before the manager-prefix form, and the string goes through platform.ParsePURL. The two grammars are otherwise ambiguous, since pkg reads as a legal manager prefix. A pkg: string the parser rejects is refused with the parser's message and never re-read as a prefix: once a string declares the scheme it is a purl, and a fallback would turn a typo into a package named after it. A well-formed purl whose type no manager answers to is refused naming the type.
  • The projection, which is what reaches the driver. The resource now carries the namespace and qualifiers a purl exists to express, both identity and both in the URI, and one purl() method replaces the five sites that rebuilt a platform.PURL from name and type alone. Without this half, parsing the namespace changes nothing: winget would still be asked for Vim rather than Vim.Vim.

Nothing in pkg/platform changes. The winget driver already joins Namespace + "." + Name; it had simply never been handed a namespace.

Also: the manifest schema documents the three accepted forms with an example of each, and a scenario fixture plans a purl-named package on each platform's own manager.

Plan: docs/plans/fix/813-canonical-purl-form.md (complete). The ruling the issue recorded as pending was settled by its own acceptance criteria — option 1, the provider accepts the canonical form — and this PR does not reopen it.

What the work found

  • The round-trip criterion names the wrong accessor, and the right one makes two criteria one. The issue asks that DiscoverResource(env, r.URI()) yield the same entry; URI() is the tag-wrapped form, while the contract unpackCatalog relies on is ReachabilityURI(), the scheme-specific part a provider emits and reads back. For pkg that part is the canonical purl, so the parse criterion and the round-trip criterion are one property read twice.
  • A scenario fixture does not run unless a Go test names it. devlore-test's data/*.star files are not auto-discovered. The fixture was added, the suite stayed green, and it had never executed — caught by running it explicitly. TestPkgCanonicalPurl names it now.

Acceptance — #813

  • pkg:winget/Vim/Vim?scope=machine, pkg:brew/[email protected] and the existing brew:jq / jq forms all construct; a malformed purl is refused with the parser's message — TestNewResource_AcceptsTheCanonicalPurlForm, TestNewResource_AMalformedPurlReportsTheParsersMessage, TestNewResource_AnUnknownPurlTypeIsRefused
  • The constructor round-trips its own URI — TestResource_URIRoundTripsThroughTheConstructor, pinned on the reachability URI per the note above
  • schema/packages-manifest.json documents every accepted form of name
  • A unit test per form in pkg/op/provider/pkg, and a devlore-test fixture that plans a purl-named package
  • writ deploy noblefactor --dry-run on DANOBLE-WD11-3 passes the personal layer's Windows manifest — yours: it needs the VM, which is parked, and the reversal of the workaround commit on Personal (the manifest returns to pkg:winget/Vim/Vim?scope=machine)

Closes #813.

https://claude.ai/code/session_01SqQVFZz7AdiLZkGoAcUqRW

Time

Marker UTC Elapsed
opened (first commit) 2026-09-08T22:23:24Z —
submitted (PR opened) 2026-09-09T01:39:08Z 3.3 h after opened
merged 2026-09-09T01:53:50Z 0.2 h after submitted; 3.5 h in all

Computed by the algorithm of noblefactor-ops#188 at merge.

David Noble added 3 commits September 8, 2026 15:23
A draft for review before any code. The constructor cuts at the first colon, so
a purl's own scheme reads as an unknown manager, while the same function emits
purl.String() as the URI. Found while sizing: the winget driver already joins
namespace and name and has simply never been handed a namespace, so the fix is
confined to the provider -- and five sites rebuild a PURL by hand, which is
where a parsed namespace would still be lost.

Refs #813.

Claude-Session: https://claude.ai/code/session_01SqQVFZz7AdiLZkGoAcUqRW
…the driver

The constructor cut a package string at its first colon, so a purl's own scheme
read as an unknown manager named "pkg" while the same function emitted
purl.String() as the resource's URI. It now checks the scheme first and parses
through platform.ParsePURL; a malformed purl reports the parser's message
rather than falling back, since a fallback turns a typo into a package name.

The resource carries the namespace and qualifiers a purl exists to express,
both identity and both in the URI, and one projection replaces the five
hand-built PURLs that dropped them -- without which winget would still be asked
for "Vim" rather than the "Vim.Vim" its driver already knows how to join.

The schema documents the three accepted forms, and a scenario fixture plans a
purl-named package on each platform's own manager.

Refs #813.

Claude-Session: https://claude.ai/code/session_01SqQVFZz7AdiLZkGoAcUqRW
@David-Noble-at-work David-Noble-at-work self-assigned this Sep 9, 2026
@David-Noble-at-work
David-Noble-at-work merged commit 55a6859 into develop Sep 9, 2026
13 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the fix/813-canonical-purl-form branch September 9, 2026 01:54
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.

pkg.Resource rejects the canonical purl form its doc promises: "pkg:winget/Vim/Vim?scope=machine" fails as unknown package manager "pkg"

1 participant