|
| 1 | +---- MODULE McpDynamicLoadSettings ---- |
| 2 | +\* Source: the dynamic tool loading inputs in McpView. They write SettingsView cachedState. |
| 3 | +\* Path: SettingsView.handleSubmit sends updateSettings. webviewMessageHandler validates each key and stores it. |
| 4 | +\* Sink: ClineProvider.getStateToPostToWebview posts resolveMcpDynamicLoadSettings of the stored value. |
| 5 | +\* Failure 1: the panel shows a saved value that the host dropped, so the runtime uses a different value. |
| 6 | +\* Failure 2: the panel refuses a value that the schema accepts, for example the kill-switch searchTurns 0. |
| 7 | +\* Invariant 1: RoundTrip. With no unsaved change, each shown value equals the effective stored value. |
| 8 | +\* Invariant 2: ValidReachable. The panel accepts each value that the schema accepts. |
| 9 | +\* Oracle: the schema. SchemaAccepts holds for an integer at or above the minimum of the key. |
| 10 | +\* Scope: two keys. searchTurns has minimum 0 like threshold. initialK has minimum 1 like searchK. |
| 11 | +\* Host readers of searchTurns are checked in McpToolSelectionLifecycle (SharedDefault). This file is the webview. |
| 12 | +\* Expect: Raw and Omitted fail RoundTrip. NoZero fails ValidReachable. Fixed holds. |
| 13 | +\* Expect: a null result for the fixed code. The UI uses the same schema as the host. |
| 14 | +\* Assumption: React restores a controlled input after a rejected edit. So the shown value is cachedState. |
| 15 | +\* Result: Fixed holds in 150 states. Raw and Omitted fail RoundTrip. NoZero fails ValidReachable. |
| 16 | +\* Result: null result for the fixed code. The first Fixed run failed TypeOK. It was a spec error, not a code defect. |
| 17 | +\* Replay: parseInt in parseMcpDynamicLoadInput (Raw) fails 7 tests. A minimum of 1 (NoZero) fails 3 tests. |
| 18 | +\* Replay: removal of initialK from handleSubmit (Omitted) fails the SettingsView save test. |
| 19 | +\* Property test: McpDynamicLoadSettings.spec.tsx. Accepted values resolve to themselves. Rejected integers resolve to the default. |
| 20 | +\* Finding: Save writes the shown default to storage. A later change to a default does not reach that user. |
| 21 | +\* Other SettingsView settings do the same. This change does not fix it. |
| 22 | +\* Finding: the issue asks the panel to describe an embeddings ranker. createRanker returns only BM25 (#576). |
| 23 | +\* The panel and README describe BM25 only. |
| 24 | +\* Cost: each TLC config takes under 1 second. Agent time was not measured. |
| 25 | + |
| 26 | +EXTENDS Integers, TLC |
| 27 | +\* Unset and Cleared are model values. Cleared is an empty input. parseInt gives NaN for it. |
| 28 | +CONSTANTS Keys, Min, Default, Typed, Unset, Cleared, Variant |
| 29 | +VARIABLES stored, cached, dirty, rejectedValid |
| 30 | +vars == <<stored, cached, dirty, rejectedValid>> |
| 31 | + |
| 32 | +SchemaAccepts(k, v) == v # Cleared /\ v >= Min[k] |
| 33 | +UiAccepts(k, v) == |
| 34 | + CASE Variant = "Raw" -> v # Cleared |
| 35 | + [] Variant = "NoZero" -> v # Cleared /\ v >= 1 |
| 36 | + [] OTHER -> SchemaAccepts(k, v) |
| 37 | +Sent == IF Variant = "Omitted" THEN Keys \ {"initialK"} ELSE Keys |
| 38 | +Effective(k) == IF stored[k] = Unset THEN Default[k] ELSE stored[k] |
| 39 | +Posted == [k \in Keys |-> Effective(k)] |
| 40 | + |
| 41 | +Init == /\ stored \in [Keys -> {Unset} \cup (Typed \ {Cleared})] |
| 42 | + /\ \A k \in Keys : IF stored[k] = Unset THEN TRUE ELSE SchemaAccepts(k, stored[k]) |
| 43 | + /\ cached = Posted |
| 44 | + /\ dirty = FALSE |
| 45 | + /\ rejectedValid = FALSE |
| 46 | + |
| 47 | +Edit(k, v) == |
| 48 | + /\ IF UiAccepts(k, v) |
| 49 | + THEN /\ cached' = [cached EXCEPT ![k] = v] |
| 50 | + /\ dirty' = (dirty \/ cached[k] # v) |
| 51 | + /\ UNCHANGED rejectedValid |
| 52 | + ELSE /\ rejectedValid' = (rejectedValid \/ SchemaAccepts(k, v)) |
| 53 | + /\ UNCHANGED <<cached, dirty>> |
| 54 | + /\ UNCHANGED stored |
| 55 | + |
| 56 | +\* The host keeps the old value of a key that fails validation. |
| 57 | +Save == /\ dirty |
| 58 | + /\ stored' = [k \in Keys |-> |
| 59 | + IF k \in Sent /\ SchemaAccepts(k, cached[k]) THEN cached[k] ELSE stored[k]] |
| 60 | + /\ dirty' = FALSE |
| 61 | + /\ UNCHANGED <<cached, rejectedValid>> |
| 62 | + |
| 63 | +\* Reload and Discard both copy the posted state into cachedState. |
| 64 | +Reload == /\ cached' = Posted |
| 65 | + /\ dirty' = FALSE |
| 66 | + /\ UNCHANGED <<stored, rejectedValid>> |
| 67 | + |
| 68 | +Next == (\E k \in Keys, v \in Typed : Edit(k, v)) \/ Save \/ Reload |
| 69 | +Spec == Init /\ [][Next]_vars |
| 70 | + |
| 71 | +Shown == Typed \cup {Default[k] : k \in Keys} |
| 72 | +TypeOK == /\ stored \in [Keys -> {Unset} \cup Shown] |
| 73 | + /\ cached \in [Keys -> Shown] |
| 74 | + /\ dirty \in BOOLEAN |
| 75 | + /\ rejectedValid \in BOOLEAN |
| 76 | +RoundTrip == ~dirty => cached = Posted |
| 77 | +ValidReachable == ~rejectedValid |
| 78 | +==== |
0 commit comments