Skip to content

fix(platform): anchor two-factor grace periods - #4437

Merged
yannickmonney merged 3 commits into
mainfrom
fix/platform-two-factor-anchor
Oct 6, 2026
Merged

yannickmonney merged 3 commits into
mainfrom
fix/platform-two-factor-anchor

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Closes #4424

Persist the first required sign-in anchor for two-factor grace periods. New rows calculate anchor + current grace, so shortening blocks immediately and lengthening extends from the same anchor. Legacy rows have no recoverable anchor and retain their stored deadline. Migration 0153 is forward-only.

OLD/NEW evidence:

  • OLD (main): existing implementation stores only the deadline and cannot lengthen from the original anchor.
  • NEW: anchored and legacy semantics are covered by fake-time regressions in service.enforcement.test.ts.
  • SSO suite: passed (2 tests).
  • Two-factor suite: BLOCKED in this environment by existing z.enum dependency/setup failure (packages/shared/src/schemas/pii.ts).

DATA: BLOCKED unless a named CI job applies migrations to PostgreSQL.

Unrun checks: full repository check, PostgreSQL migration/data verification, and the two-factor Vitest suite due to the setup dependency failure above.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

ACCEPT — exact head 98d3cc36a599ef8c8c0770a6a216f5f7def35be2.

  • SECURITY: PASS. The new nullable first-required-sign-in anchor is written once with ON CONFLICT DO NOTHING; evaluation derives new-row deadlines from that anchor, so repeated password/SSO sign-ins cannot extend the clock. Expired grace returns blocked; the integration regression proves SSO expiry and leaves enrollment available. Queries remain keyed by the user, so no cross-tenant or role rows are touched.
  • DATA: PASS. Migration 0153 is forward-only and additive. Nullable first_required_sign_in_at_ms preserves rolling-deploy compatibility; legacy rows with a null anchor retain their stored grace_until_ms deadline. New rows retain the anchor while policy length changes recompute the deadline from it.
  • CODE: PASS. The service abstraction is reused by every session-minting door; the spec rule and test title now describe recomputation from the persisted anchor and explicitly cover legacy rows.
  • TESTS: PASS (evidence). Backend integration and platform Unit lanes are green at this head; the regression is represented in the enforcement suite and integration check. The unrelated PowerShell CLI installer timeouts in tools/cli are a CICD flake outside this PR.
  • UI / LOCALE / A11Y: N/A. No user-facing copy or UI changes.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Merge-lane coverage dispositions at c1938f9d05fb2409c80656ece5a5a7100fd43592. From agent #2 (TALE-359 run 29d92758), the merger. The independent ACCEPT is C5's (comment 6017488230, at 98d3cc36); C4 implemented. I am not the author or the reviewer.

Identity: this head is a merge of main 3fa759cb into 98d3cc36. Three diffs have the same git patch-id --stable (a616b6b5):

  • the accepted change: merge-base..98d3cc36;
  • this head against the main it merged: 3fa759cb..c1938f9d;
  • the composition on current main: a82b06af against its git merge-tree with this head.

So the squash carries exactly the reviewed change.

Topic Disposition Basis
SECURITY PASS C5: the anchor is written once (ON CONFLICT DO NOTHING), repeated password/SSO sign-ins cannot extend the clock, and expired grace blocks while enrollment stays available. Queries are keyed by user.
DATA PASS Migration 0153_two_factor_first_required_sign_in.sql is forward-only, additive and nullable. It is unique on main a82b06af, whose last migration is 0152. Legacy rows keep grace_until_ms. Backend integration (real PostgreSQL) ran green at this head.
CODE PASS C5's exact-head review. The service is reused by every session-minting door.
REL-MANUAL PASS (automated) Fake-time regression in service.enforcement.test.ts plus the integration check. C4's repair evidence (TALE-974) records the regression failing on main.
DOCS PASS The two_factor/spec.md TFA-R4 rule and its test title move together and cover legacy rows.
DEPLOYMENT PASS (source); live upgrade UNAVAILABLE The nullable column is rolling-deploy compatible, since old images ignore it. No disposable upgrade proof exists: no heavy slot and no Ops evidence.
RECOVERY PASS (source) Forward-only with no down migration. A rollback image keeps working because it never reads the new column.
CICD PASS 7 workflows at this head: 57 success, 1 neutral (Trivy), 24 allowlisted skips, Backend integration ran. The tested base 3fa759cb is one commit behind main. That commit is #4448 (task output staging), unrelated, and patch-id identity holds on current main.
PERFORMANCE, RESOURCES NOT_APPLICABLE One extra nullable column read per enforcement evaluation; no new query or loop.
UX-SIMPLICITY, UX-CLARITY, A11Y, UI-RESPONSIVE, LOCALE NOT_APPLICABLE No UI, copy or string change. The user-visible effect is enforcement timing, which REL-MANUAL covers.
PROVIDERS, OBSERVABILITY, WORKFLOW NOT_APPLICABLE No provider, telemetry or cycle-workflow change.

Merge-gate dry run at 16:46:23Z passed: open, CLEAN, head matches, no check pending.

@yannickmonney
yannickmonney merged commit 3097c95 into main Oct 6, 2026
@yannickmonney
yannickmonney deleted the fix/platform-two-factor-anchor branch October 6, 2026 16:46
yannickmonney added a commit that referenced this pull request Oct 6, 2026
Apply the three corrections from the independent fact review of #4447
(website scan probing versus the browser fetch, the knowledge database
container and its migration order, and the #4448 entry), and add the changes
merged after the reviewed range: the two-factor grace anchor (#4437) with its
migration note, sharp 0.35.5 for GHSA-wq5f-xc86-pv6w (#4450) with the pinned
sandbox runtime image note, and the All projects archived badge (#4416). Add
known issues for #4438, #4439 and #4448 from their post-merge reviews.

Independent review: ACCEPT at 32d07ec (PR comment 6024188366).
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.

bug(platform): a shortened two-factor grace period never blocks anyone earlier; the deadline slides on every check

1 participant