Skip to content

test(plugin-auth): keep the absolute-limit switch fixture off the one-hour boundary - #31213

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-wmxpk3
Nov 7, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-wmxpk3

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Fixes #31175

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:只改一个测试文件:plugin-auth 里「切换组织时按绝对时长上限判定」那条用例的会话夹具,从「正好 60 分钟前创建」改为「59 分钟前创建」,并补一句注释说明为什么不能贴着上限。
  • 为什么改:上限是 1 小时,判定时会重新读时钟;夹具正好 60 分钟,只要过去 1 毫秒会话就超限被结束,「还没到上限」的断言就红。本地实测:旧夹具在 main 上每次都红,不是偶发。产品判定本身是对的,不动产品代码。
  • 风险与回滚:极低。不改任何发布内容(测试文件不进包),「超限」那条 61 分钟断言原样保留;回滚即还原这一行。
  • 先看:packages/plugins/plugin-auth/src/organization-access-policy.test.ts(L398 夹具与 L421 注释)。
  • 两分钟验证:pnpm --filter @objectstack/plugin-auth exec vitest run src/organization-access-policy.test.ts,预期 19/19 通过。
  • 需要你做的:无,席位落地。

What changes

  • packages/plugins/plugin-auth/src/organization-access-policy.test.ts, in the deployment() fixture of the "a switch of the active organization is judged against the target's limits" block: the s1 session row is created 59 minutes ago instead of exactly 60. The "not over yet" comment now says why the fixture must sit clearly inside the limit. The "over" leg (created_at 61 minutes ago, expect ended with revoke_reason: absolute_max) is unchanged, so the test still proves the absolute limit is judged at the switch, on both sides of it.
  • The same fixture feeds the idle-timeout case in that block. It judges last_activity_at (30 minutes ago, against a 10-minute idle limit) and sets no absolute limit, so 59 vs 60 does not change what it reads.

No product file is touched; organization-access-policy.ts and auth-manager.ts are as on main.

Why

AuthManager.judgeSessionSwitch (auth-manager.ts L6352–6355) takes its own Date.now() after the fixture is written and ends the session when now - created_at > absoluteHours * 3_600_000. A row made Date.now() - 60 * MIN against a one-hour limit is over as soon as one millisecond passes between the fixture and the judgment. The product comparison is right; the fixture sat on the boundary. Main went red on it in Test Core (7/8) (run 42384924042); locally the base fixture is red on every run (the memory engine's insert and read take well over a millisecond).

Tests

Acceptance: a 5-second fake-clock advance between fixture and judgment; base fixture red, new fixture green

Each leg runs pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/organization-access-policy.test.ts -t 'the absolute limit is judged too' under os-verify-lock, with the mutation written by scripts/ablation-replace.mjs (anchor must hit, blob verified, restored to the HEAD blob). The test imports ./auth-manager from src/, so there is no dist/ hop and no rebuild per leg. The delay is vi.useFakeTimers({ toFake: ['Date'] }); vi.setSystemTime(Date.now() + 5_000); inserted on the line of the "not over yet" assertion; it was removed afterwards and is not in the diff.

leg fixture delay on-disk check result
0 59 min (head) none fixture59=1 fixture60=0 delay=0 Tests 1 passed, exit 0
0b 60 min (base) none fixture59=0 fixture60=1 delay=0 AssertionError: expected 'ended' to be 'admitted', exit 1
1 59 min (head) +5 s fixture59=1 fixture60=0 delay=1 Tests 1 passed, exit 0
2 60 min (base) +5 s fixture59=0 fixture60=1 delay=1 AssertionError: expected 'ended' to be 'admitted', exit 1

Restore proof after the last leg: git diff HEAD empty, blob on disk 086c2c08 = HEAD blob 086c2c08.

A first attempt at legs 1 and 2 was a no-op: the delay replacement still contained the anchor line, so ablation-replace refused it ("anchor count moved 1 -> 1") before running anything. It was redone with a replacement that rewrites the anchor line itself; the table above is the second run.

plugin-auth suite and typecheck at head 228d061
  • pnpm --filter @objectstack/plugin-auth test: Test Files 234 passed (234), Tests 4168 passed | 10 skipped (4178), VERDICT command-exit 0.
  • pnpm --filter @objectstack/plugin-auth typecheck (tsc, examples, check:test-typecheck): check:test-typecheck: OK, VERDICT command-exit 0. The first run answered exit 2 on examples/basic-usage.ts because plugin-auth's own dist/ was not built yet in the fresh worktree; after pnpm --filter @objectstack/plugin-auth build it is green.
  • eslint --no-inline-config packages/plugins/plugin-auth: exit 0 (plugin-auth has no lint script, so a filtered pnpm lint would match nothing).

Acceptance notes

  • Same-file boundary sweep (the card's L336–346 minutesAgo helper): the four concurrent-cap cases use ages 50/40/1, 5/30, 5/30 and 30/20/1 minutes. They only order sessions by age against count caps (max_concurrent_sessions_per_user, maxConcurrentSessions); no time limit is judged, so nothing sits on a boundary. The other same-file clock fixture, L291 hourAgo (60 minutes) against Alpha's 5-minute idle limit, is far over. No other same-file fix.
  • Rest of plugin-auth/src/**/*.test.ts, every Date.now() - N fixture read against the limit it meets: none equals its limit. Closest reads: auth-manager.test.ts L4997 (created 60 minutes ago, but the case judges a 15-minute idle limit with no absolute limit), session-of-record.test.ts L313/L332 (12 h and 2 h against an 8 h cap), auth-manager.mcp-oauth.test.ts L359/L546 (consent timestamps, no limit judged). Nothing out of scope to file.

Verification

  • Derived gate families (node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, 52 commands) run at head, reconciled with --ran: 51 exit 0, 1 NOT MEASURED (pnpm check:dual-build-cjs-loads, exit 3 PREREQUISITE NOT MET: it needs every package's dist/ and the worktree built only plugin-auth's closure). node scripts/check-plugin-teardown-shape.mjs --self-test first answered exit 3 on the shallow clone and is exit 0 after git fetch --depth=1 origin 621a4876. --ran: "52 derived famil(ies) accounted for — 51 run, 1 NOT-MEASURED", exit 0. The 16 --self-test families are checker health only, not a verdict on this diff.
  • skip-changeset: plugin-auth files[] is dist, README.md, CHANGELOG.md. After a build, the new comment text and the test file name have 0 hits there; positive control judgeSessionSwitch has 4 hits in dist.

Generated by Claude Code

…-hour boundary

The switch judgment reads its own clock after the fixture is written, so a
session made exactly 60 minutes old against a one-hour absolute limit is
over as soon as one millisecond passes, and the "not over yet" assertion
went red on main. The fixture is now 59 minutes old; the 61-minute "over"
leg is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5mS6HNaJTYsygvmxuM
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs.

What this run could not see

Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 66bf5b4a019c62f50ed1824b35fe6ba345cf51e3 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#6 · os-project-manager · session_01FEkQ5p3T5YWhLjurajudnQ

席位核对 · ACCEPT · 2026-11-07T18:42Z · head a51ee30bb47d91704ebbee8ac5c2e2c0391dc114

Seat domain:server#6 reviewed the diff of its own dispatch (claim 6710557261 on #31175, card thread session_01FEkQ5mS6HNaJTYsygvmxuM, report 6711483660). Read against GitHub, not the report.

  1. Shape: 1 file, +4 / -2, test only. organization-access-policy.test.ts deployment() fixture created_at 60 → 59 minutes against the one-hour limit, with a comment on why a fixture never sits on the limit; the 61-minute "over" leg is unchanged, so the assertion still proves the absolute limit is judged at the switch. No product file. Body says Fixes #31175; no other closing keyword.
  2. Premise: on origin/main the fixture read Date.now() - 60 * MIN against session_absolute_max_hours: 1 and expected admitted (main red, run 42384924042).
  3. Gates / check-runs: 48 runs on this head, 34 success, 14 skipped, 0 red, including Test Core 1–8/8, Type Check · workspace and Lint. Dev: 52 derived gates exit 0, --ran reconciled; the card's acceptance ablation (5 s fake-clock advance) red on 60 minutes, green on 59, delay removed. mergeable_state clean.
  4. Accepted deviations / notes: the PR body quotes the earlier head's gate counts; the final-head readings are in the report. Not worth a body edit.
  5. Out of scope / Skills-docs: boundary sweep of plugin-auth/src/**/*.test.ts found no other fixture on its limit (listed in the body). Metadata-protocol: none; Skills-docs: not owed. Nothing filed.
  6. Landing: check-governed-merges --pr 31213: not governed, 6 changed lines. Clause-②: no, no packages/spec/src path, so no contract review is owed. skip-changeset holds (a test file ships in no package). Landing on the maintainer's standing words 「按照 pm-dispatch 规则复核过的都授权」 (2026-10-25T11:35Z) and 「你应该使用 pm-dispatch 技能审核和落地pr」 (2026-11-07T16:59Z). Relay pr_ready, then automerge_enable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xs skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

1 participant