eyemind 0.5.32 → 0.6.0

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/src/srl.js CHANGED
@@ -40,7 +40,7 @@ import { loadText, statementSources } from './lang.js';
40
40
  import { Program, Source } from './program.js';
41
41
  import { DEFAULT_GRAPH } from './rdf.js';
42
42
  import { readTerms } from './reader.js';
43
- import { Struct, Var, conjunction, identity, isGround } from './terms.js';
43
+ import { Env, Struct, Var, conjunction, identity, isGround, properListItems } from './terms.js';
44
44
  import { write } from './writer.js';
45
45
 
46
46
  export class SrlError extends Error {}
@@ -154,7 +154,9 @@ export function compileRuleSet(ruleSet, { data = [], source = '<input>', context
154
154
  });
155
155
  if (needed.has('srl_now') || needed.has('srl_uuid')) {
156
156
  context = executionContext(context);
157
- parts.push(`fact(srl_execution(${q(context.now)}, ${q(context.seed)}))`);
157
+ // A rule rather than a fact, so that a proof using the context holds its
158
+ // call table, from which a later check recompiles the same program.
159
+ parts.push(`implied_by(srl_execution(${q(context.now)}, ${q(context.seed)}), 'true')`);
158
160
  }
159
161
  parts.push('query(inf(S, P, O))');
160
162
  const library = libraryText(needed);
@@ -206,17 +208,17 @@ function executionContext(context) {
206
208
 
207
209
  export function srlContextFromProof(document) {
208
210
  try {
211
+ // The proof records the execution context as the answer of the call
212
+ // table of srl_execution/2 that the firings using it consult.
209
213
  const contexts = readTerms(document).map(([term]) => term)
210
- .filter((t) => t instanceof Struct && t.name === 'clause' && t.args.length === 2)
211
- .map((t) => t.args[1])
212
- .filter((t) => t instanceof Struct && t.name === 'fact' && t.args.length === 1)
213
- .map((t) => t.args[0])
214
+ .filter((t) => t instanceof Struct && t.name === 'called' && t.args.length === 2 &&
215
+ t.args[0] instanceof Struct && t.args[0].name === 'srl_execution' && t.args[0].args.length === 2)
216
+ .flatMap((t) => properListItems(t.args[1], new Env()) ?? [])
214
217
  .filter((t) => t instanceof Struct && t.name === 'srl_execution' && t.args.length === 2);
215
- if (contexts.length !== 1) return null;
218
+ if (new Set(contexts.map((t) => identity(t))).size !== 1) return null;
216
219
  return executionContext({ now: contexts[0].args[0], seed: contexts[0].args[1] });
217
220
  } catch {
218
- // The ordinary checker reports malformed certificates, including native
219
- // displays that disagree with their complete encoded records.
221
+ // The ordinary checker reports malformed proofs.
220
222
  return null;
221
223
  }
222
224
  }
package/src/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // The release this checkout is; ./release keeps it in step with package.json.
2
- export const VERSION = '0.5.32';
2
+ export const VERSION = '0.6.0';