Repository navigation
feat(companies): make patches belong to users, not tokens - #148
Conversation
Astra reviewReviewed StandardsNo merge-blocking method or YAGNI findings. SpecNo merge-blocking intent findings against #137. Clerk login, browser pages and sharing enforcement belong to later tickets, not this PR. Verification: 67 tests passed across 10 focused files covering Companies, Users, MachineTokens, AuthApi, Patches/PatchesApi, CLI, API guard/server and developer-env behavior. The lockfile's package resolutions are unchanged; its semantic changes are confined to the affected workspace importers. Full-suite, lint, typecheck and packed-e2e verification were not rerun in this review. Summary: Standards: 0 blockers, no worst issue. Spec: 0 blockers, no worst issue. |
Code review — PR 148 vs #137Reviewed Eight parallel reviewers: Standards, Spec, issue-137 intent, implementation method, YAGNI, Companies/Users, Auth identity, and hit-every-surface. Standards and Spec stay separate on purpose. Standardsui-consistency: N/A (no product HTML/CSS). Effect services otherwise match Documented-standard violations (hard)1.
Fix: add 2. Auth no longer reports analytics; Mint removal left AuthApi with no Fix: drop Judgement-call smells (never hard; repo standards override)Feature Envy — UPDATE machine_tokens SET revoked_at = to_timestamp(...)
WHERE user_id = ${input.userId} AND revoked_at IS NULLDuplicated Code — user column list copied in Speculative Generality
Spec(a) Missing or partial
Nothing else in-scope is missing. Viewer, InviteMail, device-login routes, upload/share (b) Scope creepNone material. Extra reserved handles match §3 (“plus a short list of obvious words the build fixes as one constant”). Invite consume/revoke/list and (c) Implemented but wrongNone found against the ticket checklist.
Intent vs what landed#137’s intent is a product substitution, not a table dump: stop treating a token as a principal. A patch belongs to a user in a company. A machine token is the credential that acts for them. Replacing a key must not change ownership. Self-service minting and the bootstrap token go now so nobody invents a replacement credential. Until That substitution is in the running system. Ownership checks Drift is sequencing, not a different model. Slightly ahead: invite consume/revoke and claim refresh already exist for the pages ticket. Slightly behind, and named as such: The remaining lie is serving. Writes already mean “this user, via this machine.” Later tickets can mint onto MethodThe live request path is the small model. Authenticate is one SQL join. Postgres decides every refusal. The seed is the same idea: one transaction that produces a working credential, cloned by runner, vitest template, and packed e2e.
A different method that still hit 137 could not skip the package or the unused services. Additive migrations, a TypeScript identity assembler, or a deactivation orchestrator would have made the behavior more surprising, not less. YAGNIThe cut is mostly the right one. Three rewritten baselines; minting deleted rather than gated; one seed; empty unauthenticated path list; Must-cut: two tests in Judgement, not blockers
Nits from the service and surface reads
Standards: 2 hard findings, 4 judgement smells. Worst on this axis: leftover |
Review dispositionReviewed both agent comments against #137, parent #135 and the source. Fixes are committed and pushed in e802c3f ( Fixed
Kept, with reasons
Clerk pages, login, sharing enforcement and the HEAD fix remain in their named later tickets; none is silently added to this data-model PR. The first agent review reported no blockers and needs no separate change. Verification
Merge readiness
|
|
only caveat is something to check for if tokens are compromised but tbh we don't really need that rn. Also see if you can have a warning for expiring tokens (say, if it expires within a day or something) Also thing to note: Admins should be able to delete employee shit. But tbh that's out of scope, and we can't be complicated. Still good to keep in mind, though. |
|
@vsrikar08 Following up on your review:
None of these points requires an additional change to this PR. |
Implement #137: company membership, user-owned machine credentials, patch ownership, and a shared development seed. Remove bootstrap and self-service credentials across the API, CLI, tests, and documentation.
e802c3f to
ffe36ca
Compare
Patches belonged to the token that created them, with no user or company behind the credential. Replacing a key should not change who owns a patch.
Companies and users now own the data, while expiring, revocable machine tokens act for a user. The API and CLI use that identity, and development, tests and packed e2e share one seeded company, admin and machine token. Bootstrap and self-service credentials are removed; the docs and company-authority ADR describe the new model.
Stacked on #147 (
auth/136-remove-operator-routes). This PR targets that branch, notmain. Clerk login, browser pages and sharing enforcement remain in later tickets.Closes #137.
Verification
pnpm test: 167 tests passed across 27 files.pnpm lint,pnpm typecheckand packed CLI e2e passed.pnpm devidentity and upload verified; published GET returned 200.Implemented with GPT-6 Astra using the Oh My Pi harness.