gdp-wired 0.50.2 → 0.50.3

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.
Files changed (49) hide show
  1. package/README.md +4 -2
  2. package/dist/core/cli.d.ts +12 -1
  3. package/dist/core/cli.js +62 -25
  4. package/dist/core/discover.d.ts +6 -1
  5. package/dist/core/discover.js +54 -7
  6. package/dist/core/dsl-deadline.d.ts +3 -0
  7. package/dist/core/dsl-deadline.js +26 -2
  8. package/dist/core/dsl.d.ts +3 -1
  9. package/dist/core/dsl.js +93 -30
  10. package/dist/core/effect.d.ts +12 -0
  11. package/dist/core/effect.js +26 -9
  12. package/dist/core/ex/harness.exs +171 -5
  13. package/dist/core/extract-c.js +63 -6
  14. package/dist/core/extract-check.d.ts +5 -1
  15. package/dist/core/extract-check.js +28 -10
  16. package/dist/core/extract-go-check.js +127 -1
  17. package/dist/core/extract-go.js +8 -2
  18. package/dist/core/extract-jvm.js +2 -2
  19. package/dist/core/extract-rs.js +51 -5
  20. package/dist/core/extract-step.js +40 -6
  21. package/dist/core/extract-swift.js +47 -3
  22. package/dist/core/extract.d.ts +8 -0
  23. package/dist/core/infer.d.ts +8 -0
  24. package/dist/core/infer.js +133 -16
  25. package/dist/core/jvm/Harness.java +135 -3
  26. package/dist/core/jvm/Rt.java +66 -4
  27. package/dist/core/laws.js +51 -10
  28. package/dist/core/native-law.d.ts +3 -1
  29. package/dist/core/native-law.js +126 -14
  30. package/dist/core/native-observations.d.ts +20 -0
  31. package/dist/core/native-observations.js +41 -0
  32. package/dist/core/native-wire.d.ts +1 -0
  33. package/dist/core/native-wire.js +16 -2
  34. package/dist/core/py/harness.py +21 -4
  35. package/dist/core/rb/harness.rb +178 -9
  36. package/dist/core/search-termination.d.ts +35 -0
  37. package/dist/core/search-termination.js +13 -0
  38. package/dist/core/search-watchdog.d.ts +8 -0
  39. package/dist/core/search-watchdog.js +34 -0
  40. package/dist/core/source-check.d.ts +3 -0
  41. package/dist/core/swift/Harness.swift +65 -4
  42. package/dist/core/swift/Main.swift +27 -4
  43. package/dist/core/wall.d.ts +3 -1
  44. package/dist/core/wall.js +7 -4
  45. package/dist/core/work-refusal.d.ts +3 -0
  46. package/dist/core/work-refusal.js +8 -0
  47. package/dist/kernel/prove.d.ts +2 -0
  48. package/dist/kernel/prove.js +13 -5
  49. package/package.json +1 -1
package/dist/core/wall.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Cooperative cancellation of untrusted search. Legacy callers retain their
2
2
  // wall; an explicit work scope never consults it or grants completion headroom.
3
- import { pastWall, clock, searchNow, wallAt, inBudget, inWorkScope, checkBudget, checkWorkAdmission, remainingWork, wallDeadline } from "../kernel/prove.js";
3
+ import { wallTermination, clock, searchNow, wallAt, inBudget, inWorkScope, checkBudget, checkWorkAdmission, remainingWork, wallDeadline } from "../kernel/prove.js";
4
4
  import { runtimeWall } from "./runtime-wall.js";
5
5
  export { wallDeadline, withBudget, budgetEnd, inBudget, checkBudget, checkWorkEndpoint, BudgetExpired, searchNow } from "../kernel/prove.js";
6
6
  export { traceNow } from "./trace-clock.js";
@@ -17,9 +17,11 @@ export const transportEnd = (until, cap = Infinity) => inWorkScope()
17
17
  : Math.min(wallAt(), searchNow() + Math.min(cap, Math.max(0, until - clock()) * 10));
18
18
  export class WallExpired extends Error {
19
19
  phase;
20
- constructor(phase) {
20
+ termination;
21
+ constructor(phase, termination) {
21
22
  super(`time (${phase})`);
22
23
  this.phase = phase;
24
+ this.termination = termination;
23
25
  this.name = 'WallExpired';
24
26
  }
25
27
  }
@@ -28,8 +30,9 @@ export function checkWall(phase) {
28
30
  checkBudget(phase);
29
31
  return;
30
32
  }
31
- if (pastWall())
32
- throw new WallExpired(phase);
33
+ const termination = wallTermination(phase);
34
+ if (termination)
35
+ throw new WallExpired(phase, termination);
33
36
  }
34
37
  // The interpreter must not import the proof engine just to check cancellation.
35
38
  runtimeWall.check = checkWall;
@@ -1 +1,4 @@
1
+ import { type SearchContext } from './search-termination.js';
2
+ export declare function captureWorkContext(error: Error, context: SearchContext): void;
3
+ export declare const workContext: (error: Error) => SearchContext | undefined;
1
4
  export declare function workRefusalWhy(error: Error): string;
@@ -1,5 +1,13 @@
1
1
  // Diagnostic only: never changes refusal ownership, admission or counters.
2
2
  import { workLedger } from "./work-admission.js";
3
+ // Non-authoritative context captured before a search unwinds its SAT/model state.
4
+ // Keep the error identity and the ledger's authenticated refusal untouched.
5
+ const contexts = new WeakMap();
6
+ export function captureWorkContext(error, context) {
7
+ if (!contexts.has(error))
8
+ contexts.set(error, context);
9
+ }
10
+ export const workContext = (error) => contexts.get(error);
3
11
  export function workRefusalWhy(error) {
4
12
  const refusal = workLedger.capacityRefusal(error);
5
13
  return refusal ? `${error.message} [limits=${[...new Set(refusal.limiting.map(endpoint => endpoint.kind))].join(',')}]` : error.message;
@@ -1,3 +1,4 @@
1
+ import type { SearchTermination } from '../core/search-termination.js';
1
2
  import { type C, type E, type Law, type Machine } from '../core/machine.js';
2
3
  import { type Lin } from '../core/solver.js';
3
4
  import { type WorkAmount } from '../core/work-amount.js';
@@ -73,6 +74,7 @@ export type WallDeadline = Readonly<{
73
74
  end: number;
74
75
  }>;
75
76
  export declare const wallDeadline: (end: number, domain?: WallDeadline["domain"]) => WallDeadline;
77
+ export declare const wallTermination: (phase: string) => SearchTermination | undefined;
76
78
  export declare const pastWall: () => boolean;
77
79
  export declare function withWall<T>(limit: number | WallDeadline, f: () => T): T;
78
80
  export declare const wallAt: () => number;
@@ -1,4 +1,5 @@
1
1
  import { retainFamily, retainFrom } from "../core/proof-output.js";
2
+ import { checkWatchdog } from "../core/search-watchdog.js";
2
3
  // An untrusted prover for the kernel: grows a split tree until every leaf's constraints are refuted by solve(), splitting
3
4
  // on whatever atom the hypotheses leave open (an if's condition, a min's or ∸'s comparison, a disjunction's atoms, two
4
5
  // reads of one map at keys not yet known equal or apart). Its trees go to kernel.check; nothing it says is trusted.
@@ -390,6 +391,7 @@ export const budgetEnd = () => {
390
391
  };
391
392
  // Hard-stop checkpoints must not turn a local search deadline into a whole-run stop.
392
393
  export function checkWorkEndpoint(phase) {
394
+ checkWatchdog(phase);
393
395
  if (completeWorkProfile.enabled) {
394
396
  workLedger.check(phase);
395
397
  return;
@@ -521,14 +523,20 @@ export const wallDeadline = (end, domain) => ({ end, domain: domain ?? (inWorkSc
521
523
  // A legacy counted clock is not an opt-in work-only cancellation policy.
522
524
  // Preserve its inherited real wall; only explicit work scopes/profiles elide it.
523
525
  const workOnlyWall = () => inBudget() || stepWorkProfile.enabled;
524
- export const pastWall = () => {
526
+ // Preserve the predicate's original order, but capture the actual clock domain
527
+ // at the cancelling boundary. A WallExpired alone cannot identify real time:
528
+ // pastWall has always included counted stage endpoints as well.
529
+ export const wallTermination = (phase) => {
525
530
  checkWorkEndpoint('prover boundary');
526
531
  const proxy = proxySearchState();
527
- if (proxy)
528
- return clock() > withinDeadline(Infinity) || (!workOnlyWall() && proxy.wallEnd !== Infinity && performance.now() > proxy.wallEnd);
529
- return (inWorkScope() && clock() > withinDeadline(budgetEnd()))
530
- || (!workOnlyWall() && wallEnd !== Infinity && performance.now() > wallEnd);
532
+ if (proxy ? clock() > withinDeadline(Infinity) : inWorkScope() && clock() > withinDeadline(budgetEnd()))
533
+ return { kind: 'work-exhausted', phase, scope: 'stage' };
534
+ const end = proxy ? proxy.wallEnd : wallEnd;
535
+ if (!workOnlyWall() && end !== Infinity && performance.now() > end)
536
+ return { kind: 'wall-deadline', phase, scope: 'search' };
537
+ return undefined;
531
538
  };
539
+ export const pastWall = () => wallTermination('prover boundary') !== undefined;
532
540
  export function withWall(limit, f) {
533
541
  const proxy = proxySearchState();
534
542
  // Untagged legacy endpoints retain their old policy. Search producers tag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdp-wired",
3
- "version": "0.50.2",
3
+ "version": "0.50.3",
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",