feat(rules): rule_group/rule_atom (0033), /rules endpoints, evaluation via referenced rule groups
- migration 0033: rule_group (layers, hard excludes, scope, source, revision,
fingerprint, default_order) and rule_atom; acquisition_slot.rule_group_ids;
preference tags migrated into rule groups (same id/fingerprint), suppressions
linked; seeded default groups for acquisition / upgrade / search
- contracts: RuleGroup/RuleAtom/RuleExpr/RuleDefaults, parse/serialize/preview
schemas; Api.rules, Api.ruleAtoms, Api.rulePolicies, Api.ruleSuppressions
- server: GET/POST/PATCH/DELETE /rules, /rules/{id}/revisions, /rules/{id}/preview,
/rules/parse, /rules/serialize, /rules/keywords, /rules/defaults, /rules/atoms;
disable/delete writes suppression, agent re-add -> 409
- /preference-tags now aliases rule groups; /policy-revisions and
/preference-suppressions kept as aliases of /rules/policies, /rules/suppressions
- evaluateAcquisition resolves slot -> subscription -> default chain (+ upgrade
defaults) and records pri / rule_group@revision / per-layer trace
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
a0946bf480
commit
0105e5c6ac
11 files changed
+2296
-340
No files matched your search
@@ -206,6 +206,8 @@ export type ResolutionAttemptOutcome =
|
||||
| "manual"
|
||||
| "skipped_locked";
|
||||
export type ResolutionAttemptActorType = "user" | "agent" | "system" | "api_key";
|
||||
export type RuleGroupKind = "acquisition" | "upgrade" | "search";
|
||||
export type RuleGroupSource = "manual" | "chat" | "agent";
|
||||
export type ScheduledJobBoardGroup = "collect" | "download" | "organize" | "maintain" | "agent";
|
||||
export type ScheduledJobKind = "task" | "agent_check";
|
||||
export type ScheduledJobLastStatus = "ok" | "failed" | "skipped" | "running";
|
||||
@@ -289,6 +291,7 @@ export interface AcquisitionSlotTable {
|
||||
created_at: GeneratedTimestamptz;
|
||||
updated_at: GeneratedTimestamptz;
|
||||
reserved_plan_id: string | null;
|
||||
rule_group_ids: Generated<Json>;
|
||||
}
|
||||
|
||||
export interface AdminSessionTable {
|
||||
@@ -1056,6 +1059,7 @@ export interface PreferenceSuppressionTable {
|
||||
lifted_by: string | null;
|
||||
created_at: GeneratedTimestamptz;
|
||||
updated_at: GeneratedTimestamptz;
|
||||
rule_group_id: string | null;
|
||||
}
|
||||
|
||||
export interface PreferenceTagTable {
|
||||
@@ -1108,6 +1112,47 @@ export interface ResolutionAttemptTable {
|
||||
updated_at: GeneratedTimestamptz;
|
||||
}
|
||||
|
||||
export interface RuleAtomTable {
|
||||
id: Generated<string>;
|
||||
key: string;
|
||||
name: string | null;
|
||||
description: string | null;
|
||||
include: Generated<Json>;
|
||||
exclude: Generated<Json>;
|
||||
match_fields: Generated<Json>;
|
||||
unit_size_mb: Json | null;
|
||||
min_seeders: number | null;
|
||||
publish_delay_minutes: Json | null;
|
||||
free: Generated<boolean>;
|
||||
created_at: GeneratedTimestamptz;
|
||||
updated_at: GeneratedTimestamptz;
|
||||
}
|
||||
|
||||
export interface RuleGroupTable {
|
||||
id: Generated<string>;
|
||||
name: string;
|
||||
description: string | null;
|
||||
kind: Generated<RuleGroupKind>;
|
||||
scope: Generated<Json>;
|
||||
layers: Generated<Json>;
|
||||
hard_excludes: Generated<Json>;
|
||||
ladder_required: Generated<boolean>;
|
||||
rule_string: string | null;
|
||||
source: Generated<RuleGroupSource>;
|
||||
enabled: Generated<boolean>;
|
||||
revision: Generated<number>;
|
||||
fingerprint: string;
|
||||
evidence: Generated<Json>;
|
||||
default_order: number | null;
|
||||
auto_fill: boolean | null;
|
||||
legacy_kind: string | null;
|
||||
legacy_rule: Json | null;
|
||||
suppressed_at: Timestamptz | null;
|
||||
deleted_at: Timestamptz | null;
|
||||
created_at: GeneratedTimestamptz;
|
||||
updated_at: GeneratedTimestamptz;
|
||||
}
|
||||
|
||||
export interface ScheduledJobTable {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -1515,6 +1560,8 @@ export interface DB {
|
||||
preference_tag: PreferenceTagTable;
|
||||
reconcile_run: ReconcileRunTable;
|
||||
resolution_attempt: ResolutionAttemptTable;
|
||||
rule_atom: RuleAtomTable;
|
||||
rule_group: RuleGroupTable;
|
||||
scheduled_job: ScheduledJobTable;
|
||||
scheduled_job_run: ScheduledJobRunTable;
|
||||
secret: SecretTable;
|
||||
@@ -1682,6 +1729,12 @@ export type ReconcileRunUpdate = Updateable<ReconcileRunTable>;
|
||||
export type ResolutionAttemptRow = Selectable<ResolutionAttemptTable>;
|
||||
export type NewResolutionAttempt = Insertable<ResolutionAttemptTable>;
|
||||
export type ResolutionAttemptUpdate = Updateable<ResolutionAttemptTable>;
|
||||
export type RuleAtomRow = Selectable<RuleAtomTable>;
|
||||
export type NewRuleAtom = Insertable<RuleAtomTable>;
|
||||
export type RuleAtomUpdate = Updateable<RuleAtomTable>;
|
||||
export type RuleGroupRow = Selectable<RuleGroupTable>;
|
||||
export type NewRuleGroup = Insertable<RuleGroupTable>;
|
||||
export type RuleGroupUpdate = Updateable<RuleGroupTable>;
|
||||
export type ScheduledJobRow = Selectable<ScheduledJobTable>;
|
||||
export type NewScheduledJob = Insertable<ScheduledJobTable>;
|
||||
export type ScheduledJobUpdate = Updateable<ScheduledJobTable>;
|
||||
|
||||
Reference in new issue
Block a user