Skip to content

feat(agent-config): JSON merge-patch, JSON pointer, overlay ops and YAML helpers [2/21] - #323

Merged
gusfcarvalho merged 2 commits into
agent-config/01-code-editorfrom
agent-config/02-overlay-primitives
Oct 6, 2026
Merged

gusfcarvalho merged 2 commits into
agent-config/01-code-editorfrom
agent-config/02-overlay-primitives

Conversation

@gusfcarvalho

Copy link
Copy Markdown
Contributor

Part 2 of 21 of the stacked split of #318 (agent remote configuration). Every layer adds the final version of its files from #318, and only imports from layers below it, so each layer passes make reviewable on its own. Nothing is reachable in the app until layer 20 wires the Configuration tab in.

What

Pure helpers the overlay editor is built on: RFC 7396 JSON merge-patch, RFC 6901 JSON pointers, overlay set/unset operations, YAML parse/dump wrappers and value provenance (overlay vs. host vs. default).

Tests

Unit specs for each helper.

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 5, 2026 10:51
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8cad1cc6-3999-4d07-9760-95fce19f99a3
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

YAML validation and provenance classification still have correctness defects.

Review effort: Balanced
Findings: 2 High severity · 2 Medium severity

Open (4)
What changed in this PR

Adds foundational helpers for the agent configuration overlay editor, without exposing new app UI yet.

Changes:

  • Adds merge-patch, JSON Pointer, and immutable overlay-editing utilities.
  • Adds YAML parsing/rendering and value provenance.
  • Adds unit tests for all five helpers.
File Description
src/​utils/​agent-config/​yaml.ts YAML parsing, rendering, and validation.
src/​utils/​agent-config/​provenance.ts Classifies file and overlay value origins.
src/​utils/​agent-config/​overlay-ops.ts Immutable set, unset, and delete operations.
src/​utils/​agent-config/​merge-patch.ts Merge-patch, cloning, and structural equality.
src/​utils/​agent-config/​json-pointer.ts Pointer encoding, lookup, and ancestry checks.
src/​utils/​agent-config/​__tests__/​yaml.spec.ts Tests YAML conversion and validation.
src/​utils/​agent-config/​__tests__/​provenance.spec.ts Tests provenance classifications.
src/​utils/​agent-config/​__tests__/​overlay-ops.spec.ts Tests edits, pruning, and prototype-key safety.
src/​utils/​agent-config/​__tests__/​merge-patch.spec.ts Tests RFC examples and immutability.
src/​utils/​agent-config/​__tests__/​json-pointer.spec.ts Tests pointer parsing and navigation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

let nodes = 0;
const visit = (v: unknown): string | null => {
if (++nodes > MAX_NODES) return 'Document is too large';
if (v === null || typeof v !== 'object') return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in c157be1. parseYaml now loads with CORE_SCHEMA int/float types that reject non-finite values (.inf, -.Inf, .nan) with a blocking error at their line and column ("… is not a finite number: quote it to keep it as text"), so nothing reaches JSON.stringify as null. 1e999 is not a YAML float at all, so it stays the string that was typed. Specs are in yaml.spec.ts.

Comment thread src/utils/agent-config/yaml.ts Outdated
error: { message: (e as Error).message ?? String(e), line: 0, column: 0 },
};
}
if (value === null || value === undefined) return { ok: true, value: {} };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in c157be1. An explicit null / ~ root (also --- null) now fails with "Overlay must be a mapping". Only text without any node, meaning empty or comment-only, is {}. js-yaml loads both as null, so a load listener records whether any node had content.

Comment thread src/utils/agent-config/provenance.ts Outdated
base: unknown,
overlay: unknown,
): Provenance {
const inBase = hasAt(base, ptr) && getAt(base, ptr) !== null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in c157be1. Whether the file has the member is now decided by hasAt alone, so for base {k: null}, {k: 1} is overrides-file and {k: null} is removed-by-overlay. Spec added.

Comment thread src/utils/agent-config/provenance.ts Outdated
overlay: unknown,
): Provenance {
const inBase = hasAt(base, ptr) && getAt(base, ptr) !== null;
if (nulledByOverlay(overlay, ptr)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fixed in c157be1. Provenance now walks the overlay from the root. A null on a plain-object path is a deletion. An array or scalar ancestor replaces the whole subtree: nulls below it are data, and a descendant is overrides-file/overlay if the replacement has it, otherwise removed-by-overlay when the file had it. Specs cover [1]→[null], [{x,y}]→[{x}] and scalar/object replacements.

…AML helpers

Layer 2 of 21 in the stacked split of #318.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gusfcarvalho
gusfcarvalho force-pushed the agent-config/02-overlay-primitives branch from d29715b to 5813fc1 Compare October 5, 2026 16:32

@ianmiell ianmiell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ccf-review: REQUEST_CHANGES

1 Must-fix.

Stack (gh stack 343): #322 → #323 → #324 → #325 → #326 → #327 → #328 → #329 → #330 → #331 → #332 → #333 → #334 → #335 → #336 → #337 → #338 → #339 → #340 → #341 → #342

Comment thread src/utils/agent-config/yaml.ts Outdated
…7396 provenance

- parseYaml rejects numbers that would not be saved as typed (.inf/.nan,
  0644/0x1F/0o17/+5, integers past 2^53) with the line and column, for
  every field and for mapping keys; quoting keeps them as text
- an explicit null / ~ root is not a mapping; only comment-only text is {}
- provenance: a null file value is present; under an array or scalar
  replacement, nulls are data and descendants are classified by the
  replacement

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ianmiell ianmiell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ccf-review: APPROVE

no findings.

Stack (gh stack 343): #322 → #323 → #324 → #325 → #326 → #327 → #328 → #329 → #330 → #331 → #332 → #333 → #334 → #335 → #336 → #337 → #338 → #339 → #340 → #341 → #342

@gusfcarvalho
gusfcarvalho merged commit 43dd9bb into main Oct 6, 2026
3 checks passed
@gusfcarvalho
gusfcarvalho deleted the agent-config/02-overlay-primitives branch October 6, 2026 15:13
Sign up for free to 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.

3 participants