Description
Hello, I always appreciate rulesync.
Problem
I found a data loss bug in CopilotRule.toRulesyncRule(). When converting a root rule with applyTo: "**", the value is normalized to "**/*" during conversion to a RulesyncRule, but this original value is never restored on the way back, causing the roundtrip to be non-idempotent.
Evidence
In src/features/rules/copilot-rule.ts around line 117–118:
if (this.isRoot()) {
globs = ["**/*"]; // Always hardcoded — original "**" is lost
}And in fromRulesyncRule() around line 160:
applyTo: rulesyncFrontmatter.globs?.length
? rulesyncFrontmatter.globs.join(",")
: undefined,The roundtrip results in:
| Step | Value |
|---|---|
Input (applyTo) |
"**" |
After toRulesyncRule (globs) |
["**/*"] |
After fromRulesyncRule (applyTo) |
"**/*" |
The original "**" is permanently replaced with "**/*" after a single conversion cycle.
Reproduction Steps
- Create a
CopilotRulewithapplyTo: "**"in frontmatter - Call
.toRulesyncRule()→ observeglobs: ["**/*"] - Call
CopilotRule.fromRulesyncRule()on the result → observeapplyTo: "**/*"(not"**")
Expected Behavior
A roundtrip conversion should preserve the original glob value, or at minimum, the two values ("**" and "**/*") should be treated as equivalent throughout the pipeline.
Actual Behavior
"**" is silently replaced with "**/*", causing inconsistency when re-importing or re-syncing rules.
Your consideration would be appreciated.
Activity
flanny7 commentedon Apr 22, 2026
Update: Real-World Impact Scenarios and Reproduction Steps
When Does This Bug Appear?
The bug surfaces when users perform a generate → import roundtrip, which is a common workflow when syncing rules across team members or migrating an existing project.
Scenario 1: Syncing a shared repository
.rulesync/rules/overview.mdwithroot: trueand noglobs:rulesync generate --targets copilot→.github/copilot-instructions.mdis created correctly (body only, no frontmatter)rulesync import --targets copilotto sync.rulesync/rules/copilot-instructions.mdis created with unexpectedglobs: ["**/*"], andoverview.mdremains untouched — causing two conflicting root rulesScenario 2: Re-importing after editing the Copilot file directly
.github/copilot-instructions.mddirectly (e.g., quick hotfix)rulesync import --targets copilotto sync the change backglobs: ["**/*"]that was not in the original source ruleReproduction Steps (Verified)
Actual output after step 6:
Expected output after step 6:
Cascade Failure: Second Generate Breaks
After the import, running
generate --dry-runagain produces an error:Because
importcreates a new file (copilot-instructions.md) rather than updating the original (overview.md), the project ends up with two root rules, and subsequentgenerateinvocations fail entirely.There is no rush at all. Your consideration would be appreciated.
fix(permissions): address review findings (round 1) for kilo/augmentc…
fix(permissions): address review findings (round 2)
refactor(kilo): make subagent validate() pure and tidy schema (PR dyo…
fix(kilo): address review findings on rules/MCP PR
fix(file): dedup symlink-cycle glob results and clarify symlink trust…
fix(generate): correct root-file ownership for wildcard configs and m…
test(mcp): add cross-generator field-stripping contract tests (dyoshi…