eyeling 1.26.3 → 1.26.4

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/eyeling.js CHANGED
@@ -5535,6 +5535,27 @@ const INFERENCE_FUSE_EXIT_CODE = 65;
5535
5535
  const RDF_NIL_IRI = RDF_NS + 'nil';
5536
5536
  const EMPTY_LIST_TERM = new ListTerm([]);
5537
5537
 
5538
+ const LOG_COLLECT_ALL_IN_IRI = LOG_NS + 'collectAllIn';
5539
+ const LOG_FOR_ALL_IN_IRI = LOG_NS + 'forAllIn';
5540
+ const LOG_INCLUDES_IRI = LOG_NS + 'includes';
5541
+ const LOG_NOT_INCLUDES_IRI = LOG_NS + 'notIncludes';
5542
+ const LOG_IMPLIES_IRI = LOG_NS + 'implies';
5543
+ const LOG_IMPLIED_BY_IRI = LOG_NS + 'impliedBy';
5544
+
5545
+ const MATH_BUILTINS_SATISFIABLE_WHEN_FULLY_UNBOUND = new Set([
5546
+ MATH_NS + 'sin',
5547
+ MATH_NS + 'cos',
5548
+ MATH_NS + 'tan',
5549
+ MATH_NS + 'asin',
5550
+ MATH_NS + 'acos',
5551
+ MATH_NS + 'atan',
5552
+ MATH_NS + 'sinh',
5553
+ MATH_NS + 'cosh',
5554
+ MATH_NS + 'tanh',
5555
+ MATH_NS + 'degrees',
5556
+ MATH_NS + 'negation',
5557
+ ]);
5558
+
5538
5559
  const { lex, N3SyntaxError } = require('./lexer');
5539
5560
  const { Parser } = require('./parser');
5540
5561
  const { liftBlankRuleVars } = require('./rules');
@@ -5595,10 +5616,29 @@ function __cloneSubst(subst) {
5595
5616
  return out;
5596
5617
  }
5597
5618
 
5619
+ function __defineHidden(obj, name, value, writable) {
5620
+ Object.defineProperty(obj, name, { value, enumerable: false, writable, configurable: true });
5621
+ }
5622
+
5623
+ function __defineHiddenValue(obj, name, value) {
5624
+ __defineHidden(obj, name, value, false);
5625
+ }
5626
+
5598
5627
  function __defineHiddenWritable(obj, name, value) {
5599
- Object.defineProperty(obj, name, { value, enumerable: false, writable: true });
5628
+ __defineHidden(obj, name, value, true);
5600
5629
  }
5601
5630
 
5631
+ function __setHiddenWritable(obj, name, value) {
5632
+ if (hasOwn.call(obj, name)) obj[name] = value;
5633
+ else __defineHiddenWritable(obj, name, value);
5634
+ }
5635
+
5636
+ const FACT_INDEX_ARRAY_FIELDS = ['__varPred', '__varPredNonFastS', '__varPredNonFastO'];
5637
+ const FACT_INDEX_ARRAY_MAP_FIELDS = ['__byPred', '__byPNonFastS', '__byPNonFastO', '__varPredPS', '__varPredPO'];
5638
+ const FACT_INDEX_NESTED_ARRAY_MAP_FIELDS = ['__byPS', '__byPO'];
5639
+ const FACT_INDEX_MAP_FIELDS = FACT_INDEX_ARRAY_MAP_FIELDS.concat(FACT_INDEX_NESTED_ARRAY_MAP_FIELDS);
5640
+ const FACT_INDEX_REQUIRED_FIELDS = FACT_INDEX_ARRAY_FIELDS.concat(FACT_INDEX_MAP_FIELDS, ['__keySet']);
5641
+
5602
5642
  let version = 'dev';
5603
5643
  try {
5604
5644
  // Node: keep package.json version if available
@@ -5822,14 +5862,13 @@ function __firingKey(ruleIndex, instantiatedPremises) {
5822
5862
  // -----------------------------------------------------------------------------
5823
5863
  function __ensureRuleKeySet(rules) {
5824
5864
  if (!hasOwn.call(rules, '__ruleKeySet')) {
5825
- Object.defineProperty(rules, '__ruleKeySet', {
5826
- value: new Set(
5865
+ __defineHiddenValue(
5866
+ rules,
5867
+ '__ruleKeySet',
5868
+ new Set(
5827
5869
  rules.map((r) => __ruleKey(r.isForward, r.isFuse, r.premise, r.conclusion, r.__dynamicConclusionTerm || null)),
5828
5870
  ),
5829
- enumerable: false,
5830
- writable: false,
5831
- configurable: true,
5832
- });
5871
+ );
5833
5872
  }
5834
5873
  return rules.__ruleKeySet;
5835
5874
  }
@@ -5847,28 +5886,13 @@ function __computeHeadIsStrictGround(r) {
5847
5886
  function __prepareForwardRule(r) {
5848
5887
  if (!hasOwn.call(r, '__scopedSkipInfo')) {
5849
5888
  const info = __computeForwardRuleScopedSkipInfo(r);
5850
- Object.defineProperty(r, '__scopedSkipInfo', {
5851
- value: info,
5852
- enumerable: false,
5853
- writable: false,
5854
- configurable: true,
5855
- });
5889
+ __defineHiddenValue(r, '__scopedSkipInfo', info);
5856
5890
  }
5857
5891
  if (!hasOwn.call(r, '__headIsStrictGround')) {
5858
- Object.defineProperty(r, '__headIsStrictGround', {
5859
- value: __computeHeadIsStrictGround(r),
5860
- enumerable: false,
5861
- writable: false,
5862
- configurable: true,
5863
- });
5892
+ __defineHiddenValue(r, '__headIsStrictGround', __computeHeadIsStrictGround(r));
5864
5893
  }
5865
5894
  if (!hasOwn.call(r, '__needsForwardSkipCheck')) {
5866
- Object.defineProperty(r, '__needsForwardSkipCheck', {
5867
- value: !!(r.__headIsStrictGround || (r.__scopedSkipInfo && r.__scopedSkipInfo.needsSnap)),
5868
- enumerable: false,
5869
- writable: false,
5870
- configurable: true,
5871
- });
5895
+ __defineHiddenValue(r, '__needsForwardSkipCheck', !!(r.__headIsStrictGround || (r.__scopedSkipInfo && r.__scopedSkipInfo.needsSnap)));
5872
5896
  }
5873
5897
  }
5874
5898
 
@@ -5926,13 +5950,13 @@ function __computeMaxScopedClosurePriorityNeeded(forwardRules, backRules) {
5926
5950
  const pv = tr.p.value;
5927
5951
 
5928
5952
  // log:collectAllIn / log:forAllIn use the object position for the priority.
5929
- if (pv === LOG_NS + 'collectAllIn' || pv === LOG_NS + 'forAllIn') {
5953
+ if (pv === LOG_COLLECT_ALL_IN_IRI || pv === LOG_FOR_ALL_IN_IRI) {
5930
5954
  bumpMaxPriority(tr.o);
5931
5955
  return;
5932
5956
  }
5933
5957
 
5934
5958
  // log:includes / log:notIncludes use the subject position for the priority.
5935
- if (pv === LOG_NS + 'includes' || pv === LOG_NS + 'notIncludes') bumpMaxPriority(tr.s);
5959
+ if (pv === LOG_INCLUDES_IRI || pv === LOG_NOT_INCLUDES_IRI) bumpMaxPriority(tr.s);
5936
5960
  }
5937
5961
 
5938
5962
  for (const r of forwardRules) {
@@ -5944,17 +5968,6 @@ function __computeMaxScopedClosurePriorityNeeded(forwardRules, backRules) {
5944
5968
  return maxP;
5945
5969
  }
5946
5970
 
5947
- function __termContainsVarName(t, name) {
5948
- if (t instanceof Var) return t.name === name;
5949
- if (t instanceof ListTerm) return t.elems.some((e) => __termContainsVarName(e, name));
5950
- if (t instanceof OpenListTerm) return t.tailVar === name || t.prefix.some((e) => __termContainsVarName(e, name));
5951
- if (t instanceof GraphTerm)
5952
- return t.triples.some(
5953
- (tr) =>
5954
- __termContainsVarName(tr.s, name) || __termContainsVarName(tr.p, name) || __termContainsVarName(tr.o, name),
5955
- );
5956
- return false;
5957
- }
5958
5971
 
5959
5972
  function __varOccursElsewhereInPremise(premise, name, idx, field) {
5960
5973
  for (let i = 0; i < premise.length; i++) {
@@ -5962,9 +5975,9 @@ function __varOccursElsewhereInPremise(premise, name, idx, field) {
5962
5975
  if (!(tr && tr.s && tr.p && tr.o)) continue;
5963
5976
 
5964
5977
  // Skip the specific scope/priority occurrence we are analyzing.
5965
- if (!(i === idx && field === 's') && __termContainsVarName(tr.s, name)) return true;
5966
- if (!(i === idx && field === 'p') && __termContainsVarName(tr.p, name)) return true;
5967
- if (!(i === idx && field === 'o') && __termContainsVarName(tr.o, name)) return true;
5978
+ if (!(i === idx && field === 's') && containsVarTerm(tr.s, name)) return true;
5979
+ if (!(i === idx && field === 'p') && containsVarTerm(tr.p, name)) return true;
5980
+ if (!(i === idx && field === 'o') && containsVarTerm(tr.o, name)) return true;
5968
5981
  }
5969
5982
  return false;
5970
5983
  }
@@ -5995,7 +6008,7 @@ function __analyzeForwardRuleScopedUse(rule) {
5995
6008
  if (!(tr && tr.p instanceof Iri)) continue;
5996
6009
  const pv = tr.p.value;
5997
6010
 
5998
- if (pv === LOG_NS + 'includes' || pv === LOG_NS + 'notIncludes') {
6011
+ if (pv === LOG_INCLUDES_IRI || pv === LOG_NOT_INCLUDES_IRI) {
5999
6012
  // Explicit quoted scopes are local formulas, not snapshots of the global closure.
6000
6013
  if (tr.s instanceof GraphTerm) continue;
6001
6014
 
@@ -6009,7 +6022,7 @@ function __analyzeForwardRuleScopedUse(rule) {
6009
6022
  continue;
6010
6023
  }
6011
6024
 
6012
- if (pv === LOG_NS + 'collectAllIn') {
6025
+ if (pv === LOG_COLLECT_ALL_IN_IRI) {
6013
6026
  if (tr.o instanceof GraphTerm) continue;
6014
6027
 
6015
6028
  out.needsSnap = true;
@@ -6021,7 +6034,7 @@ function __analyzeForwardRuleScopedUse(rule) {
6021
6034
  continue;
6022
6035
  }
6023
6036
 
6024
- if (pv === LOG_NS + 'forAllIn') {
6037
+ if (pv === LOG_FOR_ALL_IN_IRI) {
6025
6038
  if (tr.o instanceof GraphTerm) continue;
6026
6039
 
6027
6040
  out.needsSnap = true;
@@ -6063,16 +6076,7 @@ function __setForwardRuleScopedStratumInfo(rule, level) {
6063
6076
  ? { needsSnap: true, requiredLevel: level, exactLevel: true }
6064
6077
  : { needsSnap: false, requiredLevel: 0, exactLevel: false };
6065
6078
 
6066
- if (!hasOwn.call(rule, '__scopedStratumInfo')) {
6067
- Object.defineProperty(rule, '__scopedStratumInfo', {
6068
- value,
6069
- enumerable: false,
6070
- writable: true,
6071
- configurable: true,
6072
- });
6073
- } else {
6074
- rule.__scopedStratumInfo = value;
6075
- }
6079
+ __setHiddenWritable(rule, '__scopedStratumInfo', value);
6076
6080
  }
6077
6081
 
6078
6082
  function __computeForwardRuleScopedStrata(forwardRules) {
@@ -6146,9 +6150,9 @@ function __computeForwardRuleScopedSkipInfo(rule) {
6146
6150
  if (!(tr && tr.p instanceof Iri)) continue;
6147
6151
  const pv = tr.p.value;
6148
6152
 
6149
- if (pv === LOG_NS + 'collectAllIn' || pv === LOG_NS + 'forAllIn') {
6153
+ if (pv === LOG_COLLECT_ALL_IN_IRI || pv === LOG_FOR_ALL_IN_IRI) {
6150
6154
  if (!addScopedUse(tr.o, i, 'o')) return null;
6151
- } else if (pv === LOG_NS + 'includes' || pv === LOG_NS + 'notIncludes') {
6155
+ } else if (pv === LOG_INCLUDES_IRI || pv === LOG_NOT_INCLUDES_IRI) {
6152
6156
  if (!addScopedUse(tr.s, i, 's')) return null;
6153
6157
  }
6154
6158
  }
@@ -6740,31 +6744,10 @@ function tripleFastKey(tr) {
6740
6744
  }
6741
6745
 
6742
6746
  function ensureFactIndexes(facts) {
6743
- if (
6744
- facts.__byPred &&
6745
- facts.__byPS &&
6746
- facts.__byPO &&
6747
- facts.__byPNonFastS &&
6748
- facts.__byPNonFastO &&
6749
- facts.__varPred &&
6750
- facts.__varPredPS &&
6751
- facts.__varPredPO &&
6752
- facts.__varPredNonFastS &&
6753
- facts.__varPredNonFastO &&
6754
- facts.__keySet
6755
- )
6756
- return;
6747
+ if (FACT_INDEX_REQUIRED_FIELDS.every((name) => facts[name])) return;
6757
6748
 
6758
- __defineHiddenWritable(facts, '__byPred', new Map());
6759
- __defineHiddenWritable(facts, '__byPS', new Map());
6760
- __defineHiddenWritable(facts, '__byPO', new Map());
6761
- __defineHiddenWritable(facts, '__byPNonFastS', new Map());
6762
- __defineHiddenWritable(facts, '__byPNonFastO', new Map());
6763
- __defineHiddenWritable(facts, '__varPred', []);
6764
- __defineHiddenWritable(facts, '__varPredPS', new Map());
6765
- __defineHiddenWritable(facts, '__varPredPO', new Map());
6766
- __defineHiddenWritable(facts, '__varPredNonFastS', []);
6767
- __defineHiddenWritable(facts, '__varPredNonFastO', []);
6749
+ for (const name of FACT_INDEX_MAP_FIELDS) __defineHiddenWritable(facts, name, new Map());
6750
+ for (const name of FACT_INDEX_ARRAY_FIELDS) __defineHiddenWritable(facts, name, []);
6768
6751
  __defineHiddenWritable(facts, '__keySet', new Set());
6769
6752
  __defineHiddenWritable(facts, '__keySetComplete', false);
6770
6753
 
@@ -6794,16 +6777,9 @@ function cloneFactIndexesForSnapshot(src, dest) {
6794
6777
  return out;
6795
6778
  }
6796
6779
 
6797
- __defineHiddenWritable(dest, '__byPred', cloneArrayMap(src.__byPred));
6798
- __defineHiddenWritable(dest, '__byPS', cloneNestedArrayMap(src.__byPS));
6799
- __defineHiddenWritable(dest, '__byPO', cloneNestedArrayMap(src.__byPO));
6800
- __defineHiddenWritable(dest, '__byPNonFastS', cloneArrayMap(src.__byPNonFastS));
6801
- __defineHiddenWritable(dest, '__byPNonFastO', cloneArrayMap(src.__byPNonFastO));
6802
- __defineHiddenWritable(dest, '__varPred', src.__varPred.slice());
6803
- __defineHiddenWritable(dest, '__varPredPS', cloneArrayMap(src.__varPredPS));
6804
- __defineHiddenWritable(dest, '__varPredPO', cloneArrayMap(src.__varPredPO));
6805
- __defineHiddenWritable(dest, '__varPredNonFastS', src.__varPredNonFastS.slice());
6806
- __defineHiddenWritable(dest, '__varPredNonFastO', src.__varPredNonFastO.slice());
6780
+ for (const name of FACT_INDEX_ARRAY_MAP_FIELDS) __defineHiddenWritable(dest, name, cloneArrayMap(src[name]));
6781
+ for (const name of FACT_INDEX_NESTED_ARRAY_MAP_FIELDS) __defineHiddenWritable(dest, name, cloneNestedArrayMap(src[name]));
6782
+ for (const name of FACT_INDEX_ARRAY_FIELDS) __defineHiddenWritable(dest, name, src[name].slice());
6807
6783
  __defineHiddenWritable(dest, '__keySet', new Set(src.__keySet));
6808
6784
  __defineHiddenWritable(dest, '__keySetComplete', !!src.__keySetComplete);
6809
6785
  }
@@ -7082,18 +7058,6 @@ function mergeSinglePremiseAgendaBuckets(...buckets) {
7082
7058
  return out;
7083
7059
  }
7084
7060
 
7085
- function termContainsVar(t) {
7086
- if (t instanceof Var) return true;
7087
- if (t instanceof ListTerm) return t.elems.some(termContainsVar);
7088
- if (t instanceof OpenListTerm) return true;
7089
- if (t instanceof GraphTerm)
7090
- return t.triples.some(
7091
- (tr) =>
7092
- termContainsVar(tr.s) || termContainsVar(tr.p) || termContainsVar(tr.o),
7093
- );
7094
- return false;
7095
- }
7096
-
7097
7061
  function makeSinglePremiseAgendaIndex(forwardRules, backRules) {
7098
7062
  const index = {
7099
7063
  byPred: new Map(),
@@ -7157,7 +7121,7 @@ function getSinglePremiseAgendaCandidates(index, fact) {
7157
7121
  let exact = null;
7158
7122
  if (fact.p instanceof Iri) {
7159
7123
  const pk = fact.p.__tid;
7160
- if ((sk === null && termContainsVar(fact.s)) || (ok === null && termContainsVar(fact.o))) {
7124
+ if ((sk === null && containsVarTerm(fact.s)) || (ok === null && containsVarTerm(fact.o))) {
7161
7125
  // A fact with a variable-bearing subject/object (most importantly a
7162
7126
  // top-level variable fact such as `?S :p ?O.`) can match rules whose
7163
7127
  // premise is fixed in that position. The ordinary `(p,s)` / `(p,o)` lookup
@@ -7202,11 +7166,11 @@ function getSinglePremiseAgendaCandidates(index, fact) {
7202
7166
  // ===========================================================================
7203
7167
 
7204
7168
  function isLogImplies(p) {
7205
- return p instanceof Iri && p.value === LOG_NS + 'implies';
7169
+ return p instanceof Iri && p.value === LOG_IMPLIES_IRI;
7206
7170
  }
7207
7171
 
7208
7172
  function isLogImpliedBy(p) {
7209
- return p instanceof Iri && p.value === LOG_NS + 'impliedBy';
7173
+ return p instanceof Iri && p.value === LOG_IMPLIED_BY_IRI;
7210
7174
  }
7211
7175
 
7212
7176
  // ===========================================================================
@@ -7239,16 +7203,7 @@ function __makeGoalTable() {
7239
7203
 
7240
7204
  function __attachGoalTable(scopeCarrier, goalTable) {
7241
7205
  if (!scopeCarrier) return goalTable;
7242
- if (!hasOwn.call(scopeCarrier, 'goalTable')) {
7243
- Object.defineProperty(scopeCarrier, 'goalTable', {
7244
- value: goalTable,
7245
- enumerable: false,
7246
- writable: true,
7247
- configurable: true,
7248
- });
7249
- } else {
7250
- scopeCarrier.goalTable = goalTable;
7251
- }
7206
+ __setHiddenWritable(scopeCarrier, 'goalTable', goalTable);
7252
7207
  return goalTable;
7253
7208
  }
7254
7209
 
@@ -7303,11 +7258,10 @@ function __canStoreGoalMemo(visited, maxResults) {
7303
7258
  // Unification + substitution
7304
7259
  // ===========================================================================
7305
7260
 
7306
- function containsVarTerm(t, v) {
7307
- if (t instanceof Iri || t instanceof Literal || t instanceof Blank) return false;
7308
- if (t instanceof Var) return t.name === v;
7261
+ function containsVarTerm(t, v = null) {
7262
+ if (t instanceof Var) return v === null || t.name === v;
7309
7263
  if (t instanceof ListTerm) return t.elems.some((e) => containsVarTerm(e, v));
7310
- if (t instanceof OpenListTerm) return t.prefix.some((e) => containsVarTerm(e, v)) || t.tailVar === v;
7264
+ if (t instanceof OpenListTerm) return t.prefix.some((e) => containsVarTerm(e, v)) || v === null || t.tailVar === v;
7311
7265
  if (t instanceof GraphTerm)
7312
7266
  return t.triples.some((tr) => containsVarTerm(tr.s, v) || containsVarTerm(tr.p, v) || containsVarTerm(tr.o, v));
7313
7267
  return false;
@@ -7513,7 +7467,7 @@ function unifyOpenWithList(prefix, tailv, ys, subst) {
7513
7467
 
7514
7468
  function graphTriplesContainVars(triples) {
7515
7469
  for (const tr of triples) {
7516
- if (termContainsVar(tr.s) || termContainsVar(tr.p) || termContainsVar(tr.o)) return true;
7470
+ if (containsVarTerm(tr.s) || containsVarTerm(tr.p) || containsVarTerm(tr.o)) return true;
7517
7471
  }
7518
7472
  return false;
7519
7473
  }
@@ -7798,19 +7752,7 @@ function __tripleHasVarOrBlank(tr) {
7798
7752
  }
7799
7753
 
7800
7754
  function __builtinIsSatisfiableWhenFullyUnbound(pIriVal) {
7801
- return (
7802
- pIriVal === MATH_NS + 'sin' ||
7803
- pIriVal === MATH_NS + 'cos' ||
7804
- pIriVal === MATH_NS + 'tan' ||
7805
- pIriVal === MATH_NS + 'asin' ||
7806
- pIriVal === MATH_NS + 'acos' ||
7807
- pIriVal === MATH_NS + 'atan' ||
7808
- pIriVal === MATH_NS + 'sinh' ||
7809
- pIriVal === MATH_NS + 'cosh' ||
7810
- pIriVal === MATH_NS + 'tanh' ||
7811
- pIriVal === MATH_NS + 'degrees' ||
7812
- pIriVal === MATH_NS + 'negation'
7813
- );
7755
+ return MATH_BUILTINS_SATISFIABLE_WHEN_FULLY_UNBOUND.has(pIriVal);
7814
7756
  }
7815
7757
 
7816
7758
  function proveGoals(goals, subst, facts, backRules, depth, visited, varGen, maxResults, opts) {
@@ -8445,12 +8387,7 @@ function __proofTripleKey(tr) {
8445
8387
 
8446
8388
  function __copyProofSource(from, to) {
8447
8389
  if (from && to && Object.prototype.hasOwnProperty.call(from, '__source')) {
8448
- Object.defineProperty(to, '__source', {
8449
- value: from.__source,
8450
- enumerable: false,
8451
- writable: false,
8452
- configurable: true,
8453
- });
8390
+ __defineHiddenValue(to, '__source', from.__source);
8454
8391
  }
8455
8392
  return to;
8456
8393
  }
@@ -8462,12 +8399,7 @@ function __annotateProofVarSourceNames(rule) {
8462
8399
  const m = /^(.*)__\d+$/.exec(name);
8463
8400
  sourceNames[name] = m ? m[1] : name;
8464
8401
  }
8465
- Object.defineProperty(rule, '__proofVarSourceNames', {
8466
- value: sourceNames,
8467
- enumerable: false,
8468
- writable: false,
8469
- configurable: true,
8470
- });
8402
+ __defineHiddenValue(rule, '__proofVarSourceNames', sourceNames);
8471
8403
  return rule;
8472
8404
  }
8473
8405
 
@@ -8673,45 +8605,16 @@ function forwardChain(facts, forwardRules, backRules, onDerived /* optional */,
8673
8605
  // until a scoped snapshot exists (or a given closure level is reached).
8674
8606
  // Helper functions are module-scoped: __computeForwardRuleScopedSkipInfo, etc.
8675
8607
  function setScopedSnapshot(snap, level) {
8676
- if (!hasOwn.call(facts, '__scopedSnapshot')) {
8677
- Object.defineProperty(facts, '__scopedSnapshot', {
8678
- value: snap,
8679
- enumerable: false,
8680
- writable: true,
8681
- configurable: true,
8682
- });
8683
- } else {
8684
- facts.__scopedSnapshot = snap;
8685
- }
8686
-
8687
- if (!hasOwn.call(facts, '__scopedClosureLevel')) {
8688
- Object.defineProperty(facts, '__scopedClosureLevel', {
8689
- value: level,
8690
- enumerable: false,
8691
- writable: true,
8692
- configurable: true,
8693
- });
8694
- } else {
8695
- facts.__scopedClosureLevel = level;
8696
- }
8608
+ __setHiddenWritable(facts, '__scopedSnapshot', snap);
8609
+ __setHiddenWritable(facts, '__scopedClosureLevel', level);
8697
8610
  }
8698
8611
 
8699
8612
  function makeScopedSnapshot() {
8700
8613
  const snap = facts.slice();
8701
8614
  cloneFactIndexesForSnapshot(facts, snap);
8702
- Object.defineProperty(snap, '__scopedSnapshot', {
8703
- value: snap,
8704
- enumerable: false,
8705
- writable: true,
8706
- configurable: true,
8707
- });
8615
+ __defineHiddenWritable(snap, '__scopedSnapshot', snap);
8708
8616
  // Propagate closure level so nested scoped builtins can see it.
8709
- Object.defineProperty(snap, '__scopedClosureLevel', {
8710
- value: scopedClosureLevel,
8711
- enumerable: false,
8712
- writable: true,
8713
- configurable: true,
8714
- });
8617
+ __defineHiddenWritable(snap, '__scopedClosureLevel', scopedClosureLevel);
8715
8618
  return snap;
8716
8619
  }
8717
8620
 
@@ -9059,36 +8962,12 @@ function __withScopedSnapshotForQueries(facts, fn) {
9059
8962
  // Create a frozen snapshot of the saturated closure.
9060
8963
  const snap = facts.slice();
9061
8964
  ensureFactIndexes(snap);
9062
- Object.defineProperty(snap, '__scopedSnapshot', {
9063
- value: snap,
9064
- enumerable: false,
9065
- writable: true,
9066
- configurable: true,
9067
- });
9068
- Object.defineProperty(snap, '__scopedClosureLevel', {
9069
- value: Number.MAX_SAFE_INTEGER,
9070
- enumerable: false,
9071
- writable: true,
9072
- configurable: true,
9073
- });
8965
+ __defineHiddenWritable(snap, '__scopedSnapshot', snap);
8966
+ __defineHiddenWritable(snap, '__scopedClosureLevel', Number.MAX_SAFE_INTEGER);
9074
8967
 
9075
8968
  // Ensure the live facts array exposes the snapshot/level for builtins.
9076
- if (!hasOwn.call(facts, '__scopedSnapshot')) {
9077
- Object.defineProperty(facts, '__scopedSnapshot', {
9078
- value: null,
9079
- enumerable: false,
9080
- writable: true,
9081
- configurable: true,
9082
- });
9083
- }
9084
- if (!hasOwn.call(facts, '__scopedClosureLevel')) {
9085
- Object.defineProperty(facts, '__scopedClosureLevel', {
9086
- value: 0,
9087
- enumerable: false,
9088
- writable: true,
9089
- configurable: true,
9090
- });
9091
- }
8969
+ __setHiddenWritable(facts, '__scopedSnapshot', null);
8970
+ __setHiddenWritable(facts, '__scopedClosureLevel', 0);
9092
8971
 
9093
8972
  facts.__scopedSnapshot = snap;
9094
8973
  facts.__scopedClosureLevel = Number.MAX_SAFE_INTEGER;