Skip to content

Commit f2eb047

Browse files
committed
test: close three coverage gaps the post-merge audit found mutation-surviving
All three guard real behavior that no test actually pinned: - antigravity canonicalization: removing MAX_CANONICAL_DEPTH left all 34 tests green. Byte and key budgets do not bound recursion — a deeply nested argument is tiny on the wire — so without the cap a replay observation throws RangeError instead of skipping. Depth 120 canonicalizes, 200 and 50k refuse with null. - scheduler settle predicate: the end-to-end unknown-SCM test sets taskInstalled and registrationHealthy true, so its final clause is already false and deleting the nativeServiceAbsent guard left it green. schedulerVerificationMaySettle is now exercised directly against a transient-looking tail, one unproven flag at a time, and goes red when that guard is removed. - ephemeral ACL memo release: the test inherited USERNAME from an earlier block's `??=`, which never restores it, so running it alone or in another order failed before reaching the memo behavior. It sets and restores its own environment now.
1 parent 99747ca commit f2eb047

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

tests/google-antigravity-replay.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,25 @@ describe("antigravity replay fixed-size key identities", () => {
413413
expect(antigravityCanonicalJsonBoundedForTests({ a: [1, "x"] }, 1024)).toBe('{"a":[1,"x"]}');
414414
});
415415

416+
test("pathological nesting is refused by the depth cap, not by a stack overflow", () => {
417+
// The byte and key budgets do not bound RECURSION: a deeply nested argument
418+
// shape is tiny on the wire. Without the depth cap this walk exhausts the
419+
// stack and throws RangeError out of a replay observation, which is a crash
420+
// path rather than a skipped replay. Removing MAX_CANONICAL_DEPTH left every
421+
// other antigravity test green, so this is the only case that pins it.
422+
const nest = (levels: number): unknown => {
423+
let value: unknown = 1;
424+
for (let i = 0; i < levels; i++) value = { n: value };
425+
return value;
426+
};
427+
428+
// Comfortably inside the cap: canonicalizes normally.
429+
expect(antigravityCanonicalJsonBoundedForTests(nest(120), 1024 * 1024)).toContain('{"n":');
430+
// Past the cap: a null refusal, never a thrown RangeError.
431+
expect(antigravityCanonicalJsonBoundedForTests(nest(200), 1024 * 1024)).toBeNull();
432+
expect(antigravityCanonicalJsonBoundedForTests(nest(50_000), 8 * 1024 * 1024)).toBeNull();
433+
});
434+
416435
test("overflow aborts the walk near the cap, proven by scan instrumentation", () => {
417436
resetCanonicalScanUnitsForTests();
418437
const hugeString = "y".repeat(10 * 1024 * 1024);

tests/windows-elevation-spawn.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
import {
2323
evaluateSchedulerInstallRestartReconciliation,
2424
finalizeWindowsSchedulerServiceRegistration,
25+
schedulerVerificationMaySettle,
2526
setFinalizeWindowsSchedulerHooksForTests,
2627
} from "../src/service";
2728
import type { WindowsSchedulerInstallVerification } from "../src/service";
@@ -987,6 +988,43 @@ describe("finalizeWindowsSchedulerServiceRegistration", () => {
987988
expect(parentRollbackLaunches).toBe(0);
988989
});
989990

991+
test("the settle predicate refuses every unproven state on its own terms", () => {
992+
// The end-to-end unknown-SCM test above cannot isolate this: its fixture has
993+
// taskInstalled and registrationHealthy both true, so the FINAL clause is
994+
// already false and deleting an earlier guard leaves it green. Exercising the
995+
// predicate directly with a transient-looking tail (invisible task) is what
996+
// proves each guard carries its own weight.
997+
const transientTail: WindowsSchedulerInstallVerification = {
998+
taskInstalled: false,
999+
registrationHealthy: false,
1000+
registrationInvalid: false,
1001+
assetsHealthy: true,
1002+
nativeServiceAbsent: true,
1003+
nativeStatusUnknown: false,
1004+
conflict: false,
1005+
ok: false,
1006+
detail: "Task Scheduler task is not installed.",
1007+
};
1008+
1009+
// Baseline: a scheduler view that has genuinely not caught up may settle.
1010+
expect(schedulerVerificationMaySettle(transientTail)).toBe(true);
1011+
1012+
// Each of these is unproven or permanent, and must refuse even though the
1013+
// transient tail below it still looks retryable.
1014+
expect(schedulerVerificationMaySettle({ ...transientTail, ok: true })).toBe(false);
1015+
expect(schedulerVerificationMaySettle({ ...transientTail, conflict: true })).toBe(false);
1016+
expect(schedulerVerificationMaySettle({ ...transientTail, assetsHealthy: false })).toBe(false);
1017+
expect(schedulerVerificationMaySettle({ ...transientTail, nativeServiceAbsent: false })).toBe(false);
1018+
expect(schedulerVerificationMaySettle({ ...transientTail, registrationInvalid: true })).toBe(false);
1019+
1020+
// And a fully healthy-but-not-ok view has nothing left to wait for.
1021+
expect(schedulerVerificationMaySettle({
1022+
...transientTail,
1023+
taskInstalled: true,
1024+
registrationHealthy: true,
1025+
})).toBe(false);
1026+
});
1027+
9901028
test("ownership lost during a settle delay stops without rollback or state write", async () => {
9911029
mockParentRollbackSpawn();
9921030
let owned = true;

tests/windows-secret-acl.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,12 @@ describe("ephemeral ACL memo release (#840 refinement)", () => {
626626
test("ephemeral release clears temp-keyed timeout memos in BOTH namespaces", () => {
627627
setPlatformForTests("win32");
628628
setIcaclsRunnerForTests(() => timeout);
629+
// Own the environment this test needs. It used to inherit USERNAME from an
630+
// earlier describe's `??=`, which never restores it: run this file's blocks in
631+
// another order, or this test alone, and the harden fails before it ever
632+
// reaches the memo behavior under test.
633+
const previousUsername = process.env.USERNAME;
634+
process.env.USERNAME = "ocx-test-user";
629635
const tempA = join(testDir, "dest.ocx.1.1.tmp");
630636
const tempB = join(testDir, "dest.ocx.1.2.tmp");
631637
writeFileSync(tempA, "a", "utf-8");
@@ -642,6 +648,8 @@ describe("ephemeral ACL memo release (#840 refinement)", () => {
642648
} finally {
643649
setIcaclsRunnerForTests(null);
644650
setPlatformForTests(null);
651+
if (previousUsername === undefined) delete process.env.USERNAME;
652+
else process.env.USERNAME = previousUsername;
645653
}
646654
});
647655

0 commit comments

Comments
 (0)