Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

law-discovery.md

81 lines4.8 KB

1# Law discovery
2​
3**Use when:** a bug, example, or implementation exists but the promised behavior
4is unclear; several supplied reports may share a law; or an existing law might
5conflate distinct obligations.
6​
7**Inputs:** the question, contract sources, known examples, existing oracle owner
8and limits, and the public observation that matters. A missing authority is an
9input gap, not permission to infer a promise from production.
10​
11With several supplied reports or examples, ask whether one caller-visible
12obligation predicts their different symptoms. Name its common preconditions,
13check an apparent outlier and a nearby case it should permit, and split the
14proposal if those cases require different promises. A descriptive cluster is a
15lead, not evidence that one contract governs every item.
16​
17## Operation
18​
191. State the obligation in domain terms before describing machinery: for which
20 legal inputs or histories, under which preconditions, what must be observable
21 at which checkpoint? Include what can still be pending or unspecified.
222. Trace its authority. Separate accepted contract, observed current behavior,
23 mathematical consequence, and proposed design. Explain why the obligation
24 matters to a caller. A mathematical rule still needs an argument that it is
25 the right rule for this API.
263. Form a plausible rival interpretation. Derive both predictions for the
27 smallest legal case that separates them, without consulting production for
28 the expected answer. If authority does not select a prediction, retain the
29 design question instead of turning one guess into an assertion.
304. Compare an ordinary case with a nearby boundary case. Vary a relevant
31 condition such as cardinality, ordering, identity, authority, or observation
32 time. Keep other conditions fixed where possible. Check the boundary is
33 within the claimed domain.
345. Identify the checkpoint where the contract requires the proposed result; a
35 permitted pending state does not establish a gap. Check whether the result
36 is determined by the information available to the responsible production
37 path there. Seek two legal underlying histories that give the path the same
38 initial state and inputs through that checkpoint but require incompatible
39 public observations. If they exist, name the missing information or provider
40 obligation. A candidate law may be scoped explicitly; do not silently narrow
41 an accepted promise, which requires authority to revise.
426. Describe the smallest independent model that enacts the obligation and limits
43 from step 1 and makes the rival and boundary predictions from steps 3–4.
44 Retain the source facts needed to examine any information gap from step 5,
45 even when the production path has not received them.
46 For any proposed merge of model states, ask whether a legal next action can
47 distinguish them. Map model abstractions to the project vocabulary.
48​
49The information check concerns what production can receive. The test of model
50state concerns what the reference must remember. A model may know a source row
51that the production path has never received. For example, suppose a path must
52publish a full top-ten result after a deletion but receives only the old top
53ten and the deletion. If it cannot receive replacement rows before publication,
54two source datasets can require incompatible results while the path sees the
55same inputs. A live query can request replacement rows with `loadSubset`. If
56the provider supplies them through Collection sync writes that apply before
57publication, that path has the needed information; judge it at its own promised
58publication checkpoint.
59​
60**Return:** the candidate law and status, its source, rival predictions, a
61concrete distinguishing witness, and the next experiment or unresolved decision.
62For an information gap, include the indistinguishable histories and the
63unresolved source, protocol, or scope decision.
64For a simple law, a short paragraph and a worked example suffice.
65​
66**Control:** try a legal alternative implementation. Does the proposed law
67reject it only because its scheduling or representation differs? Also try a
68plausible wrong result: could the proposed observation distinguish it? If an
69information gap is claimed, try a nearby path that supplies the missing input,
70such as a provider backfill. Check whether that input distinguishes the
71histories before the checkpoint; if it does, the original impossibility
72argument no longer applies to that path.
73​
74**Distortion:** freezing an implementation accident into a law; treating a vivid
75edge case as representative; or overstating what is owed at an intermediate cut.
76​
77**Stop when:** the law is precise enough to enact independently, or a named
78missing authority or fact prevents choosing between predictions. Continue other
79authorized work while keeping that choice unresolved.
80​
81Adapted from Field Lab's assumption mapping and ground-condition probe.