Skip to content

fix: Ad4mModel don't parse every Literal in properties (only when resolve language)#695

Merged
lucksus merged 6 commits intodevfrom
fix/ad4m-model-parse-literal
Feb 26, 2026
Merged

fix: Ad4mModel don't parse every Literal in properties (only when resolve language)#695
lucksus merged 6 commits intodevfrom
fix/ad4m-model-parse-literal

Conversation

@lucksus
Copy link
Member

@lucksus lucksus commented Feb 25, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Prevented unintended unwrapping of literal URIs in property resolution.
    • Enhanced link validation messages with contextual details for clearer diagnostics.
  • Chores

    • Bumped package and project versions; made core package publishable.
  • Tests

    • Updated bootstrap seed data used by test suites.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1436f4 and 8a6f28c.

📒 Files selected for processing (1)
  • rust-executor/src/types.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • rust-executor/src/types.rs

📝 Walkthrough

Walkthrough

Tightens literal-URI parsing so literal:// values are parsed only when a property's resolveLanguage === "literal", augments link validation errors with contextual link details, updates many package/Cargo manifest versions, and replaces test seed JSON data.

Changes

Cohort / File(s) Summary
Literal-URI Parsing Guard
core/src/model/Ad4mModel.ts
Adds guards so literal:// values are parsed only when the property's resolveLanguage is explicitly "literal", applied to both primary resolution and fallback/assignment paths.
Link Validation Context
rust-executor/src/types.rs
Enhances Link::validate error messages by appending a local link_desc (source, target, optional predicate) to validation/empty-field errors for clearer diagnostics.
Version / Manifest Bumps
**/package.json, **/Cargo.toml, core/package.json, executor/src/core/Config.ts, rust-executor/src/globals.rs, ui/src-tauri/tauri.conf.json
Widespread metadata version updates from 0.12.0-rc1-dev0.12.0-rc1-dev.1; core/package.json also removes the private flag.
Hook Packages
ad4m-hooks/helpers/package.json, ad4m-hooks/react/package.json, ad4m-hooks/vue/package.json
Bumped package versions and updated @coasys/ad4m workspace dependency reference to 0.12.0-rc1-dev.1.
Bootstrap Languages Manifests
bootstrap-languages/*/package.json
Individual language package versions bumped to 0.12.0-rc1-dev.1 (metadata-only changes).
Executor / Rust Manifests
executor/package.json, rust-executor/package.json, rust-client/Cargo.toml, cli/Cargo.toml, ui/src-tauri/Cargo.toml
Crate/package versions and some internal dependency versions bumped to .1.
Tests / Seed Data
tests/js/bootstrapSeed.json
Replaces seed data with a new set of trusted agents, known link languages, language bundles, and related entries (data-only update).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

"I hop and guard the literal stream, 🐇
Only parse what the schema deems,
Errors now wear their context bright,
Seeded anew for morning light,
Small bumps, clear paths — a rabbit's delight!"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main functional change: preventing unconditional parsing of literal-URI values in property resolution, with parsing now limited to cases where resolveLanguage is explicitly set to 'literal'.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ad4m-model-parse-literal

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/src/model/Ad4mModel.ts`:
- Around line 1698-1701: getData() currently parses any "literal://" values
unconditionally; mirror the guard added elsewhere by only parsing literal://
URIs when the property's propMeta.resolveLanguage === 'literal' (same check used
in the other branch). Update getData() to inspect propMeta.resolveLanguage
before unwrapping literal:// strings so get()/save() paths behave consistently;
reference the getData() function and the propMeta.resolveLanguage literal check
used where you added the guard, and ensure behavior matches get()/save() by
refusing to parse literal:// unless resolveLanguage === 'literal'.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8601815 and 3cb45e0.

📒 Files selected for processing (2)
  • core/src/model/Ad4mModel.ts
  • rust-executor/src/types.rs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/js/bootstrapSeed.json (1)

1-1: Consider externalizing the embedded bundle from the JSON fixture.

Line 1 packs a very large escaped JS payload into one JSON field, which makes diffs hard to review and conflict-prone. Optional improvement: keep the bundle in a separate fixture file and load/inject it in test setup.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/js/bootstrapSeed.json` at line 1, The JSON fixture embeds a huge JS
bundle in the languageLanguageBundle field which makes reviews and diffs
painful; move the bundle into a separate fixture file (e.g.
tests/fixtures/languageBundle.js), replace the languageLanguageBundle value in
tests/js/bootstrapSeed.json with a small sentinel (for example
"@file:languageBundle.js"), and update your test setup code to detect that
sentinel and load the external file via Deno.readTextFileSync (injecting its
contents into the languageLanguageBundle key before tests run). Ensure the test
loader looks for the languageLanguageBundle field in the bootstrap fixture and
performs the read/replace so existing consumers (fields named
languageLanguageBundle) continue to work unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/js/bootstrapSeed.json`:
- Line 1: The JSON fixture embeds a huge JS bundle in the languageLanguageBundle
field which makes reviews and diffs painful; move the bundle into a separate
fixture file (e.g. tests/fixtures/languageBundle.js), replace the
languageLanguageBundle value in tests/js/bootstrapSeed.json with a small
sentinel (for example "@file:languageBundle.js"), and update your test setup
code to detect that sentinel and load the external file via
Deno.readTextFileSync (injecting its contents into the languageLanguageBundle
key before tests run). Ensure the test loader looks for the
languageLanguageBundle field in the bootstrap fixture and performs the
read/replace so existing consumers (fields named languageLanguageBundle)
continue to work unchanged.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3cb45e0 and f1436f4.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (26)
  • ad4m-hooks/helpers/package.json
  • ad4m-hooks/react/package.json
  • ad4m-hooks/vue/package.json
  • bootstrap-languages/agent-language/package.json
  • bootstrap-languages/direct-message-language/package.json
  • bootstrap-languages/neighbourhood-language/package.json
  • bootstrap-languages/p-diff-sync/package.json
  • bootstrap-languages/perspective-language/package.json
  • cli/Cargo.toml
  • connect/package.json
  • core/package.json
  • core/src/model/Ad4mModel.ts
  • docs-src/package.json
  • executor/package.json
  • executor/src/core/Config.ts
  • package.json
  • rust-client/Cargo.toml
  • rust-executor/Cargo.toml
  • rust-executor/package.json
  • rust-executor/src/globals.rs
  • test-runner/package.json
  • tests/js/bootstrapSeed.json
  • tests/js/package.json
  • ui/package.json
  • ui/src-tauri/Cargo.toml
  • ui/src-tauri/tauri.conf.json
✅ Files skipped from review due to trivial changes (8)
  • executor/package.json
  • bootstrap-languages/neighbourhood-language/package.json
  • bootstrap-languages/agent-language/package.json
  • rust-executor/Cargo.toml
  • test-runner/package.json
  • bootstrap-languages/p-diff-sync/package.json
  • package.json
  • ad4m-hooks/helpers/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/src/model/Ad4mModel.ts

@lucksus lucksus merged commit c918f79 into dev Feb 26, 2026
5 checks passed
jhweir added a commit that referenced this pull request Feb 26, 2026
…ge === literal|undefined

Same root cause as #695 (do not parse every literal:// target
unconditionally), but the fix differs because our refactored mutation layer
always encodes plain scalar values as literal:// URIs (unlike the old
monolithic Ad4mModel where only explicit resolveLanguage:"literal" props
used literal://).

Before: resolveValue() parsed ANY literal:// target regardless of
resolveLanguage. A property with resolveLanguage set to a custom language
address whose stored target happened to be a literal:// string (e.g. a
model baseExpression URI stored as a string property) would have its URI
silently destroyed, returning the unwrapped random ID instead.

After: literal:// is only parsed when resolveLanguage is "literal" or
undefined (the normal case for plain string/number properties). A
non-literal resolveLanguage whose value starts with literal:// is left
raw, preserving the URI for the caller.

PR #695 can be dropped from dev once this branch merges — we replace
the entire Ad4mModel.ts, so the old code path no longer exists.
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.

1 participant