Skip to content

rename to criteria config - #477

Merged
iceljc merged 1 commit into
SciSharp:mainfrom
iceljc:features/add-rule-criteria
Aug 13, 2026
Merged

rename to criteria config#477
iceljc merged 1 commit into
SciSharp:mainfrom
iceljc:features/add-rule-criteria

Conversation

@iceljc

Copy link
Copy Markdown
Collaborator

No description provided.

@iceljc
iceljc merged commit 962912e into SciSharp:mainAug 13, 2026
1 of 2 checks passed
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Rename rule criteria to criteria_config across agent rules UI

✨ Enhancement🕐 10-20 Minutes

Grey Divider

AI Description

• Rename rule criteria model to RuleCriteriaConfig for clearer intent and extensibility.
• Update agent rule editor to read/write criteria_config (mode + criteria text).
• Ensure code-script generation uses criteria_config.criteria as the user request input.
Diagram

graph TD
A["Agent Rule Editor"] --> B["agent-rule.svelte"] --> C["agent-rule-item.svelte"]
B --> D("normalizeCriteriaConfig()") --> B
B --> E("generateAgentCodeScript()") --> F{{"Agent Service/API"}}
B --> G[("agentTypes.js")]
C --> G
subgraph Legend
direction LR
_ui["UI component"] ~~~ _fn("Function") ~~~ _ext{{"External API"}} ~~~ _types[("Type defs")]
end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Backward-compatible alias (support both fields)
  • ➕ Avoids breaking older persisted rules or older API payloads still using criteria
  • ➕ Allows gradual migration/deprecation with telemetry/warnings
  • ➖ Slightly more code/branching and a longer deprecation window
  • ➖ Risk of ambiguity if both fields are present
2. Boundary mapping only (UI adapts; backend stays unchanged)
  • ➕ Keeps backend contract stable while improving UI semantics
  • ➕ Limits blast radius to the frontend
  • ➖ Creates mismatch between UI naming and backend naming
  • ➖ Requires careful mapping on every read/write path
3. Explicit migration step for persisted rules
  • ➕ One-time cleanup; removes need for long-term dual-field support
  • ➕ Ensures uniform data shape going forward
  • ➖ Requires migration tooling and coordination with release/deployment
  • ➖ Higher operational risk if migration misses edge cases

Recommendation: If the backend/storage contract has already moved to criteria_config, this PR’s approach is the cleanest. If not, add a short-term compatibility layer (accept criteria on read and write criteria_config) or a migration plan to prevent breaking existing saved rules and older clients.

Files changed (3) +18 / -18

Refactor (3) +18 / -18
agentTypes.jsRename RuleCriteria typedef to RuleCriteriaConfig and update AgentRule field+3/-3

Rename RuleCriteria typedef to RuleCriteriaConfig and update AgentRule field

• Renames the JSDoc typedef from 'RuleCriteria' to 'RuleCriteriaConfig' and updates the AgentRule shape to use 'criteria_config' instead of 'criteria'. Also clarifies the mode description to include python scripts.

src/lib/helpers/types/agentTypes.js

agent-rule-item.svelteUpdate rule item UI bindings to criteria_config+3/-3

Update rule item UI bindings to criteria_config

• Switches UI bindings from 'rule.criteria' to 'rule.criteria_config' for determining compile eligibility, selected criteria mode, and criteria text value. This aligns the editor fields with the renamed data model.

src/routes/page/agent/[agentId]/agent-components/rules/agent-rule-item.svelte

agent-rule.sveltePersist and normalize criteria_config across rule lifecycle+12/-12

Persist and normalize criteria_config across rule lifecycle

• Updates rule fetching, state updates, and default rule creation to use 'criteria_config'. Renames and updates the normalization helper and ensures code-script generation uses 'criteria_config.criteria' as the request payload input.

src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1)📘 Rule violations (0)📜 Skill insights (0)

Grey Divider


Action required

1. Legacy criteria ignored 🐞 Bug≡ Correctness
Description
The rules UI now reads and saves only rule.criteria_config; any existing rule objects that still
have the legacy criteria field will render as having no criteria (including disabling code
generation) and will be saved with criteria_config: null in the rebuilt rules payload.
Code

src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte[R46-48]

 message: x.message || null,
- criteria: normalizeCriteria(x.criteria),+ criteria_config: normalizeCriteriaConfig(x.criteria_config),
expanded: x.expanded
Evidence
fetchRules() rebuilds outgoing rule objects and normalizes only x.criteria_config, so any
criteria stored under another key is ignored. The rule item UI also exclusively checks
rule.criteria_config to decide whether criteria exists (and whether code generation is available).

src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte[41-50]
src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte[164-172]
src/routes/page/agent/[agentId]/agent-components/rules/agent-rule-item.svelte[44-47]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The UI migrated from `criteria` to `criteria_config` but does not map legacy rule objects that still carry `criteria`. Because `fetchRules()` rebuilds the rules payload using only `x.criteria_config`, legacy criteria can be dropped on save.
## Issue Context
This repo appears to be a frontend that consumes persisted agent rule JSON from an external API/storage; renames like this typically require handling pre-migration data.
## Fix Focus Areas
- src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte[41-50]
- src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte[164-172]
- src/routes/page/agent/[agentId]/agent-components/rules/agent-rule-item.svelte[44-47]
## What to change
1. When initializing/refreshing `innerRules` (e.g., in `init()` or `innerRefresh()`), map legacy to new:
- If `x.criteria_config` is missing but `x.criteria` exists, set `criteria_config = x.criteria` (or normalize it).
2. In `fetchRules()`, be defensive when normalizing:
- Use `normalizeCriteriaConfig(x.criteria_config ?? x.criteria)`.
3. Optionally (belt-and-suspenders), in the UI read path you can also fall back:
- `rule.criteria_config?.criteria ?? rule.criteria?.criteria` (only if `rule.criteria` can exist at runtime).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines 46 to 48
message: x.message || null,
criteria: normalizeCriteria(x.criteria),
criteria_config: normalizeCriteriaConfig(x.criteria_config),
expanded: x.expanded

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Legacy criteria ignored 🐞 Bug≡ Correctness

The rules UI now reads and saves only rule.criteria_config; any existing rule objects that still
have the legacy criteria field will render as having no criteria (including disabling code
generation) and will be saved with criteria_config: null in the rebuilt rules payload.
Agent Prompt
## Issue description
The UI migrated from `criteria` to `criteria_config` but does not map legacy rule objects that still carry `criteria`. Because `fetchRules()` rebuilds the rules payload using only `x.criteria_config`, legacy criteria can be dropped on save.
## Issue Context
This repo appears to be a frontend that consumes persisted agent rule JSON from an external API/storage; renames like this typically require handling pre-migration data.
## Fix Focus Areas
- src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte[41-50]
- src/routes/page/agent/[agentId]/agent-components/rules/agent-rule.svelte[164-172]
- src/routes/page/agent/[agentId]/agent-components/rules/agent-rule-item.svelte[44-47]
## What to change
1. When initializing/refreshing `innerRules` (e.g., in `init()` or `innerRefresh()`), map legacy to new:
- If `x.criteria_config` is missing but `x.criteria` exists, set `criteria_config = x.criteria` (or normalize it).
2. In `fetchRules()`, be defensive when normalizing:
- Use `normalizeCriteriaConfig(x.criteria_config ?? x.criteria)`.
3. Optionally (belt-and-suspenders), in the UI read path you can also fall back:
- `rule.criteria_config?.criteria ?? rule.criteria?.criteria` (only if `rule.criteria` can exist at runtime).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@iceljc