test(session): cover the header baseline validation and persistence round-trip

CI per-file coverage flagged the new sandboxMode/approvalPolicy branches:
invalid-type cases in both session header validation tables, and a shared
persistence-contract case pinning that both backends round-trip the
baselines verbatim and keep absent fields ABSENT (presence is the signal
the policy owners branch on).
This commit is contained in:
kingwl
2026-07-26 19:30:27 +08:00
parent 12a05e2692
commit ffb6435a41
2 changed files with 34 additions and 0 deletions

View File

@@ -764,6 +764,8 @@ describe('Session', () => {
{ header: { ...base, seedLength: '1' }, error: /seedLength must be a non-negative safe integer/ },
{ header: { ...base, seedLength: 0.5 }, error: /seedLength must be a non-negative safe integer/ },
{ header: { ...base, seedLength: -1 }, error: /seedLength must be a non-negative safe integer/ },
{ header: { ...base, sandboxMode: 1 }, error: /header sandboxMode must be a string/ },
{ header: { ...base, approvalPolicy: 1 }, error: /header approvalPolicy must be a string/ },
]
for (const { header, error } of cases) {
@@ -1011,6 +1013,8 @@ describe('SessionStore', () => {
{ meta: { delegationDepth: '1' }, error: /delegationDepth must be a non-negative safe integer/ },
{ meta: { delegationDepth: 0.5 }, error: /delegationDepth must be a non-negative safe integer/ },
{ meta: { delegationDepth: -1 }, error: /delegationDepth must be a non-negative safe integer/ },
{ meta: { sandboxMode: 1 }, error: /header sandboxMode must be a string/ },
{ meta: { approvalPolicy: 1 }, error: /header approvalPolicy must be a string/ },
]
for (const [index, { meta, error }] of cases.entries()) {