Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
pull_request:
push:
branches: [main, master]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install dependencies
run: npm ci

- name: Install Grunt CLI
run: npm install -g grunt-cli

- name: JSHint
run: grunt jshint

- name: Tests
run: npm test
2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
node = "22.22.1"
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

11 changes: 10 additions & 1 deletion lib/nodes/betaNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,29 @@ Node.extend({
}
},

dispose: function () {
// visited: skip shared betas; propagateDispose: downstream joins get dispose + Memory#clear.
dispose: function (assertable, visited) {
visited = visited || {};
if (visited[this.__count]) {
return;
}
visited[this.__count] = true;
this.leftMemory = {};
this.rightMemory = {};
this.leftTuples.clear();
this.rightTuples.clear();
this.propagateDispose(assertable, undefined, visited);
},

disposeLeft: function (fact) {
// Fact-scoped retract path: clear left side only, then notify downstream.
this.leftMemory = {};
this.leftTuples.clear();
this.propagateDispose(fact);
},

disposeRight: function (fact) {
// Mirror of disposeLeft for right-input retractions.
this.rightMemory = {};
this.rightTuples.clear();
this.propagateDispose(fact);
Expand Down
6 changes: 6 additions & 0 deletions lib/nodes/fromNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ JoinNode.extend({
this.__variables = vars;
},

// Drop from-derived fact index; super clears join tuples and walks out-edges.
dispose: function () {
this.fromMemory = {};
this._super(arguments);
},

__createMatches: function (context) {
var fh = context.factHash, o = this.from(fh);
if (isArray(o)) {
Expand Down
6 changes: 6 additions & 0 deletions lib/nodes/fromNotNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ JoinNode.extend({

},

// Same as FromNode: fromMemory is outside BetaNode hash/tuples.
dispose: function () {
this.fromMemory = {};
this._super(arguments);
},

retractLeft: function (context) {
var ctx = this.removeFromLeftMemory(context);
if (ctx) {
Expand Down
4 changes: 3 additions & 1 deletion lib/nodes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ declare({
});
},

// One visited map for the whole dispose walk (cycles / sharing).
dispose: function () {
var visited = {};
var typeNodes = this.typeNodes, i = typeNodes.length - 1;
for (; i >= 0; i--) {
typeNodes[i].dispose();
typeNodes[i].dispose(visited);
}
},

Expand Down
4 changes: 0 additions & 4 deletions lib/nodes/leftAdapterNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ Node.extend({
this.__propagate("retractResolve", match);
},

dispose: function (context) {
this.propagateDispose(context);
},

toString: function () {
return "LeftAdapterNode " + this.__count;
}
Expand Down
15 changes: 11 additions & 4 deletions lib/nodes/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,27 @@ declare({
}
},

dispose: function (assertable) {
this.propagateDispose(assertable);
// Pass `visited` through from RootNode.dispose.
dispose: function (assertable, visited) {
visited = visited || {};
if (visited[this.__count]) {
return;
}
visited[this.__count] = true;
this.propagateDispose(assertable, undefined, visited);
},

retract: function (assertable) {
this.propagateRetract(assertable);
},

propagateDispose: function (assertable, outNodes) {
propagateDispose: function (assertable, outNodes, visited) {
visited = visited || {};
outNodes = outNodes || this.nodes;
var entrySet = this.__entrySet, i = entrySet.length - 1;
for (; i >= 0; i--) {
var entry = entrySet[i], outNode = entry.key;
outNode.dispose(assertable);
outNode.dispose(assertable, visited);
}
},

Expand Down
6 changes: 6 additions & 0 deletions lib/nodes/notNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ JoinNode.extend({
this.notMatch = new Context(new InitialFact()).match;
},

// BetaNode.dispose does not reset blocked-tuple map; clear before super chain.
dispose: function () {
this.leftTupleMemory = {};
this._super(arguments);
},

__cloneContext: function (context) {
return context.clone(null, null, context.match.merge(this.notMatch));
},
Expand Down
4 changes: 0 additions & 4 deletions lib/nodes/rightAdapterNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ Node.extend({
this.__propagate("retractResolve", match);
},

dispose: function (context) {
this.propagateDispose(context);
},

propagateAssert: function (context) {
this.__propagate("assertRight", context);
},
Expand Down
10 changes: 8 additions & 2 deletions lib/nodes/typeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ AlphaNode.extend({
return "TypeNode" + this.__count;
},

dispose: function () {
// Root passes visited; optional otherwise.
dispose: function (visited) {
visited = visited || {};
if (visited[this.__count]) {
return;
}
visited[this.__count] = true;
var es = this.__entrySet, i = es.length - 1;
for (; i >= 0; i--) {
var e = es[i], outNode = e.key, paths = e.value;
outNode.dispose({paths: paths});
outNode.dispose({paths: paths}, visited);
}
},

Expand Down
13 changes: 13 additions & 0 deletions mise.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading