feat(coding-agent): added AST-condition matching for interrupt flow rule handling
- Added astCondition to rule frontmatter parsing and rule metadata, with AST-grep normalization. - Updated TTSR bucketing so astCondition-only rules are treated as interruptible matches. - Added ts-redundant-clear-guard as a built-in JS/TS tool rule for guarded clear* calls. - Added AST snapshot matching in agent sessions with per-stream cache throttling and cleanup.
This commit is contained in:
@@ -16,6 +16,7 @@ function makeRule(partial: Partial<Rule>): Rule {
|
||||
alwaysApply: partial.alwaysApply,
|
||||
description: partial.description,
|
||||
condition: partial.condition,
|
||||
astCondition: partial.astCondition,
|
||||
scope: partial.scope,
|
||||
interruptMode: partial.interruptMode,
|
||||
_source: partial._source ?? source("native"),
|
||||
@@ -34,6 +35,18 @@ describe("bucketRules", () => {
|
||||
expect(mgr.checkDelta("contains FORBIDDEN token", { source: "text" }).map(r => r.name)).toEqual(["no-foo"]);
|
||||
});
|
||||
|
||||
it("registers an ast-only rule as TTSR and excludes it from rulebook/always buckets", () => {
|
||||
const mgr = new TtsrManager();
|
||||
const ttsr = makeRule({ name: "no-console", astCondition: ["console.log($A)"], description: "blocks console" });
|
||||
|
||||
const { rulebookRules, alwaysApplyRules } = bucketRules([ttsr], mgr);
|
||||
|
||||
expect(rulebookRules).toHaveLength(0);
|
||||
expect(alwaysApplyRules).toHaveLength(0);
|
||||
expect(mgr.hasRules()).toBe(true);
|
||||
expect(mgr.hasAstRules()).toBe(true);
|
||||
});
|
||||
|
||||
it("splits non-TTSR rules into always-apply and rulebook by metadata", () => {
|
||||
const mgr = new TtsrManager();
|
||||
const sticky = makeRule({ name: "sticky", alwaysApply: true, description: "sticky desc" });
|
||||
|
||||
Reference in New Issue
Block a user