@gobing-ai/ts-rule-engine 0.4.7 → 0.4.9
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/dist/engine.d.ts +9 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +4 -2
- package/dist/evaluators/exit-code-evaluator.d.ts.map +1 -1
- package/dist/evaluators/exit-code-evaluator.js +2 -2
- package/dist/evaluators/ripgrep-evaluator.d.ts.map +1 -1
- package/dist/evaluators/ripgrep-evaluator.js +2 -2
- package/dist/evaluators/sg-evaluator.d.ts.map +1 -1
- package/dist/evaluators/sg-evaluator.js +2 -2
- package/package.json +5 -5
- package/src/engine.ts +12 -3
- package/src/evaluators/exit-code-evaluator.ts +2 -2
- package/src/evaluators/ripgrep-evaluator.ts +2 -2
- package/src/evaluators/sg-evaluator.ts +2 -2
package/dist/engine.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BusLifecycleEvents, Logger } from '@gobing-ai/ts-infra';
|
|
2
|
+
import { EventBus } from '@gobing-ai/ts-infra';
|
|
2
3
|
import { type FileSystem, type ProcessExecutor } from '@gobing-ai/ts-runtime';
|
|
3
4
|
import type { RuleEngineEvents } from './events';
|
|
4
5
|
import { type FixApplicationResult } from './fixers/fixers';
|
|
@@ -19,6 +20,13 @@ export interface RuleEngineOptions {
|
|
|
19
20
|
host?: RuleEngineHost;
|
|
20
21
|
/** Optional event bus for structured run observability (R-A4). */
|
|
21
22
|
events?: EventBus<RuleEngineEvents>;
|
|
23
|
+
/**
|
|
24
|
+
* Optional lifecycle bus to bridge rule events into the application
|
|
25
|
+
* System Events stream (R2). When `events` is omitted the engine
|
|
26
|
+
* constructs an internal `EventBus<RuleEngineEvents>` parented to this
|
|
27
|
+
* bus so `rule.*` prefixes appear in the JSONL log.
|
|
28
|
+
*/
|
|
29
|
+
lifecycleBus?: EventBus<BusLifecycleEvents>;
|
|
22
30
|
/** Optional logger; defaults to the shared `rule-engine` category logger. */
|
|
23
31
|
logger?: Logger;
|
|
24
32
|
/** Optional persistence adapter for durable run/eval history. */
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAgB,QAAQ,EAAyB,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAwB,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAIH,KAAK,oBAAoB,EAE5B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAqB,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGhH,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAC9B,+DAA+D;IAC/D,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,mCAAmC;IACnC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,kEAAkE;IAClE,MAAM,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACpC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC5C,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MA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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addSpanEvent, getLogger, traceAsync } from '@gobing-ai/ts-infra';
|
|
1
|
+
import { addSpanEvent, EventBus, getLogger, traceAsync } from '@gobing-ai/ts-infra';
|
|
2
2
|
import { createNodeFileSystem } from '@gobing-ai/ts-runtime';
|
|
3
3
|
import { applyFixes as applyFixesImpl, FIX_MODE_RANK, registerBuiltinFixers, } from './fixers/fixers.js';
|
|
4
4
|
import { registerBuiltins } from './host/builtins.js';
|
|
@@ -18,7 +18,9 @@ export class RuleEngine {
|
|
|
18
18
|
this.host = options.host ?? new RuleEngineHost();
|
|
19
19
|
registerBuiltins(this.host, options.processExecutor);
|
|
20
20
|
registerBuiltinFixers(this.host, options.processExecutor);
|
|
21
|
-
this.events =
|
|
21
|
+
this.events =
|
|
22
|
+
options.events ??
|
|
23
|
+
(options.lifecycleBus ? new EventBus({ lifecycleBus: options.lifecycleBus }) : undefined);
|
|
22
24
|
this.logger = options.logger ?? getLogger('rule-engine');
|
|
23
25
|
this.persistence = options.persistence;
|
|
24
26
|
this.runId = options.runId ?? crypto.randomUUID();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-code-evaluator.d.ts","sourceRoot":"","sources":["../../src/evaluators/exit-code-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"exit-code-evaluator.d.ts","sourceRoot":"","sources":["../../src/evaluators/exit-code-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EACH,KAAK,cAAc,EAEnB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACrB,MAAM,UAAU,CAAC;AAGlB,2EAA2E;AAC3E,qBAAa,iBAAkB,YAAW,aAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,GAAE,eAAwD;IAE/F,4FAA4F;IACtF,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;CA2B5F"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeBunFactory } from '@gobing-ai/ts-runtime';
|
|
2
2
|
import { createFinding, } from '../types.js';
|
|
3
3
|
import { configArray, configNumber, configString } from './file-utils.js';
|
|
4
4
|
/** Evaluates a rule by running a subprocess and checking its exit code. */
|
|
5
5
|
export class ExitCodeEvaluator {
|
|
6
6
|
executor;
|
|
7
|
-
constructor(executor =
|
|
7
|
+
constructor(executor = nodeBunFactory.createProcessExecutor()) {
|
|
8
8
|
this.executor = executor;
|
|
9
9
|
}
|
|
10
10
|
/** Run configured command and emit a finding unless the exit code matches `successCode`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ripgrep-evaluator.d.ts","sourceRoot":"","sources":["../../src/evaluators/ripgrep-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ripgrep-evaluator.d.ts","sourceRoot":"","sources":["../../src/evaluators/ripgrep-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EACH,KAAK,cAAc,EAEnB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACrB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IAClD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;gBAE/B,QAAQ,GAAE,eAAwD;IAI9E,oFAAoF;IAC9E,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;CA8B5F;AAmFD;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACtC,OAAO,EAAE,MAAM,GAChB;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,UAAU,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAK/D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeBunFactory } from '@gobing-ai/ts-runtime';
|
|
2
2
|
import { createFinding, } from '../types.js';
|
|
3
3
|
import { configString, DEFAULT_EXCLUDES } from './file-utils.js';
|
|
4
4
|
/**
|
|
@@ -26,7 +26,7 @@ import { configString, DEFAULT_EXCLUDES } from './file-utils.js';
|
|
|
26
26
|
*/
|
|
27
27
|
export class RipgrepEvaluator {
|
|
28
28
|
executor;
|
|
29
|
-
constructor(executor =
|
|
29
|
+
constructor(executor = nodeBunFactory.createProcessExecutor()) {
|
|
30
30
|
this.executor = executor;
|
|
31
31
|
}
|
|
32
32
|
/** Run ripgrep and emit findings for matches (forbid) or absent files (require). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sg-evaluator.d.ts","sourceRoot":"","sources":["../../src/evaluators/sg-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sg-evaluator.d.ts","sourceRoot":"","sources":["../../src/evaluators/sg-evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EACH,KAAK,cAAc,EAEnB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACrB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,WAAY,YAAW,aAAa;IAC7C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;gBAE/B,QAAQ,GAAE,eAAwD;IAI9E,wDAAwD;IAClD,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAyD5F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeBunFactory } from '@gobing-ai/ts-runtime';
|
|
2
2
|
import { createFinding, } from '../types.js';
|
|
3
3
|
import { DEFAULT_EXCLUDES, matchesGlob } from './file-utils.js';
|
|
4
4
|
/**
|
|
@@ -21,7 +21,7 @@ import { DEFAULT_EXCLUDES, matchesGlob } from './file-utils.js';
|
|
|
21
21
|
*/
|
|
22
22
|
export class SgEvaluator {
|
|
23
23
|
executor;
|
|
24
|
-
constructor(executor =
|
|
24
|
+
constructor(executor = nodeBunFactory.createProcessExecutor()) {
|
|
25
25
|
this.executor = executor;
|
|
26
26
|
}
|
|
27
27
|
/** Run sg and emit one finding per matched AST node. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-rule-engine",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "@gobing-ai/ts-rule-engine — Constraint rule schemas, loading, evaluation, and result formatting.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-rule-engine-v<version> && git push --tags' && exit 1"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@gobing-ai/ts-ai-runner": "^0.4.
|
|
53
|
-
"@gobing-ai/ts-infra": "^0.4.
|
|
54
|
-
"@gobing-ai/ts-runtime": "^0.4.
|
|
55
|
-
"@gobing-ai/ts-db": "^0.4.
|
|
52
|
+
"@gobing-ai/ts-ai-runner": "^0.4.9",
|
|
53
|
+
"@gobing-ai/ts-infra": "^0.4.9",
|
|
54
|
+
"@gobing-ai/ts-runtime": "^0.4.9",
|
|
55
|
+
"@gobing-ai/ts-db": "^0.4.9",
|
|
56
56
|
"yaml": "^2.7.0",
|
|
57
57
|
"zod": "^4.1.0"
|
|
58
58
|
},
|
package/src/engine.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { addSpanEvent, getLogger, traceAsync } from '@gobing-ai/ts-infra';
|
|
1
|
+
import type { BusLifecycleEvents, Logger } from '@gobing-ai/ts-infra';
|
|
2
|
+
import { addSpanEvent, EventBus, getLogger, traceAsync } from '@gobing-ai/ts-infra';
|
|
3
3
|
import { createNodeFileSystem, type FileSystem, type ProcessExecutor } from '@gobing-ai/ts-runtime';
|
|
4
4
|
import type { RuleEngineEvents } from './events';
|
|
5
5
|
import {
|
|
@@ -29,6 +29,13 @@ export interface RuleEngineOptions {
|
|
|
29
29
|
host?: RuleEngineHost;
|
|
30
30
|
/** Optional event bus for structured run observability (R-A4). */
|
|
31
31
|
events?: EventBus<RuleEngineEvents>;
|
|
32
|
+
/**
|
|
33
|
+
* Optional lifecycle bus to bridge rule events into the application
|
|
34
|
+
* System Events stream (R2). When `events` is omitted the engine
|
|
35
|
+
* constructs an internal `EventBus<RuleEngineEvents>` parented to this
|
|
36
|
+
* bus so `rule.*` prefixes appear in the JSONL log.
|
|
37
|
+
*/
|
|
38
|
+
lifecycleBus?: EventBus<BusLifecycleEvents>;
|
|
32
39
|
/** Optional logger; defaults to the shared `rule-engine` category logger. */
|
|
33
40
|
logger?: Logger;
|
|
34
41
|
/** Optional persistence adapter for durable run/eval history. */
|
|
@@ -55,7 +62,9 @@ export class RuleEngine {
|
|
|
55
62
|
this.host = options.host ?? new RuleEngineHost();
|
|
56
63
|
registerBuiltins(this.host, options.processExecutor);
|
|
57
64
|
registerBuiltinFixers(this.host, options.processExecutor);
|
|
58
|
-
this.events =
|
|
65
|
+
this.events =
|
|
66
|
+
options.events ??
|
|
67
|
+
(options.lifecycleBus ? new EventBus<RuleEngineEvents>({ lifecycleBus: options.lifecycleBus }) : undefined);
|
|
59
68
|
this.logger = options.logger ?? getLogger('rule-engine');
|
|
60
69
|
this.persistence = options.persistence;
|
|
61
70
|
this.runId = options.runId ?? crypto.randomUUID();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeBunFactory, type ProcessExecutor } from '@gobing-ai/ts-runtime';
|
|
2
2
|
import {
|
|
3
3
|
type ConstraintRule,
|
|
4
4
|
createFinding,
|
|
@@ -10,7 +10,7 @@ import { configArray, configNumber, configString } from './file-utils';
|
|
|
10
10
|
|
|
11
11
|
/** Evaluates a rule by running a subprocess and checking its exit code. */
|
|
12
12
|
export class ExitCodeEvaluator implements RuleEvaluator {
|
|
13
|
-
constructor(private readonly executor: ProcessExecutor =
|
|
13
|
+
constructor(private readonly executor: ProcessExecutor = nodeBunFactory.createProcessExecutor()) {}
|
|
14
14
|
|
|
15
15
|
/** Run configured command and emit a finding unless the exit code matches `successCode`. */
|
|
16
16
|
async evaluate(rule: ConstraintRule, context: RuleContext): Promise<RuleEvaluationResult> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeBunFactory, type ProcessExecutor } from '@gobing-ai/ts-runtime';
|
|
2
2
|
import {
|
|
3
3
|
type ConstraintRule,
|
|
4
4
|
createFinding,
|
|
@@ -34,7 +34,7 @@ import { configString, DEFAULT_EXCLUDES } from './file-utils';
|
|
|
34
34
|
export class RipgrepEvaluator implements RuleEvaluator {
|
|
35
35
|
private readonly executor: ProcessExecutor;
|
|
36
36
|
|
|
37
|
-
constructor(executor: ProcessExecutor =
|
|
37
|
+
constructor(executor: ProcessExecutor = nodeBunFactory.createProcessExecutor()) {
|
|
38
38
|
this.executor = executor;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeBunFactory, type ProcessExecutor } from '@gobing-ai/ts-runtime';
|
|
2
2
|
import {
|
|
3
3
|
type ConstraintRule,
|
|
4
4
|
createFinding,
|
|
@@ -29,7 +29,7 @@ import { DEFAULT_EXCLUDES, matchesGlob } from './file-utils';
|
|
|
29
29
|
export class SgEvaluator implements RuleEvaluator {
|
|
30
30
|
private readonly executor: ProcessExecutor;
|
|
31
31
|
|
|
32
|
-
constructor(executor: ProcessExecutor =
|
|
32
|
+
constructor(executor: ProcessExecutor = nodeBunFactory.createProcessExecutor()) {
|
|
33
33
|
this.executor = executor;
|
|
34
34
|
}
|
|
35
35
|
|