Skip to content
Open
7 changes: 7 additions & 0 deletions docs/architecture/tla/FileLockCleanup.DoubleRelease.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions docs/architecture/tla/FileLockCleanup.NoAwait.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions docs/architecture/tla/FileLockCleanup.NoRelease.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions docs/architecture/tla/FileLockCleanup.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions docs/architecture/tla/FileLockCleanup.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---- MODULE FileLockCleanup ----
\* Source: withFileLock acquisition and callback. Sink: release count and returned outcome.
\* Failure: release is early, omitted, repeated, or hides the operation outcome.
\* Property test: utils/__tests__/fileLock.test.ts. Errors are input oracles.
\* Replay: all four cleanup mutations fail real-code tests. Original cleanup cases pass.
\* Review ratchet: added 0, covered 0, gap 0. This is a simplification contract.
\* Expect: fixed checks pass and each retained guard-removal check fails.
\* Cost: one agent; split from independent projections of the 192-state model.
\* Result: fixed passes in 24 states; all 4 failure variants fail. No new defect found.
\* Prior review or proposal came before these invariants.
\* This model does not prove the code. No new production change is included.
EXTENDS Naturals, FiniteSets
CONSTANTS CleanupPolicy, KeepOperationOutcome, AwaitOperation
VARIABLES cleanupPhase, operationOutcome, releaseFails, acquireFails, releaseCount, returned
vars == <<cleanupPhase, operationOutcome, releaseFails, acquireFails, releaseCount, returned>>
Init == cleanupPhase = "acquire" /\ operationOutcome \in {"ok", "error"}
/\ releaseFails \in BOOLEAN /\ acquireFails \in BOOLEAN /\ releaseCount = 0 /\ returned = "none"
AcquireForWork ==
/\ cleanupPhase = "acquire"
/\ cleanupPhase' = IF acquireFails THEN "done" ELSE "operation"
/\ returned' = IF acquireFails THEN "acquire-error" ELSE returned
/\ UNCHANGED <<operationOutcome, releaseFails, acquireFails, releaseCount>>
FinishOperation ==
/\ cleanupPhase = "operation" /\ cleanupPhase' = "cleanup"
/\ UNCHANGED <<operationOutcome, releaseFails, acquireFails, releaseCount, returned>>
FinishCleanup ==
/\ cleanupPhase = "cleanup" /\ cleanupPhase' = "done"
/\ releaseCount' = CASE CleanupPolicy = "never" -> 0 [] CleanupPolicy = "twice" -> 2 [] OTHER -> 1
/\ returned' = IF releaseFails /\ ~KeepOperationOutcome THEN "release-error" ELSE operationOutcome
/\ UNCHANGED <<operationOutcome, releaseFails, acquireFails>>
ReleaseEarly ==
/\ cleanupPhase = "operation" /\ ~AwaitOperation /\ releaseCount = 0 /\ releaseCount' = 1
/\ UNCHANGED <<cleanupPhase, operationOutcome, releaseFails, acquireFails, returned>>
Next == AcquireForWork \/ FinishOperation \/ FinishCleanup \/ ReleaseEarly
Spec == Init /\ [][Next]_vars
ReleaseAfterOperation == cleanupPhase = "operation" => releaseCount = 0
ReleasedOnce == cleanupPhase = "done" => releaseCount = IF acquireFails THEN 0 ELSE 1
PreservedOutcome == cleanupPhase = "done" => returned = IF acquireFails THEN "acquire-error" ELSE operationOutcome
====

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/architecture/tla/JsonFaultInjection.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions docs/architecture/tla/JsonFaultInjection.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---- MODULE JsonFaultInjection ----
\* Source: writer and TaskHistoryStore test paths. Sink: rename, stat, and unlink fault hooks.
\* Failure: a lexical fixture path does not match the canonical writer path.
\* Expect: canonical fixtures reach the hook; the alias variant fails.
\* Property tests: safeWriteJson.test.ts and safeWriteJson.interruption.test.ts in utils/__tests__.
\* Replay: an aliased TMPDIR reproduced all 15 Windows assertion failures on Linux.
\* After the fix, both suites pass all 53 cases with an aliased TMPDIR and the CI config.
\* CI ratchet: added 1, covered 0, gap 0. CI logs came before this invariant.
\* Cost: one agent, two fixture roots. Result: fixed passes in 6 states; the alias variant fails. No new defect found.
\* This checks path-spelling assumptions, not native path resolution or production code.
\* PR #2762 follow-up: covered 2, added 0, gap 0. The same alias mismatch bypassed unlink hooks.
\* Property test: core/task-persistence/__tests__/TaskHistoryStore.deleteSemantics.spec.ts.
\* Expect: resolving the fixture root restores all three missing unlink failures.
\* Replay before fix: an aliased TMPDIR reproduces all three Windows failures on Linux.
\* Wider alias replay: a read barrier also paused the delete helper at a different path spelling.
\* Property test: core/task-persistence/__tests__/TaskHistoryStore.realConcurrency.spec.ts.
\* Follow-up result: 240 tests pass with an aliased TMPDIR. No new production defect found.
\* Cost: one agent, two fixture roots; no model state was added.
\* Windows CI passes the writer suites; the TaskHistoryStore fixture fix awaits native CI.
EXTENDS Naturals
CONSTANT CanonicalFixtures
VARIABLES fixturePath, phase, hookObserved
vars == <<fixturePath, phase, hookObserved>>
WriterTarget == "canonical"
HookTarget == IF CanonicalFixtures THEN WriterTarget ELSE fixturePath
Init == fixturePath \in {"canonical", "alias"} /\ phase = "setup" /\ hookObserved = FALSE
Prepare == phase = "setup" /\ phase' = "ready" /\ UNCHANGED <<fixturePath, hookObserved>>
Observe == phase = "ready" /\ phase' = "observed"
/\ hookObserved' = (HookTarget = WriterTarget) /\ UNCHANGED fixturePath
Next == Prepare \/ Observe
Spec == Init /\ [][Next]_vars
FaultReached == phase = "observed" => hookObserved
====

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions docs/architecture/tla/JsonFileLockIdentity.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions docs/architecture/tla/JsonFileLockIdentity.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---- MODULE JsonFileLockIdentity ----
\* Source: resolveFileLockPath. Sink: acquireFileLock and write, delete, and recovery paths.
\* Failure: operations on one stable file alias use different locks and overlap.
\* Property test: utils/__tests__/jsonFileLockIdentity.test.ts.
\* Follow-up to #2762: added 1, covered 0, gap 0. This was a supplied observation.
\* Replay: four leaf-link cases failed before the fix; all alias cases pass after it.
\* Path resolution is an oracle. Concurrent link changes remain outside scope.
\* Expect: fixed checks pass and each retained guard-removal check fails.
\* Cost: one agent; split from independent projections of the 192-state model.
\* Result: fixed passes in 4 states; all 1 failure variants fail. No new defect found.
\* Prior review or proposal came before these invariants.
\* Review #2762 through 293de2b9d6 #12: gap 1. Path resolution is an oracle in this lock model.
\* The native relative-link test failed before resolving the physical parent and passes after it.
\* The model cannot parse native paths. Expect unchanged four-state lock results; no new model defect expected.
\* This model does not prove the code. Cost: one regression test and one path expression.
EXTENDS Naturals, FiniteSets
CONSTANTS CanonicalLocks
VARIABLES active
vars == <<active>>
Operations == {"write", "delete", "recover"}
LockKey(op) == IF CanonicalLocks \/ op = "write" THEN "real" ELSE "alias"
Init == active = {}
Acquire ==
/\ \E op \in Operations \ active :
/\ \A peer \in active : LockKey(peer) # LockKey(op)
/\ active' = active \cup {op}

Release ==
/\ \E op \in active : active' = active \ {op}

Next == Acquire \/ Release
Spec == Init /\ [][Next]_vars
SameFileSerialized == Cardinality(active) <= 1
====
10 changes: 10 additions & 0 deletions docs/architecture/tla/JsonWriteMetadata.NoFollowLink.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions docs/architecture/tla/JsonWriteMetadata.NoPreserveMode.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions docs/architecture/tla/JsonWriteMetadata.NoSkipMerge.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions docs/architecture/tla/JsonWriteMetadata.OutsideWorkspace.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions docs/architecture/tla/JsonWriteMetadata.ReadOnlyFlush.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions docs/architecture/tla/JsonWriteMetadata.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions docs/architecture/tla/JsonWriteMetadata.tla
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---- MODULE JsonWriteMetadata ----
\* Source: safeWriteJson reads a path, mode, and merge result. Sink: replacement metadata.
\* Failure: replacement changes permissions, replaces a link, or writes unchanged data.
\* Property test: utils/__tests__/safeWriteJson.metadata.test.ts.
\* Review #2762: added 2 (#14, #16), covered 0, gap 1 (concurrent link changes).
\* Replay: old code fails mode, link, and unchanged-merge cases; the fix passes.
\* Expect: fixed checks pass and each retained guard-removal check fails.
\* Cost: one agent; split from independent projections of the 192-state model.
\* Result: fixed passes in 2 states; all 3 failure variants fail. No new defect found.
\* Prior review or proposal came before these invariants.
\* This model does not prove the code.
EXTENDS Naturals, FiniteSets
\* Review #2762 through 293de2b9d6 #5, #14, #17: added 2, gap 1 (native mode and link errors need tests).
\* Expect: a path outside the workspace cannot be replaced; a read-only target is flushed before mode restore.
\* Resolved containment is an oracle. A changed symlink during path resolution remains outside scope.
\* Source: project Hub, installer, and open-settings writes pass allowedRoot. Sink: safeWriteJson replacement.
\* Result: fixed passes in 2 states; all five failure variants fail. Cost: two input predicates, no extra fixed states.
CONSTANTS GuardRoot, FlushBeforeMode
CONSTANTS PreserveMode, FollowLink, SkipMerge
VARIABLES phase, modeKept, linkKept, unchangedKept, boundaryKept, flushed
vars == <<phase, modeKept, linkKept, unchangedKept, boundaryKept, flushed>>
Init == boundaryKept = TRUE /\ flushed = TRUE /\ phase = "read" /\ modeKept = TRUE /\ linkKept = TRUE /\ unchangedKept = TRUE
Replace ==
/\ phase = "read" /\ phase' = "done"

/\ \E restricted \in BOOLEAN, linked \in BOOLEAN, unchanged \in BOOLEAN, inside \in BOOLEAN :
/\ boundaryKept' = (inside \/ GuardRoot)
/\ flushed' = (~restricted \/ FlushBeforeMode)
/\ modeKept' = (~restricted \/ PreserveMode \/ (unchanged /\ SkipMerge))
/\ linkKept' = (~linked \/ FollowLink \/ (unchanged /\ SkipMerge))
/\ unchangedKept' = (~unchanged \/ SkipMerge)
Next == Replace
Spec == Init /\ [][Next]_vars
WorkspaceOnly == boundaryKept
Flushed == flushed
KeepMode == modeKept
KeepLink == linkKept
SkipUnchanged == unchangedKept
====

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/architecture/tla/McpConnectionOwnership.LateDetach.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/architecture/tla/McpConnectionOwnership.LateSetup.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions docs/architecture/tla/McpConnectionOwnership.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading