Repository navigation
Refactor: Take the top level to seven directories and rename authlib to core - #1142
Conversation
The flatten removed the vestigial authbridge/ level and exposed two things it had been hiding: the root does not describe the product (four of ten directories are implementation satellites), and the names are a product generation behind. authlib is the sharpest case, and not merely because of the AuthBridge->Cortex rename. Measured by non-test lines it is 1.7% auth: 65% framework, 22% cost, 10% observability. The docs compound it, calling it "the shared auth library" and enumerating the 1.7% first while omitting the 32%. Scope deliberately excludes every published contract — image names the operator selects by name, binary names on users' PATH, the x-authbridge-* wire headers injected by Helm-rendered Envoy config, the AUTHBRIDGE_* env vars install.sh accepts, the authbridge-* ConfigMaps, /etc/authbridge, authproxy-routes, the abph_ prefix, and install.sh's --ref probe. "Do not break anything" is written as twelve gates rather than an intention. Section 6 carries forward the class that cost rossoctl#1134 a review round: its substitutions matched authbridge/ WITH a trailing slash, so sixteen bare-directory spellings survived. authlib has nineteen of the same shape, enumerated by count. Unlike rossoctl#1134 the replace directives DO change, both sides, five of them. Self-review caught three errors of mine before commit: the module count is 12 not 13 (storage/redis is already one of them, so moving it adds none), there are five build profiles not four (cpex is image-only, needing cgo), and "build.yaml's six name: values" was a bad gate since a grep for '- name:' returns 15 including step names. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
Six tasks, one per commit, so a rename touching 850 import sites can be reviewed piecewise: group the deployables under deploy/, consolidate the loose dev scripts, rename authlib to core, move the redis driver beside the interface it implements, rename five packages inside core/, then fix the prose and retire the script. Three lessons from rossoctl#1134 are wired into the mechanics rather than left as advice. Every substitution matches the bare name without requiring a trailing slash — that omission is exactly what let sixteen spellings survive the flatten, nine of them cd lines whose blocks then failed at step 1. Verification decomposes by shape (raw mentions, then each spelling) instead of trusting the patterns. And pytest is in the gate set, which it was not last time, when a dead parents[1] path broke collection. Two hazards are named where they live. Task 2: the dev scripts compute REPO_ROOT from SCRIPT_DIR, so moving them one level deeper changes that arithmetic — the identical hazard was live in the previous PR. Task 5: the new package names `event` and `settle` are short common words, so a local variable can shadow the new package; only the build proves it. Unlike the flatten, the replace directives change on both sides, and storage/redis is the only directory that changes depth. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
Move proxy-init/, sparc-service/, and lineage-attach/ under a new deploy/ directory. All three run in-cluster beside the sidecar: proxy-init and sparc-service are published images with their own build contexts, and lineage-attach is cluster-attach tooling with a Dockerfile that is deliberately not in build.yaml. Grouping them makes that shared shape visible at the top level instead of leaving three unrelated-looking directories at repo root. No published contract changes: image name: values in .github/workflows/build.yaml are untouched (the operator selects images by name), only their context: paths move. install.sh is untouched. Nothing is renamed here -- only moved. Swept every reference to the three old paths across CI workflows, dependabot config, the root Makefile, scripts, docs, and demos, distinguishing filesystem paths (updated) from same-named identifiers that must not change: image names, Deployment/Service names, DNS names, container names, and CI job ids. Found and fixed two path-arithmetic bugs where a script/doc computed a path relative to its own file location and would have silently broken one level deeper after the move: deploy/lineage-attach/RECIPE.md's `cd ..` (now `cd ../..`) and CLAUDE.md's matching build-instructions snippet. Verified: docker builds of both moved images from their new deploy/ contexts, GOWORK=off go build ./... in authlib, and sh install_test.sh (113 passed). Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
Moves local-build-and-test.sh, verify-spire-keycloak.sh, and verify-moved-ca-diagnostics.sh into scripts/dev/ so scripts/ reads as four clear things: dev/, hooks/, profile-tags/, readme-demo/. Fixes the REPO_ROOT arithmetic in local-build-and-test.sh (one more level of ../) and the repo-root cd in verify-moved-ca-diagnostics.sh, and updates every reference in CLAUDE.md, CONTRIBUTING.md, and .claude/skills/demo/SKILL.md plus each script's own header comments. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
The three deployables moved one level deeper, so relative links out of their READMEs — to .github/, demos/, docs/ and authlib/ — now land in deploy/ and 404. Nothing in the diff showed it: the link text never changed, only the ground beneath the file. This is the class that cost rossoctl#1134 a review round, and it is gate 11 of the design spec. The Task 1 brief named the prose-cd shape and not this one, so both the implementer's sweep and my own verification missed it. Grep-by-name cannot see it — a link's text does not mention the moved directory. Only resolving targets on disk finds it, checked against the base commit to tell a new break from a pre-existing one. deploy/sparc-service/deploy/README.md needed ../../../ for its three docs/ links while keeping ../README.md, which points at its own parent and already resolved. A blanket ../ -> ../../ would have broken it. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
authlib is 1.7% auth by non-test lines (882 of ~50,000) -- it is the shared framework, cost, and observability module every binary imports. "core" names what it actually is. Mechanical rename via scripts/layout-migrate.sh (committed alongside, so review is "re-run it and diff"): git mv authlib core, the module path, all seven replace directives (five single-line, two inside a replace (...) block), ~850 import occurrences across ~393 files, and bare-word path/prose references across yaml/yml/md/sh/py/Makefile/ Dockerfile/go.work. docs/superpowers/ (dated archive) and install.sh are excluded by design and untouched. Beyond the corrected script: fixed three functional survivors the script's patterns don't model -- two test guards comparing import-path suffixes (cmd/authbridge-cpex, cmd/authbridge-envoy main_test.go) and one regexp literal with escaped dots (scripts/profile-tags/ guards_test.go) that would otherwise silently stop matching anything and pass vacuously. Also swept the ~150 bare "authlib" mentions left in Go comments and go.mod comments (not reachable by the script's non-Go bare-word rule) so the repo carries zero mentions outside the two excluded paths. No published contract changed: image names, binary names, x-authbridge-* headers, AUTHBRIDGE_* env vars, authbridge-* ConfigMaps, /etc/authbridge/*, authproxy-routes, and the abph_ prefix are untouched. Signed-off-by: Hai Huang <huang195@gmail.com> Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
The plan commits this script so review can be "re-run it and diff". As
committed it could not: re-running it from the base left 144 survivors,
because the bare-word rule was scoped to non-Go files and the Go-side
references were then fixed by hand.
Three of those were not prose. They are references written in a syntax
no plain module-path substitution can match: a regexp literal with
escaped dots in scripts/profile-tags/guards_test.go, and two guards in
cmd/authbridge-{cpex,envoy}/main_test.go comparing a quoted import-path
suffix, "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/authlib/costledger" and "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/authlib/usage". Left alone each one
goes quietly inert -- the string stops matching, so the test still
passes while the assertion no longer asserts anything. That is the most
useful shape this refactor has surfaced, and a script that silently
omits it is worse than no script.
Extending the bare-word rule to *.go and go.mod covers all three, and
is safe: authlib is nowhere a Go identifier or import alias, and sits
in no string literal, struct tag, go:embed directive or testdata
fixture where it is data rather than a path.
Verified by re-running the corrected script against a fresh checkout of
the base: zero survivors, and the resulting tree is byte-identical to
the rename commit.
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
storage/redis implements core/storage's Store interface but lived as a
sibling of the library rather than beside it. Move it to
core/storage/redis, keeping it as its own Go module (its go.mod still
declares github.com/rossoctl/cortex/core/storage/redis) so the Redis
dependency stays out of core's dependency graph.
Updates every reference to the old path: go.work, dependabot.yml, the
require/replace directives in cmd/authbridge-{proxy,envoy}/go.mod, the
blank imports in both plugins_sessionbudget.go files (the session-budget
plugin's redis registration), and the CLAUDE.md prose/tree. Deletes the
now-dead COPY storage/ storage/ line from the proxy, envoy, and praxis
Dockerfiles (core/ already carries it one line earlier) and updates
praxis's build-context comment. The module's own replace for core
becomes ../.., since the target moved closer even though the module
moved deeper.
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
Rename nine core packages so their names describe what they do, not their history: core/shared -> core/memstore core/runtimeutil -> core/bootstrap core/contracts -> core/capabilities core/tls -> core/tlsconfig core/pricing -> core/cost/pricing core/costing -> core/cost/settle core/costledger -> core/cost/ledger core/costevent -> core/cost/event core/usage -> core/cost/usage Every import site, package clause, and identifier prefix (costing.*, costledger.*, costevent.*) was swept across all 12 Go modules, plus comment-only path mentions in Go source and prose references in docs and scripts that a plain identifier sweep does not touch. No published contract changed: image names, binary names, x-authbridge-* headers, AUTHBRIDGE_* env vars, authbridge-* ConfigMaps, /etc/authbridge/*, authproxy-routes, and the abph_ prefix are all untouched, and install.sh has zero diff against the branch point. docs/superpowers/ keeps its stale paths as a dated archive, by design. All 12 modules build, vet, and test clean with GOWORK=off, including the cpex build tag and both sessionbudget-tagged builds, and go mod tidy -diff is clean everywhere. The markdown relative-link checker and the contract-count checks (AUTHBRIDGE_, x-authbridge-direction, /etc/authbridge, abph_) are unchanged from the branch point. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
Renaming authlib to core changed how gofmt wants 16 import blocks ordered, and nothing caught it: gofmt is gated nowhere here, because ci.yaml runs `go fmt ./...`, which is `gofmt -l -w` — it rewrites the checkout and exits 0, so drift cannot fail a build. The cause is alphabetical, not cosmetic. `authlib` sorted before sibling paths like `cmd/abctl/apiclient`; `core` sorts after them, so every import block mixing the two needed resequencing. Measured per commit: the repo carries 6 gofmt-dirty files on main and stayed at 6 through the deploy/ and scripts/dev/ moves, then went to 22 at the rename and stayed there. This restores it to those same 6, which are pre-existing and left alone deliberately — fixing them would add unrelated churn to a layout PR. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
…nded Every one of the seven renamed packages still opened with `// Package <oldname>`, so `go doc` and pkg.go.dev would have shown the wrong name for all seven. Nothing caught it: a godoc header names the bare identifier with no path prefix, so neither the `core/<oldname>` path sweep nor the `^package <oldname>$` clause rule can see it. It is the eighth distinct shape in this refactor that a substitution sweep is structurally blind to. Seven files were also still named after the package they no longer belong to — runtimeutil.go in package bootstrap, costing.go in settle, costevent.go in event, plus their tests. Renamed, since a filename that names a package is stale the moment that package is renamed, and filenames reflecting what they hold is part of the point here. Verified with `go doc` on each of the seven, which now reports the package's real name. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
…ript
The docs called it "the shared auth library" and enumerated it as
"validation, exchange, cache, bypass, spiffe, routing, auth, config" —
listing the 1.6% first and omitting the 57%. core/README.md named 11 of
its 25 packages and left out the entire cost group, which is 21% of the
module, along with listener, which is most of the rest.
It also claimed, twice, "no protocol dependencies (no gRPC, no Envoy)".
That stopped being true when the listeners moved in: listener/extproc
is an Envoy ext_proc gRPC server, and core has 20 direct dependencies
including grpc, go-control-plane, OPA, OpenTelemetry and CPEX. The
README's dependency list named three of them.
Every package description now comes from that package's own doc comment,
and the theme table is measured on this branch rather than inherited from
the design spec, whose figures no longer match.
Two judgement calls worth knowing about:
Comments naming a renamed package now use the import-path form —
cost/ledger, not ledger. The bare leaf names read badly in prose
("event is explicit that no consumer may add money" is ambiguous), and
the path form is what a reader would grep for.
The 21 runtime log and error prefixes that say "costledger: ..." are
left alone, in three non-test files. They are observable output an
operator greps and alerting may key on; they are not wrong, since the
subsystem is still the cost ledger; and "ledger:" would say less than
"costledger:" does. Renaming observable output is a separate decision
with its own blast radius, not something to fold into a layout change
whose whole premise is that no published contract moves.
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
The whole-branch review found one functional break and two more classes of reference that no substitution rule could have caught. `make pricing-table` was broken. Makefile still ran `go run ./pricing/internal/gen -dir ./pricing` from inside core, where it is now `./cost/pricing`. No CI job runs the target, and it is the documented recovery path cited by seven code sites and docs/plugin-catalog.md. The ninth shape: a path that never gained a new parent. The five cost packages moved DEEPER, so a reference mapping old leaf to new leaf comes out wrong by exactly one level while containing no old name — invisible to every grep for costledger or costing. The Makefile pair is the purest case: `pricing` kept its leaf, so nothing textual changed at all and no rule could have fired. The reference broke purely by gaining a parent. Also core/ledger, core/event, core/settle in three comments. I handled exactly this for core/storage/redis and did not think to for core/cost/*. The tenth: the indefinite article stranded by substitution. `authlib` starts with a vowel and `core` does not, so six sites read "an core" — including two godoc comments on exported functions, which pkg.go.dev publishes, and one in framework-architecture.md where "an authlib-core change" had become "an core-core change". Also: sixteen comments still named the retired `costing` package. Those survived because `costing` is an English word, so no bare-word rule could fire without wrecking the twenty places where it is the gerund — "costing each client the request it had in flight" stays. core/README.md's Auth table contradicted its own theme table over where `capabilities` and `spiffe` are counted; it now says which and why. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
|
Important Review skippedToo many files! This PR contains 717 files, which is 617 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (717)
You can disable this status message by setting the 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. Comment |
Review round 1 on this PR found 29 findings, 0 must-fix. This applies the 21
in-scope ones plus the four adjacent guards, by class rather than by instance.
RENAME-DRIFT (deep-move). The five cost packages gained a cost/ parent and KEPT
their leaf name, so a reference by leaf is wrong while containing no occurrence
of any old name -- `grep authlib --include=*.go` over the tree returns zero hits
and reads perfectly clean. Swept per MATCH rather than per line, because a line
holding one correct and one stale reference is otherwise filtered out: 20 distinct
leaf-path targets, 15 of them stale, 22 citing sites. Fixed the 6 in scope
(pricegen.go's emitted header, the committed bundled.go carrying it, two godoc
lines in internal/gen, two PR-added comments in sessionapi/dst_test.go). The
other 15 sit in 2026-09-09 design docs this PR never touches and are deferred,
not fixed -- rewriting a point-in-time record is archaeology.
FALSE-CLAIM. Ten verified-false claims, fixed by deleting or dropping the number
rather than restating it, since a replacement claim is new unreviewed surface:
- The spec's theme table gave Framework 32,984 lines / 65%. Measured per
directory it is 30,485, identical at base and HEAD, which is what
core/README.md already says. Its Auth row named five directories of which
only two ever existed -- `validation` and `exchange` never existed at all,
`contracts` is base-only -- while the 882 figure actually comes from
`capabilities`, a HEAD-only name the row did not mention. Corrected the
Lines column, dropped the Share column, and pointed at core/README.md as the
one place shares are maintained.
- The spec's commit arithmetic ("twelve commits, not six ... the other six are
fallout ... matched the planned work commit-for-commit") was 13 total / 11
implementation / 5 fallout. Dropped the counts instead of correcting them:
this very commit would invalidate any number written here.
- The spec's target-layout block rendered `core/validation/`, which has never
existed in this repo at either end of the diff.
- core/README.md claimed 24 packages (25 directories, and the package/container
split makes the count ambiguous) -- number dropped; that `routing` is counted
under Framework (Framework's total is exactly the other five, so routing's
185 lines are in the stated remainder); and that neither external consumer is
referenced anywhere else in the tree (rossoctl/operator appears in 13 files).
- The plan's brace expansion named dependabot-tidy.yaml; it is .yml. And it
called seven target names "six" two clauses before calling them "seven".
GEOMETRY-INVARIANT. The invariant is "identical to base", not "internally
uniform". Measured by DISPLAY column, since box-drawing characters are multi-byte:
base's CLAUDE.md tree block is uniform at 70/70 on column 38, HEAD had exactly two
outliers. Fixed line 93 (column 35). Line 159 stays at 43 as a recorded exception
-- it overflows on the length of verify-moved-ca-diagnostics.sh, and aligning it
would mean widening all 81 lines of the block for one filename.
UNFAILABLE-ASSERTION. Three negative guards where a match is the failure, so zero
hits is the pass -- and a stale pattern produces zero hits too. The reviewer proved
the suffixes correct at HEAD with positive import mutants, but nothing stopped them
going inert on the next move. Each now carries a reachability control, copying the
`checked == 0` idiom from core/plugins/injection_coverage_test.go: the two
cost-ledger guards assert the directories their suffixes name exist, and the
profile-tags scan counts the sanctioned plugins_*.go matches it skips, separating
"the tree is clean" from "the regexp is blind". Every one was mutated and watched
to fail before being kept.
Makefile: `cd core && go fmt ./...` cannot reach core/storage/redis, because Go
excludes nested modules from ./... -- 64 packages, none of them under it, while
redis.go is one of the tree's gofmt-dirty files. Coverage is unchanged from base;
the move only made it look covered. Added the one module the move affected, and
deliberately did not reformat the dirty file, which is pre-existing.
dependabot.yml: after the rename "core uses three symbols from core/schemas" reads
self-referential. Disambiguated to bifrost's core/schemas.
Not fixed, deliberately: the 15 historical-doc references above, CLAUDE.md:159,
and findings 27-29, which are pre-existing breaks in files this PR does not touch.
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
Review round 2 (delta-scoped to 8518a7b) returned one must-fix, in that commit's own fix. Escalation 1 from the remediation stop rule: change how the fix is written, rather than adding more of it. UNFAILABLE-ASSERTION, recurrence of round 1's findings 22-24 inside the code that fixed them. The reachability control I added read a SECOND literal copy of the package paths while the guard matched on its own `HasSuffix` literals. Nothing coupled them, so an edit to the matcher alone left the control green and the guard could still go silently blind -- witnessed by mutants G3 (envoy) and G5 (cpex), both of which mutate only the `HasSuffix` literals and both of which SURVIVED. That falsified the comment the fix shipped ("Pin the suffixes to real directories") for exactly the failure mode it named. Why the round-1 mutation missed it: M1/M2 mutated the CONTROL's own list, which proves the control runs, not that it covers the matcher. A mutation aimed at the code you just wrote can pass while the defect it targets is untouched. Both guards now derive the match and the existence check from one `costPkgs` slice, building the suffix as "/"+pkg. The same commit already had this right 30 lines away in scripts/profile-tags/guards_test.go, which counts with the same `blankPluginImport` variable its scan uses -- so this restores a verified sibling rather than composing a new shape. The desynchronisation G3/G5 expressed is now structurally unavailable: there is no second copy to edit, which is why those two mutants' target no longer exists. | Mutant | Mutation | Verdict | |---|---|---| | G1 | envoy main.go gains a real core/cost/ledger import | killed | | G2 | cpex main.go gains a real core/cost/usage import | killed | | M1 | envoy costPkgs -> core/NOPE/ledger | killed | | M2 | cpex costPkgs -> core/NOPE/ledger | killed | | M3 | blankPluginImport module path core -> authlib | killed | | G3/G5 | matcher literals only | target no longer exists (one list) | G1/G2 matter most here: they prove the DERIVED suffix still matches real import paths, so coupling the control did not weaken what the guard actually detects. Also from round 2, both created by the previous round's own subtractive fixes: - The auth fraction was corrected at one site and left standing at five others in the same two files. Swept: every instance in the 2026-09-26 spec and plan now reads 1.6%, matching core/README.md and the spec's own header, which truncate rather than round. Fixing the named line without sweeping the class applies to figures, not just paths. - The replacement pointer sentence claimed core/README.md was "the one place" shares are maintained, contradicted by this spec's own header 30 lines above it. Deleted the over-claim rather than restating it. G4 (pricegen's emitted header, mutated alone, survives the cost/pricing suite) stays open: the golden test compares generated DATA, never Render()'s bytes, so the header pair this PR fixed by hand is ungated. Pre-existing and adjacent -- recorded in the review log, not fixed here. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
Review round 3 flagged the comment added in 11a2d0e: "an edit that blinds one blinds the other" is unqualified, and false for edits to the match EXPRESSION rather than the strings. Mutants G8/G9 (append a trailing slash to the derived suffix) and G10/G11 (HasSuffix -> HasPrefix) each blind the matcher with one token while the os.Stat loop stays green. The conclusion was true -- the two-copy desynchronisation really is structurally gone -- so this is a true claim resting on an over-broad reason, which is the shape that survives every check aimed at the conclusion. Narrowed the claim to the strings it actually covers and said plainly what it does not catch, rather than widening the guard to match the sentence. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
rossoctl#1141 landed while this was in review. Merged rather than rebased: this branch carries 206 pure renames across 15 commits, so a replay would re-resolve the same rename-vs-modify decision once per commit, and it would rewrite the SHAs three review rounds cite. Upstream's four commits touched nine files. Eight merged cleanly, including the four `authlib/pricing/*.go` edits, which git routed to `core/cost/pricing/*` on its own via rename detection -- verified by the tests, not assumed. `docs/plugin-catalog.md` conflicted in two hunks. rossoctl#1141 MOVED the pricing and cost-record sections out of that file into a new `docs/pricing.md`, replacing them with pointers, while this branch still held the originals with their paths renamed. Took upstream's side in both hunks: keeping ours would have duplicated 162 lines that now live in `docs/pricing.md`. Confirmed the content is actually there before discarding it. The merge's real hazard was not the conflict. `docs/pricing.md` is new, written against the pre-rename layout, and arrived carrying ten `authlib/` citations -- plus one that upstream added to `plugin-catalog.md`. Merging them verbatim would have silently reintroduced the exact drift this branch exists to remove, in files no conflict marker pointed at. Translated all eleven, most-specific first so the bare `authlib/` could not shadow the others, and verified every target exists on disk before writing it: authlib/pricing -> core/cost/pricing authlib/usage -> core/cost/usage authlib/costing -> core/cost/settle authlib/costledger -> core/cost/ledger authlib/costevent -> core/cost/event authlib/ -> core/ authlib/plugins/litellm_budgettrack -> core/plugins/litellm_budgettrack Also `costing.Settle` -> `settle.Settle`: that package's name changed too, so the symbol reference was stale independently of its path. Verified after resolution: all 9 modules test clean (incl. `-tags cpex`), gofmt clean on every merged Go dir, `go mod tidy -diff` clean, every relative link in both docs resolves, every `core/...` path cited in the new doc exists, the complete mutation suite re-run with no prior mutant flipping to SURVIVED, and no `authlib` string left outside the dated `docs/superpowers/` archive. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Hai Huang <huang195@gmail.com>
esnible
left a comment
There was a problem hiding this comment.
Summary
A 721-file rename refactor that holds together. I verified the structural and mechanical claims against the PR head tree rather than taking the (unusually detailed) description on trust, and found nothing to flag — no must-fix, no suggestions, no nits.
Author: huang195 (MEMBER — maintainer)
Areas reviewed: Go, CI/GitHub Actions, Dockerfiles, dependency manifests, Shell, Python, Docs, Agent/IDE config
Agent/IDE config (.claude/.vscode): FLAGGED and cleared — .claude/skills/demo/SKILL.md (6/-6). Full patch read: all six lines are prose path updates from this PR's own rename (authlib/spiffe→core/spiffe, proxy-init→deploy/proxy-init, scripts/→scripts/dev/). No hooks, no command, no runOptions, no permission grants, no executables added or referenced, no obfuscated content. No settings.json/settings.local.json anywhere in the diff; a repo-wide scan for settings.json|setup.mjs|tasks.json|launch.json|extensions.json|devcontainer returns zero hits.
Commits: 17, all signed off
CI status: passing (27/27; Spellcheck + tidy skipped, CodeRabbit skipped at 717 files over its 100-file limit)
Verified against the head tree
| Claim | Result |
|---|---|
| Top level 10 → 7 | cmd core demos deploy docs scripts tests |
core/ 29 → 25 packages |
exactly 25 |
| Nine renames landed | all present; zero surviving authlib/costing/costledger/costevent/runtimeutil/contracts |
placeholder/praxis kept |
both present, as stated |
Seven replace directives |
correct, including the depth-sensitive core/storage/redis => ../.. |
Hazard #10 (make pricing-table) |
./cost/pricing/internal/gen -dir ./cost/pricing; both paths exist |
| Hazard #4 (escaped-dot regexp) | updated — no substring sweep could have matched it |
| Hazard #6 (tag-gated blank imports) | both plugins_sessionbudget.go fixed |
| Hazard #11 ("an core") | 0 remaining |
| "20 direct dependencies" | exactly 20 in core/go.mod |
| README package coverage (was 11/25) | 24/25 — only internal/ omitted, correctly |
| "no gRPC, no Envoy" false claim | corrected explicitly rather than quietly dropped |
install.sh untouched |
absent from the diff, so --ref against pre-flatten releases still resolves |
settle.StateKey safe to move |
consumers go through settle.Load()/settle.Settled, never the literal |
Security posture: all Actions remain full-SHA pinned, every go.sum is 0/-0 (no dependency content moved), and no dependabot ignore constraint was loosened. The core/schemas → bifrost's core/schemas disambiguation in dependabot.yml is a real improvement now that core is this repo's own module name.
Worth calling out
The two cost-ledger guards (hazard #5) weren't merely re-pointed. They now derive both the suffix match and an os.Stat existence check from one costPkgs slice, so a future rename that stales the suffix fails loudly instead of passing vacuously — and the comment is candid about the limit it does not claim to catch. That is the right fix for a guard that could previously have guarded nothing in silence.
Every deliberate exclusion checks out as correctly reasoned, and the four Deferred items are real and appropriately scoped out of this PR.
One thing outside this PR's reach
As the description notes, the envoy image's final assembly can't be built in the author's environment (MITM cert on a CloudFront blob pull, reproduces on unrelated images). build.yaml covers assembly on tag push, but one confirming build somewhere with normal registry access is worth having before a tag is cut — and per the Rollback section, don't tag until this has settled.
Approving on a maintainer diff with the flagged agent-config file inspected and confirmed benign.
What
The flatten (#1134) removed the vestigial
authbridge/level. That fixed the depth and exposed two things it had been hiding: the root did not describe the product, and the library's name was wrong on two axes at once.This takes the top level from 10 directories to 7, renames
authlibtocore, and renames nine packages inside it to say what they do. No published contract changes.authlibwas not merely stale — it was 1.6% authMeasured on this branch, non-test lines under
core/(53,323 total):pipeline,plugins,listener,config,spiffecost/*session,sessionapi,observe,redactauth,bypass,capabilitiesThe docs compounded it. They called it "the shared auth library" and enumerated it as "validation, exchange, cache, bypass, spiffe, routing, auth, config…" — the 1.6% listed first, the 57% omitted.
core/README.mdnamed 11 of its 25 packages, leaving out the entire cost group andlistener, which between them are most of the module.And it claimed, twice, "no protocol dependencies (no gRPC, no Envoy)". That stopped being true when the listeners moved in:
listener/extprocis an Envoy ext_proc gRPC server, andcorehas 20 direct dependencies includinggoogle.golang.org/grpc,envoyproxy/go-control-plane, OPA, OpenTelemetry and CPEX. The README's dependency list named three of the twenty. No gate can catch a doc that lies; it took reading it againstgo.mod.Read it in commit order
e1c25cc4deploy/—proxy-init,sparc-service,lineage-attachgrouped. Contexts moved; imagename:values untouched.a43090c0scripts/dev/— the three loose shell scripts consolidated.bd649fdfdeploy/fallout that no diff could show.2254a937authlib→core— module path, ~850 imports over ~393 files, 7replacedirectives.82bfc59784f2dc8bstorage/redis→core/storage/redis— beside the interface it implements.5b0cff2e591884247239a663bfae6a7a1aa53d93maketarget plus the last two invisible shapes, found by the final review.Plus the two doc commits carrying the design spec and the plan.
Six planned commits, eleven as shipped. The five extra are each fallout that earned its own reviewable boundary rather than being buried in the commit that caused it. That the fallout nearly matched the planned work commit-for-commit is the honest measure of how much of this change was invisible to the sweep performing it.
The nine renames
sharedmemstorestorage, the cross-pod persistent oneruntimeutilbootstrapcontractscapabilitiestlstlsconfig*crypto/tls.Configvalues.tlsbridgeforges certificates. Two unrelated jobs, near-identical namespricingcostingcostledgercosteventusagecost/{pricing,settle,ledger,event,usage}costing→settlebecause it "turns one response's facts into one settled cost"core/'s top-level package count drops 29 → 25.placeholderandpraxiswere deliberately not renamed:placeholderis accurately named and tied to theabph_wire prefix, which cannot change;praxisis an external product's name.Eleven classes of reference a substitution sweep cannot see
The design spec anticipated one — the bare-name-without-trailing-slash class that cost #1134 sixteen broken spellings. Implementation found eleven. Each was caught by building or measuring, not by grepping for what I expected. The last two were found by the whole-branch review, after I thought the branch was finished, and one of them was the only functional break in it.
Relative markdown links whose text never changes. Ten of them, in four READMEs that moved one level deeper. A diff shows nothing; only the ground beneath the file moved. A blanket
../→../../would have brokendeploy/sparc-service/deploy/README.md's../README.md, which points at its own parent and already resolved — so the fix had to be per-link.Wildcard-free git pathspecs match at the root only. The migration script's
'Dockerfile*'and'Makefile'each covered exactly one file, hiding 4 nested Dockerfiles withCOPY authlib/ authlib/and 2 nested Makefiles.'*.py'was absent entirely — the same omission that madepytestfail at collection in Refactor: Flatten authbridge/ into the repo root #1134.A starred regex group keeps only its last repetition.
s|=> \(\.\./\)*authlib|=> \1core|turns=> ../../authlibinto=> ../core: wrong depth, on everyreplacedirective, silently. There were 7, not the 5 the spec claimed — two live insidereplace (blocks, which is why the first count was low.References written in a syntax other than plain text.
scripts/profile-tags/guards_test.goholds the module path as a regexp literal with escaped dots (github\.com/…). No plain-substring sweep can match it, and grepping for the literal string cannot find others like it.Assertions that compare a package path as a string. Two guards in
cmd/authbridge-{cpex,envoy}/main_test.gousestrings.HasSuffix(path, "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/authlib/costledger"). Miss them and nothing fails — the suffix stops matching, the loop finds nothing, the test passes, and the assertion silently guards nothing. Both were re-pointed and then proven to still fire by inverting them.A build tag no profile enables is invisible to every aggregate gate.
cmd/authbridge-{proxy,envoy}/plugins_sessionbudget.gocarry_ "…/storage/redis"blank imports behindinclude_plugin_sessionbudget, which appears in zero shipped profiles.go build ./...and all four profile builds pass while that import is broken — andrelease-binaries.yamlships a-sessionbudgetvariant. Only an explicit tagged build sees it.The same identifier check gives opposite answers per name.
authlibis nowhere a Go identifier, so a bare-word substitution was safe.sharedis — a struct fieldp.sharedincore/plugins/opa— and a blanket rule rewrote 11 field accesses intop.memstore. Meanwhiletlsneeded no identifier rewrite: all 7 importers already alias itauthtlsbecausecrypto/tlsowns the bare name in 5 of the same files, so atls.rule would have corrupted ~30crypto/tlscall sites, some plausibly still compiling.\bdoes not stop at an underscore.^package tls\bmissespackage tls_test, producing an error that names the cause but reads obscurely:found packages tlsconfig (client.go) and tls (server_test.go).godoc headers name the bare identifier with no path prefix. All seven renamed packages still opened
// Package <oldname>, sogo docand pkg.go.dev would have shown the wrong name for every one. Invisible to both thecore/<old>path sweep and the^package <old>$clause rule.A path that never gained its new parent — the only functional break on the branch. The five cost packages moved deeper, so a reference mapping old leaf → new leaf comes out wrong by exactly one level while containing no old name at all.
make pricing-tablestill rango run ./pricing/internal/gen -dir ./pricingfrom insidecore; it is now./cost/pricing. No CI job runs that target, and it is the documented recovery path cited by seven code sites anddocs/plugin-catalog.md. It is the purest case in the set:pricingkept its leaf, so nothing textual changed and no substitution rule could have fired — the reference broke purely by gaining a parent. Three comments had it too (core/ledger,core/event,core/settle). I handled exactly this hazard forcore/storage/redisand did not think to apply it tocore/cost/*.The indefinite article stranded by substitution.
authlibstarts with a vowel;coredoes not. Six sites read "an core" — including two godoc comments on exported functions, which pkg.go.dev publishes, and one indocs/framework-architecture.mdwhere "an authlib-core change" had become "an core-core change". It compiles, vets, gofmts, and leaves no old name to grep for.And one where no rule could fire without breaking something else. Sixteen comments still named the retired
costingpackage — becausecostingis also an English word. The twenty places where it is the gerund ("costing each client the request it had in flight") had to stay, so the sixteen were separated by reading them, not by pattern.Two consequences in the same family: seven files were still named after the package they no longer belong to (
runtimeutil.goinbootstrap,costing.goinsettle), and import ordering shifted —authlibsorted before sibling paths,coresorts after, so 16 import blocks needed resequencing. gofmt is gated nowhere here (ci.yamlrunsgo fmt, which rewrites and exits 0), so that one had to be measured per commit.And one the plan predicted that did not happen. It warned that
eventandsettleare short common words likely to shadow the new packages, provable only by building. I ran the whole rename in a throwaway worktree first: zero build errors, zero vet errors, all tests pass. A regex scan suggesting 34-of-50 collisions was false positives. Shadowing a package name is legal Go; it only breaks where the same scope also qualifies the package.Two deliberate inconsistencies
Runtime log and error prefixes still read
"costledger: …"incore/cost/ledger/{store,query,writer}.go. Left alone on purpose: they are observable output an operator greps and alerting may key on, they are not wrong (the subsystem is the cost ledger), and"ledger:"would say less. Renaming observable output is a separate decision with its own blast radius, not something to fold into a change whose premise is that no published contract moves.To be precise about the first one, since the prefixes span two packages: 19
"costledger:"incore/cost/ledger/{store,query,writer}.goplus 2"costing:"incore/cost/settle/settle.go. It is applied consistently — only three packages ever carried a package-named log prefix, and all three kept it (pricing:×12 needed no change).Comments name renamed packages by path form —
cost/ledger, notledger. The bare leaves read badly in prose ("event is explicit that no consumer may add money" is ambiguous) and the path form is what a reader would grep for.One production literal did move, and it is the deliberate inverse of the log-prefix call:
settle.StateKeychanged from"costing.settled"to"settle.settled". That one is in-process only — consumers reference the constant, nothing hardcodes the string, and its godoc says it is deliberately not on the wire — so unlike a log line, no one outside the process can observe it.Deliberate exclusions — please don't "fix" these
install.shis untouched — 0 lines changed, including line 485's--refprobe of${ref}/authbridge/install.sh. That probe finds installers inside pre-flatten releases, whose git trees still have the file there. Rewriting it makes both lookup paths identical and silently breaks--reffor every existing release, with no failing test to show it.docs/superpowers/keeps its staleauthlibstrings. Dated design records, per the precedent in Docs: Correct the docs and repo config to match the tree #1125.main. Fixing them is unrelated churn here; the 16 this PR caused are fixed.Verification
All Go commands with
GOWORK=off, as CI runs them.go mod tidy -diff+build+vetclean in all 12 modules — the gate that passes whilebuild,vetandtestall failcore:go test -raceclean; all four pure-Go profiles resolve and compile;cpexresolvesgo build -tags include_plugin_sessionbudgetin both proxy and envoy — the only gate that sees those blank importsinstall_test.sh113/113;pytest tests/12/12;readme-demostaleness check passescmd/names,AUTHBRIDGE_*9/9,x-authbridge-direction50,/etc/authbridge23#anchorstripped, compared against the base to separate new breaks from old: 7 broken, the same 7 asmaingofmt -lmeasured at every commit on the branch: back tomain's 6dependabot.ymlentries re-checked against their ecosystems (thegomodones have ago.mod, thedockerone aDockerfile.init)docker buildof the proxy image, and ofproxy-initandsparc-service, whose contexts movedbfae6a7a, so this row is history rather than something a reader can re-derive at HEADjson:tags, 142yaml:/mapstructure:keys, 22 plugin names, 17include_plugin_*tags, 133 metricName:literals, 16 OTel attributes, 101reasoncodes, 5 action values, 21 routes, 42x-*headers, 25 env vars. Rego and Python literal sets unchanged. Exported declarations go 968 → 978, the delta being exactly the 10redisdeclarations that moved in.One gate not closed locally. The envoy image's final assembly cannot be built on this machine: the Go-build stage completes all 9 steps, then
FROM docker.io/envoyproxy/envoyfails withx509: certificate signed by unknown authoritypulling a CloudFront blob — the local HTTPS proxy's MITM cert, untrusted by the container runtime. It reproduces on unrelated images from other registries, so it is environmental and not caused by this change, and the stage this PR edited passed.build.yamlcovers assembly on tag push. Worth one confirming build somewhere with normal registry access.Expected non-failures:
cmd/authbridge-cpexvetexits 1 without-tags cpexat every commit including the base — every file sits behind//go:build cpex, so./...matches no packages.cmd/abctl'sTestRunExec_BeforeFirstStart…fails from an ambientSSL_CERT_FILE; reproduces on unmodifiedmain.Downstream
rossoctl/operatorandrossoctl/rossoctl-clicompile against this module and need, on their next cortex bump:plus the nine package renames. Neither breaks when this merges — both pin pre-flatten pseudo-versions, so they already owed a one-time import sweep from #1134; this folds into the same one.
Rollback
A pure rename:
git revertof the merge commit restores everything, and consumers are pinned either way. The one hazard is cutting a release inside the window — a tag between this and a revert would publish, then unpublish, a module path. Don't tag until it has settled.Design spec:
docs/superpowers/specs/2026-09-26-repo-layout-design.md(marked implemented, with its two wrong counts corrected in place)Implementation plan:
docs/superpowers/plans/2026-09-26-repo-layout.mdAssisted-By: Claude (Anthropic AI) noreply@anthropic.com
Deferred, deliberately
Filed rather than fixed here, so a later pass does not rediscover them as new:
2026-09-09-pricing-consolidation-*docs. Thoseare point-in-time records this PR does not touch; the paths were correct when written.
Enumerate with the sweep in the review log.
scripts/dev/comment column inCLAUDE.md, which overflows on the length ofverify-moved-ca-diagnostics.sh. Aligning it means widening every other line in the block.--ignore=tests/e2e, asecurity-scans.yamlcomment citing ademo/path that neverexisted, and two broken relative links in
demos/github-issue/demo-aiac.md. Worth onefollow-up issue.
make fmtreaches a subset of the workspace modules. This PR adds the one the redis moveaffected; the others were never covered at base either.