oficina / estilo Public

colophon: a default note holds for every dependent it names, each shipping

Claude Fable 5.1 on #28 (55f3dcb):

- reachedVia accepted a note when any one named dependent reached the
  crate, so "DashMap and aHash use it." passed in an app reaching
  once_cell through DashMap alone. Every named project must use the crate
  directly now.
- A dependent the app only builds or tests with counted. It counts now
  only when the crate itself is only a tool there; a shipped crate's note
  rests on what ships.
- implementation/colophon.json records the reviews through #28.

Docs' web and Apple graphs pass the stricter rule unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 696e5e2c302232acadfd8252461415f21b55c5df parent aa90aac
3 files changed, +66 −18
  • colophon/colophon.go +27 −17
  • colophon/colophon_test.go +38 −0
  • implementation/colophon.json +1 −1

CI failed — run details

diff --git a/colophon/colophon.go b/colophon/colophon.go
index 2f47b33..98901a8 100644
--- a/colophon/colophon.go
+++ b/colophon/colophon.go
@@ -117,8 +117,9 @@ type Project struct {
Uses map[string]string `json:"uses"`
// Via is the projects (catalog ids) a "*" note names as what uses this
// one ("serde_json uses it." is via serde-json). A crate's default note
- // is true in an app only if the crate is reached there through one of
- // them, so Build checks it against the dependents CollectCargo records.
+ // is true in an app only if every one of them uses the crate there,
+ // through a package that ships, so Build checks it against the
+ // dependents CollectCargo records.
Via []string `json:"via,omitempty"`
}
@@ -466,27 +467,36 @@ func build(projects []Project, app string, shipped []Package) (Colophon, error)
return c, nil
}
-// reachedVia reports whether one of packages is used directly by a
-// shipped package of one of the projects p's default note names.
+// reachedVia reports whether every project p's default note names uses
+// one of packages directly ("DashMap and aHash use it." needs both), each
+// through a package it ships. A dependent the app only builds or tests with
+// counts only when the crate itself is only a tool there too: a shipped
+// crate's note must not rest on something that does not ship.
func reachedVia(p Project, packages []Package, projects []Project, owner map[Ref]int, byProject map[int][]Package) bool {
- named := map[string]bool{}
- for _, v := range p.Via {
- named[v] = true
- }
+ onlyTool := true
for _, pkg := range packages {
- for _, user := range pkg.Via {
- i, ok := owner[Ref{pkg.Ecosystem, user}]
- if !ok || !named[projects[i].ID] {
- continue
- }
- for _, shipped := range byProject[i] {
- if shipped.Name == user {
- return true
+ onlyTool = onlyTool && pkg.Tool
+ }
+ for _, named := range p.Via {
+ uses := false
+ for _, pkg := range packages {
+ for _, user := range pkg.Via {
+ i, ok := owner[Ref{pkg.Ecosystem, user}]
+ if !ok || projects[i].ID != named {
+ continue
+ }
+ for _, shipped := range byProject[i] {
+ if shipped.Name == user && (!shipped.Tool || onlyTool) {
+ uses = true
+ }
}
}
}
+ if !uses {
+ return false
+ }
}
- return false
+ return true
}
func union(a, b []string) []string {
diff --git a/colophon/colophon_test.go b/colophon/colophon_test.go
index 829b1b4..578e986 100644
--- a/colophon/colophon_test.go
+++ b/colophon/colophon_test.go
@@ -567,3 +567,41 @@ func TestADefaultNoteMustNameADependentThatShips(t *testing.T) {
t.Fatalf("a default note naming no dependent was accepted: %v", err)
}
}
+
+// A default note that names several dependents ("DashMap and aHash use
+// it.") is true only where every one of them uses the crate, and a
+// dependent the app only builds or tests with does not count: it is not
+// in what ships.
+func TestADefaultNoteNeedsEveryNamedDependentShipping(t *testing.T) {
+ base := func() []Project {
+ cat := testCatalog()
+ mk := func(id, crate, note string, via ...string) Project {
+ p := Project{ID: id, Name: crate, Kind: Library, Blurb: "A crate.", Author: "Someone", Licence: Licence{"MIT", "MIT License"}, Home: "https://crates.io/crates/" + crate, Source: "https://github.com/x/" + crate, Packages: []Ref{{Cargo, crate}}, Uses: map[string]string{"docs": "Ships."}}
+ if note != "" {
+ p.Uses = map[string]string{"*": note}
+ p.Via = via
+ }
+ return p
+ }
+ return append(cat, mk("once-cell", "once_cell", "DashMap and aHash use it.", "dashmap", "ahash"), mk("dashmap", "dashmap", ""), mk("ahash", "ahash", ""))
+ }
+ pkg := func(name string, tool bool, via ...string) Package {
+ return Package{Ecosystem: Cargo, Name: name, Version: "1.0.0", Tool: tool, Via: via, Notices: notice(name)}
+ }
+ for name, tc := range map[string]struct {
+ shipped []Package
+ ok bool
+ }{
+ "both name it and both ship": {[]Package{pkg("dashmap", false), pkg("ahash", false), pkg("once_cell", false, "ahash", "dashmap")}, true},
+ "only one of the two uses it": {[]Package{pkg("dashmap", false), pkg("ahash", false), pkg("once_cell", false, "dashmap")}, false},
+ "one of the two is only a tool": {[]Package{pkg("dashmap", false), pkg("ahash", true), pkg("once_cell", false, "ahash", "dashmap")}, false},
+ "the crate itself is only a tool": {[]Package{pkg("dashmap", true), pkg("ahash", true), pkg("once_cell", true, "ahash", "dashmap")}, true},
+ } {
+ t.Run(name, func(t *testing.T) {
+ _, err := build(base(), "docs", append(shippedSet(), tc.shipped...))
+ if (err == nil) != tc.ok {
+ t.Fatalf("accepted=%v, want %v (%v)", err == nil, tc.ok, err)
+ }
+ })
+ }
+}
diff --git a/implementation/colophon.json b/implementation/colophon.json
index f4a1dbf..77b848b 100644
--- a/implementation/colophon.json
+++ b/implementation/colophon.json
@@ -6,5 +6,5 @@
"builds_on": "credits (Notice, Lucide, Onest) and credits/catalog (Collect, and its notice-filename rule, now exported as NoticeFilename). The credits page and oficina-notices are unchanged for the apps that use them.",
"no_flash": "No script and no face: colophon.css sets no font but inherit, fetches nothing (TestStylesheetDeclaresNoFaceAndReadsOnlyDefinedTokens). Docs' browser check confirms zero loaded faces and the system UI face at 320 and 1200px with scripts on and off.",
"first_consumer": "Docs, branch feat/colophon (web Help → Colophon and the Apple apps' native Colophon from the same Build).",
- "review": "Claude Fable 5.1 (claude-fable-5-1) on #27 at b674411: needs changes (P1 dt shrink at 320px; P2s capitalised, catalog accuracy and tone, lang=en, default usage note, macro/build crates as tools). All addressed at 22a7cfe and after; re-review pending."
+ "review": "Claude Fable 5.1 (claude-fable-5-1) reviewed #27 three times: needs changes at b674411 (P1 dt shrink at 320px; P2s on capitalised, catalog accuracy and tone, lang, a default usage note, macro and build crates as tools), ready to merge at 6fb210c, squashed to main as 1ce6d25. Its follow-ups (lang marked node by node, default notes checked against the crates that use them) were #28, ready to merge at 55f3dcb, main aa90aac. fix/colophon-via-every answers #28's review: a default note must hold for every dependent it names, each shipping."
}