Skip to content

Commit 7eaf8d7

Browse files
author
bgagent
committed
refactor(event-governance): author rule packs under agent/event-rules
Move the event-rules asset tree (schema, packs, parity fixtures) from contracts/ to agent/event-rules/, alongside agent/workflows/ — one asset tree, one authoring UX, and the natural source for the future RegistryService (#246). The agent runtime never loads these files (it receives resolved event_rules on the TaskRecord), so only the three file consumers move: the CDK pack resolver (bundle-time import), the CLI --fixture loader, and the Python + TS parity/evaluator tests. Dual-plane parity is unchanged — the CDK-resolved rules remain the single source both planes consume. Repoints resolver import, CLI fixture path, four test fixture paths, blueprint schema comment, and EVENT_GOVERNANCE.md (+ Starlight mirror).
1 parent 3143ebb commit 7eaf8d7

18 files changed

Lines changed: 50 additions & 38 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Golden-file vectors shared by:
55
- `agent/tests/test_event_rules_parity.py` (Python evaluator)
66
- `cdk/test/handlers/shared/event-rules-parity.test.ts` (TypeScript evaluator)
77

8-
Fixtures live under `contracts/event-rules/fixtures/` and are referenced by
8+
Fixtures live under `agent/event-rules/fixtures/` and are referenced by
99
basename from this parity contract.
1010

1111
Design reference: `docs/design/EVENT_GOVERNANCE.md` (issue #230).

agent/event-rules/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Event governance rules
2+
3+
Event rule packs, schema, and cross-language parity fixtures for event-driven
4+
governance (issue #230). Authored here alongside `agent/workflows/` — one asset
5+
tree, one authoring UX. The related event-catalog and policy-decision schemas
6+
stay under the repo-root `contracts/` tree.
7+
8+
## Layout
9+
10+
| Path | Purpose |
11+
|------|---------|
12+
| `schema.json` | JSON Schema for event rule packs |
13+
| `packs/*.json` | Versioned rule packs pinned by `Blueprint.security.eventRulePack` |
14+
| `fixtures/` | Golden fixtures for Python + TypeScript evaluator parity |
15+
16+
## Consumers
17+
18+
| Caller | Path | Reads |
19+
|--------|------|-------|
20+
| `cdk/src/handlers/shared/event-rule-pack-resolver.ts` | Bundles `packs/*.json` at build time (future `RegistryService.resolve`) | packs |
21+
| `cdk/test/.../event-rule-evaluator.test.ts`, `event-rules-parity.test.ts` | TypeScript evaluator + parity | fixtures |
22+
| `agent/tests/test_event_rules_parity.py`, `test_event_governance_evaluator.py` | Python evaluator + parity | fixtures |
23+
| `cli/src/commands/rules.ts` | `bgagent rules eval --fixture` | fixtures |
24+
25+
The agent runtime does **not** read these files: it receives already-resolved
26+
`event_rules` frozen on the TaskRecord at submit time, so both evaluation planes
27+
consume one source (the CDK-resolved rules).
28+
29+
Design reference: [EVENT_GOVERNANCE.md](../../docs/design/EVENT_GOVERNANCE.md).

contracts/event-rules/fixtures/aggregate-cost-cancel.json renamed to agent/event-rules/fixtures/aggregate-cost-cancel.json

File renamed without changes.

contracts/event-rules/fixtures/aggregate-turn-count-escalate.json renamed to agent/event-rules/fixtures/aggregate-turn-count-escalate.json

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "https://abca.dev/contracts/event-rules/schema.json",
3+
"$id": "https://abca.dev/agent/event-rules/schema.json",
44
"title": "EventRulePack",
55
"type": "object",
66
"required": ["rules"],

agent/tests/test_event_governance_evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from event_governance.evaluator import match_rules, parse_rules
99

10-
FIXTURES = Path(__file__).resolve().parents[2] / "contracts" / "event-rules" / "fixtures"
10+
FIXTURES = Path(__file__).resolve().parents[1] / "event-rules" / "fixtures"
1111

1212

1313
def _load_fixture(name: str) -> dict:

agent/tests/test_event_rules_parity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from event_governance.evaluator import match_rules, parse_rules
1111

12-
FIXTURES = Path(__file__).resolve().parents[2] / "contracts" / "event-rules" / "fixtures"
12+
FIXTURES = Path(__file__).resolve().parents[1] / "event-rules" / "fixtures"
1313

1414

1515
def _fixture_paths() -> list[Path]:

0 commit comments

Comments
 (0)