gdp-wired 0.55.0 → 0.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -167,7 +167,10 @@ the annotation declared in your code), `@gdp_law("...")` in Python, `@gdp_law ".
167
167
  (`counts[user]`, `user in counts`, `cache["rl:" + user]`), `forall k in m: ...`, a choice by its value (`mode ==
168
168
  "closed"`). Anything else is refused with why, never dropped. Modelling choices a rule needs (`failures = "kept"` for
169
169
  laws about when it raises, a store's attributes, an untyped result) go in a `gdp.toml` beside the code (or `[tool.gdp]`
170
- in pyproject.toml, `"gdp"` in package.json), per rule under `[rules.<name>]`. The exit code is 1 when a stated law is
170
+ in pyproject.toml, `"gdp"` in package.json), per rule under `[rules.<name>]`. When an individual stated invariant or step
171
+ law ends `unknown` (neither proven nor refuted) in default reachable-state `check`, it is retried jointly with the other
172
+ laws stated on the same rule within the time its own budget has left, crediting only that law and only if the kernel checks
173
+ the whole joint family (never changing a proven or refuted verdict). The exit code is 1 when a stated law is
171
174
  broken, 2 when one couldn't be checked: `uses: monotykamary/gdp-wired@main` with `paths:` runs it in CI.
172
175
 
173
176
  Laws about two runs read the same way: `diagnosis never reaches status, result` (two runs differing only in the
@@ -250,7 +253,9 @@ All of these are proven automatically, and each proof is also a Lean theorem:
250
253
  and no run breaks them, it looks for lemmas about the rule's recurrences and lists (`discover`), lemmas about the
251
254
  functions it knows by their facts (`cycleLemmas`, each proven by a cyclic proof) and then invariants (`inferLaws`),
252
255
  under a configurable search allowance (`{search: {ms: 10000}}` by default; `{search: false}`, the prover alone);
253
- the verdict's `found` holds what proved them, as laws and lemmas with the source to paste.
256
+ the verdict's `found` holds what proved them, as laws and lemmas with the source to paste. Callers who pass several
257
+ laws on the same rule (`proveRule(rule, [law1, law2])` or `proveSteps(rule, laws, [step1, step2])`) already get joint
258
+ proof — the search and kernel check all of them together as one family, rather than proving one law at a time.
254
259
  [Explicit counted work and stop causes](docs/search-budgets.md) separate the search allowance from an optional
255
260
  real-time safety watchdog; legacy `ms` is not a promise of machine-independent completion. Each invariant found holds in the states reachable from the
256
261
  start, so a proof that needs one holds there and the verdict says so (`assumes: {states: 'reachable', laws}`). Code that
package/dist/core/cli.js CHANGED
@@ -680,11 +680,12 @@ function* checkPipeline(t, o) {
680
680
  // (from any state, the laws about states as one inductive set: the largest the stated ones make, each law the
681
681
  // kernel's step breaks taken out in turn (Houdini), the others proven together; one taken out is judged alone)
682
682
  const inductive = from && x.rule && !sys ? houdini(x, stated.filter(m => twice(m).length === 1 && kindOf(m) === 'law'), o.ms, ctx, o.work, o.watchdogMs) : undefined;
683
+ const siblings = !from && !sys ? stated.filter(m => twice(m).length === 1) : undefined;
683
684
  const outsOf = [];
684
685
  for (const i of order) {
685
686
  const l = stated[i];
686
687
  outsOf[i] = twice(l).length > 1 ? { name: l.name, expr: l.expr, where: l.where, verdict: 'not read', why: `a law of this name is stated twice (${twice(l).join(', ')}): a law is known by its name`, ms: 0 }
687
- : sys ? proveInEnv(x, l, o.ms, proven, { ...ctx, sys, entry: name }) : prove(x, l, o.ms, proven, { ...ctx, entry: name, ...(from ? { from, inductive, together: stated.filter(m => twice(m).length === 1 && kindOf(m) === 'law' && inductive.has(m.name)) } : {}) });
688
+ : sys ? proveInEnv(x, l, o.ms, proven, { ...ctx, sys, entry: name }) : prove(x, l, o.ms, proven, { ...ctx, entry: name, ...(from ? { from, inductive, together: stated.filter(m => twice(m).length === 1 && kindOf(m) === 'law' && inductive.has(m.name)) } : siblings ? { siblings } : {}) });
688
689
  }
689
690
  r.laws = outsOf;
690
691
  if (o.security) {
@@ -754,12 +755,15 @@ function houdini(x, ls, ms, opts, work, watchdogMs) {
754
755
  // an interchange document whose meta holds them.
755
756
  // The rule a law is proven on: the extraction's, declaring the divisors the law reads that the code doesn't (x // k,
756
757
  // x % k: floor division and remainder by a constant, known by their facts), its machine made again with them.
758
+ function divisorsOf(expr) {
759
+ return [...new Set([...expr.matchAll(/(?:\/\/|%)\s*(\d+)/g)].map(m => Number(m[1])).filter(k => k >= 1))].sort((a, b) => a - b);
760
+ }
757
761
  function ruleFor(x, expr) {
758
762
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
759
763
  const r = x.rule;
760
764
  if (!r)
761
765
  return x;
762
- const ks = [...expr.matchAll(/(?:\/\/|%)\s*(\d+)/g)].map(m => Number(m[1])).filter(k => k >= 1);
766
+ const ks = divisorsOf(expr);
763
767
  return ks.length ? { ...x, rule: r.withDivisors(...ks) } : x;
764
768
  }
765
769
  function prove(x0, l, ms, proven, ctx, work = ctx?.work) {
@@ -857,6 +861,72 @@ function prove(x0, l, ms, proven, ctx, work = ctx?.work) {
857
861
  verdict = 'unknown';
858
862
  if (v.translation === 'error')
859
863
  verdict = 'not read';
864
+ let jointCertInvs;
865
+ // Fallback only: when an ordinary reachable-state law ends unknown (neither proven nor refuted), retry it jointly
866
+ // with the other laws stated on the same rule within the time left in this law's own budget. Credit only this law,
867
+ // and only if the kernel checks the whole joint family (including this law).
868
+ if (verdict === 'unknown' && b && !ctx?.from && work === undefined && !v.proven && !v.run
869
+ && !(v.stopped && v.termination?.kind === 'wall-deadline')
870
+ && v.translation !== 'unchecked' && v.translation !== 'error' && (ctx?.siblings?.length ?? 0) > 1) {
871
+ const budgetCap = ctx.watchdogMs !== undefined ? Math.min(ms, ctx.watchdogMs) : ms;
872
+ const remaining = Math.floor(budgetCap - (cliNow() - t0));
873
+ if (remaining >= 1) {
874
+ const targetDivs = divisorsOf(l.expr).join(',');
875
+ const jointInvs = [...inv];
876
+ const jointSteps = [];
877
+ const addedStated = new Set();
878
+ let siblingCount = 0;
879
+ let targetInJoint = false;
880
+ for (const m of ctx.siblings) {
881
+ if (m.name === l.name) {
882
+ if (b.kind === 'law')
883
+ jointInvs.push(b.law);
884
+ else
885
+ jointSteps.push(b.law);
886
+ addedStated.add(m.name);
887
+ targetInJoint = true;
888
+ continue;
889
+ }
890
+ if (isLeadsTo(m.expr) || isTwoRuns(m.expr) || divisorsOf(m.expr).join(',') !== targetDivs)
891
+ continue;
892
+ let sb;
893
+ try {
894
+ sb = buildLaw(x, m, ctx);
895
+ }
896
+ catch {
897
+ continue;
898
+ }
899
+ if (sb.kind === 'law')
900
+ jointInvs.push(sb.law);
901
+ else
902
+ jointSteps.push(sb.law);
903
+ addedStated.add(m.name);
904
+ siblingCount++;
905
+ }
906
+ if (b.kind === 'step') {
907
+ for (const p of proven)
908
+ if (!addedStated.has(p.name))
909
+ jointInvs.push(p);
910
+ }
911
+ if (targetInJoint && siblingCount >= 1) {
912
+ const jointOpts = { search: { ms: remaining }, ...(!syncControl || ctx.watchdogMs !== undefined ? { watchdogMs: remaining } : {}) };
913
+ try {
914
+ const jv = jointSteps.length
915
+ ? proveSteps(x.rule, jointInvs, jointSteps, jointOpts)
916
+ : proveRule(x.rule, jointInvs, jointOpts);
917
+ if (jv.proven && jv.checked && jv.translation !== 'unchecked' && jv.translation !== 'error') {
918
+ v = jv;
919
+ verdict = 'proven';
920
+ jointCertInvs = jointInvs;
921
+ }
922
+ }
923
+ catch (e) {
924
+ if (e && typeof e === 'object' && e.name === 'Refusal')
925
+ throw e;
926
+ }
927
+ }
928
+ }
929
+ }
860
930
  if (ctx?.from && v.proven && v.assumes)
861
931
  v.why = `proven only in states a run from the start reaches (from = "any" asks for every state the laws allow): it needs ${v.assumes.laws.join('; ') || 'k-induction'}`;
862
932
  // (a run the front end replays on the code: broken only where the code runs it so)
@@ -879,7 +949,8 @@ function prove(x0, l, ms, proven, ctx, work = ctx?.work) {
879
949
  const more = v.found?.laws?.map(f => f.law) ?? [];
880
950
  const meta = { producer: 'gdp-wired check', file: ctx.file, ...(ctx.entry ? { entry: ctx.entry } : {}), law: l.name, expr: l.expr, ...(l.where ? { where: l.where } : {}), cites };
881
951
  const doc = v.k ? undefined : two ? certify(two.rule, [...v.given ?? [], ...more, ...two.laws], two.stepLaws, meta)
882
- : b.kind === 'law' ? certify(x.rule, [...inv, ...more, b.law], [], meta) : certify(x.rule, [...inv, ...proven, ...more], [b.law], meta);
952
+ : jointCertInvs ? certify(x.rule, [...jointCertInvs, ...more], b.kind === 'step' ? [b.law] : [], meta)
953
+ : b.kind === 'law' ? certify(x.rule, [...inv, ...more, b.law], [], meta) : certify(x.rule, [...inv, ...proven, ...more], [b.law], meta);
883
954
  if (doc) {
884
955
  fs.mkdirSync(ctx.cert, { recursive: true });
885
956
  cert = path.join(ctx.cert, `${[ctx.entry ?? path.basename(ctx.file), l.name].join('.').replace(/[^\w.-]+/g, '-')}.json`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdp-wired",
3
- "version": "0.55.0",
3
+ "version": "0.55.1",
4
4
  "description": "An automatic prover for stateful rules (budgets, caps, windows, workflows, policies): laws proven with no proof to write, checked again in Lean, counterexamples found on the GPU, the rule shipped as code",
5
5
  "keywords": [
6
6
  "verification",