feat: add CEL expression support for structured work scopes - #141
Conversation
🦋 Changeset detectedLatest commit: 7418834 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR introduces CEL (Common Expression Language) support for structured work scopes by adding two new lexicon definitions, removing the legacy helper-based work scope tag, updating the activity lexicon to reference the new CEL type, and revising documentation and schema generation logic accordingly. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lexicons/org/hypercerts/helper/celExpression.json`:
- Around line 1-38: The lexicon org.hypercerts.helper.celExpression uses main
with type: "object" which deviates from the repo convention (most top-level
lexicons use type: "record"); either convert main to type: "record" with key:
"tid" (preserving properties expression, labels, version, createdAt) to match
the generator, or keep type: "object" but add a top-level description field in
the JSON that documents the deviation and rationale (mentioning it's intended
for inline-only embedding and referencing the CEL use-case), and note that the
SCHEMAS.md generator must be updated to handle object-type mains so properties
are rendered correctly; modify either the main definition or the description in
org.hypercerts.helper.celExpression accordingly.
In `@lexicons/org/hypercerts/helper/workScopeTag.json`:
- Around line 23-28: You renamed the optional field workScopeTag.kind to type
which will silently break existing clients; instead preserve the original schema
and introduce a backwards-incompatible new schema (e.g., workScopeTagV2) that
defines "type" (and mark "kind" deprecated in the old schema if desired), update
any AppViews/clients to consume workScopeTagV2 before switching, and coordinate
a migration/communication plan; locate the definitions by the schema name
workScopeTag and the fields kind/type to add the new workScopeTagV2 schema and
keep the original schema unchanged until consumers are updated.
In `@SCHEMAS.md`:
- Around line 296-297: The table in SCHEMAS.md incorrectly lists `aliases` and
`sameAs` as Type `string` while their JSON schema defines them as arrays; update
the Type column entries for the `aliases` and `sameAs` rows to reflect an array
of strings/URIs (e.g., "string[]" or "array of string/URI") so it matches the
schema's `type: "array"` and keep the existing `maxLength` comment unchanged;
ensure the row labels `aliases` and `sameAs` are the ones edited to maintain
consistency with the schema.
- Around line 271-277: The org.hypercerts.helper.celExpression section in
SCHEMAS.md is wrong: change/remove the incorrect "**Key:** `tid`" (it should not
declare a record key because celExpression.json defines main as type: "object")
and add a properties table documenting the four required fields from
celExpression.json: expression, labels, version, createdAt; update the section
header/body for org.hypercerts.helper.celExpression to reflect that main is an
object (not a record) and list each property name, type, description, and
required status per the celExpression.json schema so the generated docs match
the source.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.changeset/add-cel-work-scope-expressions.mdERD.pumlREADME.mdSCHEMAS.mdlexicons/org/hypercerts/claim/activity.jsonlexicons/org/hypercerts/helper/celExpression.jsonlexicons/org/hypercerts/helper/workScopeTag.json
- Fix getTypeString to show array types as type[] instead of just the item type - Handle type: "object" main defs (no Key line, render properties directly from main instead of main.record) - Add deviation rationale to celExpression.json documenting why it uses type: "object" instead of type: "record" - Regenerate SCHEMAS.md with fixes Addresses CodeRabbitAI review comments on PR #141. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Addressed all CodeRabbitAI comments in 082a242:
|
There was a problem hiding this comment.
♻️ Duplicate comments (1)
SCHEMAS.md (1)
338-338:⚠️ Potential issue | 🔴 CriticalStale field name —
typehere should bekindafter the field revert, causing the CI failure.This auto-generated file still reflects the intermediate state where the field was renamed
type. The source JSON (workScopeTag.json) reverted it back tokind, but SCHEMAS.md was not regenerated. The CIgit diff --exit-codecheck catches this exactly.Regenerating SCHEMAS.md from the current lexicons will fix this line and unblock CI.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@SCHEMAS.md` at line 338, SCHEMAS.md contains a stale field name `type` for the work scope tag; regenerate the schema docs from the current lexicons so the `workScopeTag` entry uses `kind` (matching workScopeTag.json) rather than `type` to fix the CI git-diff failure; run the doc generation script/process you use for SCHEMAS.md, verify the table row for the workScopeTag (the line showing "`type` | `string` | ... Known values") is updated to "`kind`", and commit the regenerated SCHEMAS.md.
🧹 Nitpick comments (1)
lexicons/org/hypercerts/helper/workScopeTag.json (1)
46-50: Consider documenting thesupersededBy/statuscoupling in more detail.
supersededByis only meaningful whenstatusis"deprecated", but ATProto doesn't support conditional field validation — this guidance lives only in the description. The description is clear, so this is acceptable, but consider also noting in thestatusfield description that settingstatus: "deprecated"without asupersededByreference should be avoided (or calling it out via aknownValues-style annotation).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lexicons/org/hypercerts/helper/workScopeTag.json` around lines 46 - 50, Update the schema documentation to explicitly describe the coupling between status and supersededBy: in the lexicon org.hypercerts.helper.workScopeTag, augment the description of the status field to state that when status = "deprecated" a supersededBy ref to another workScopeTag SHOULD be provided (and that leaving deprecated without supersededBy is discouraged), and optionally add a note/annotation (e.g., knownValues-style guidance or a "recommendedUsage" sentence) next to the status and supersededBy entries to make this constraint obvious to consumers; ensure you reference the status field and the supersededBy property by name so readers can find the coupling easily.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@SCHEMAS.md`:
- Line 338: SCHEMAS.md contains a stale field name `type` for the work scope
tag; regenerate the schema docs from the current lexicons so the `workScopeTag`
entry uses `kind` (matching workScopeTag.json) rather than `type` to fix the CI
git-diff failure; run the doc generation script/process you use for SCHEMAS.md,
verify the table row for the workScopeTag (the line showing "`type` | `string` |
... Known values") is updated to "`kind`", and commit the regenerated
SCHEMAS.md.
---
Nitpick comments:
In `@lexicons/org/hypercerts/helper/workScopeTag.json`:
- Around line 46-50: Update the schema documentation to explicitly describe the
coupling between status and supersededBy: in the lexicon
org.hypercerts.helper.workScopeTag, augment the description of the status field
to state that when status = "deprecated" a supersededBy ref to another
workScopeTag SHOULD be provided (and that leaving deprecated without
supersededBy is discouraged), and optionally add a note/annotation (e.g.,
knownValues-style guidance or a "recommendedUsage" sentence) next to the status
and supersededBy entries to make this constraint obvious to consumers; ensure
you reference the status field and the supersededBy property by name so readers
can find the coupling easily.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
ERD.pumlSCHEMAS.mdlexicons/org/hypercerts/helper/celExpression.jsonlexicons/org/hypercerts/helper/workScopeTag.jsonscripts/generate-schemas.js
🚧 Files skipped from review as they are similar to previous changes (2)
- ERD.puml
- lexicons/org/hypercerts/helper/celExpression.json
- Fix getTypeString to show array types as type[] instead of just the item type - Handle type: "object" main defs (no Key line, render properties directly from main instead of main.record) - Add deviation rationale to celExpression.json documenting why it uses type: "object" instead of type: "record" - Regenerate SCHEMAS.md with fixes Addresses CodeRabbitAI review comments on PR #141. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…mespace move - Regenerate SCHEMAS.md after workScopeTag.kind rename and ontology namespace migration (helper→ontology) - The stale 'type' field in SCHEMAS.md was causing CI git-diff failure - Add AI tool directories to .prettierignore Addresses CodeRabbit feedback on PR #141.
3a3f6f7 to
0f835d5
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ERD.puml`:
- Around line 179-203: The workScopeTag dataclass in ERD.puml is stale and uses
old namespace and field names; update the dataclass named workScopeTag to match
the current lexicon org.hypercerts.workscope.* by replacing deprecated fields
(label → name, kind → category, externalReference → referenceDocument) and
remove or update the outdated namespace comment (org.hypercerts.ontology.*) so
all fields and the entity namespace align with the lexicons in
lexicons/**/*.json; ensure optional fields (parent?, status?, supersededBy?,
aliases[]?, sameAs[]?) remain correct per the lexicon and adjust SHOW_FIELDS
block accordingly.
In `@README.md`:
- Around line 86-89: Replace the placeholder type string "...#workScopeString"
with a concrete NSID that matches the project's schema (e.g., set workScope: {
$type: "org.hypercerts.workScope#workScopeString", scope: "Environmental
conservation" }); update the README example where workScope appears and ensure
the workScope schema name and property "scope" align with the actual JSON schema
for workScope and that startDate remains a valid ISO timestamp; verify the
substituted NSID exactly matches the schema's $type value used in the codebase
(search for workScopeString, workScope, and startDate symbols).
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
.changeset/add-cel-work-scope-expressions.md.prettierignoreERD.pumlREADME.mdSCHEMAS.mdlexicons/org/hypercerts/claim/activity.jsonlexicons/org/hypercerts/helper/workScopeTag.jsonlexicons/org/hypercerts/workscope/cel.jsonlexicons/org/hypercerts/workscope/tag.jsonscripts/generate-schemas.js
💤 Files with no reviewable changes (1)
- lexicons/org/hypercerts/helper/workScopeTag.json
🚧 Files skipped from review as they are similar to previous changes (1)
- .changeset/add-cel-work-scope-expressions.md
Introduce a two-layer work scope model: reusable vocabulary atoms (workScopeTag) composed into machine-evaluable boolean logic via CEL expressions (celExpression) on activity records. - Add org.hypercerts.helper.celExpression object type with expression, labels (denormalized index), version, and createdAt - Enhance org.hypercerts.helper.workScopeTag with lifecycle fields (status, supersededBy), interop (sameAs), rename kind→type with knownValues, and underscore-separated key convention for CEL compat - Update activity.workScope union to [celExpression, strongRef, workScopeString] with CEL as the primary variant - Update ERD with new entities and relationships - Update README example to show CEL expression usage Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix getTypeString to show array types as type[] instead of just the item type - Handle type: "object" main defs (no Key line, render properties directly from main instead of main.record) - Add deviation rationale to celExpression.json documenting why it uses type: "object" instead of type: "record" - Regenerate SCHEMAS.md with fixes Addresses CodeRabbitAI review comments on PR #141. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avoid collision with the reserved `type` keyword in AT Protocol schemas. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…strongRef usedTags - Move celExpression and workScopeTag from helper/ to ontology/ (IDs: org.hypercerts.ontology.celExpression, org.hypercerts.ontology.workScopeTag) - Replace plain-string `labels` array with `usedTags` strongRef array for referential integrity to workScopeTag records - Add knownValues: ["v1"] to version field - Update all references in activity.json, ERD, and README Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…mespace move - Regenerate SCHEMAS.md after workScopeTag.kind rename and ontology namespace migration (helper→ontology) - The stale 'type' field in SCHEMAS.md was causing CI git-diff failure - Add AI tool directories to .prettierignore Addresses CodeRabbit feedback on PR #141.
- Rename lexicons/org/hypercerts/ontology/ to workscope/ - Rename celExpression.json to cel.json (org.hypercerts.workscope.cel) - Rename workScopeTag.json to tag.json (org.hypercerts.workscope.tag) - Rename label to name, kind to category, externalReference to referenceDocument - Update sameAs and referenceDocument descriptions for clarity - Update all references in activity.json, cel.json, tag.json, and README.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep the union simpler with just CEL expressions and free-form strings. strongRef can be added later if needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b67b3c0 to
075a6e5
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (2)
README.md (1)
86-88:⚠️ Potential issue | 🟡 MinorUse a concrete NSID for the
workScopeStringexample.Line 88 still uses the placeholder
"...#workScopeString"which is not actionable and can mislead copy/paste usage. Replace with the concrete NSID.📝 Suggested fix
// OR a strongRef to a single work scope tag: // workScope: { uri: "at://did:plc:alice/org.hypercerts.workscope.tag/abc123", cid: "..." }, - // OR a simple string: workScope: { $type: "...#workScopeString", scope: "Environmental conservation" }, + // OR a simple string: + // workScope: { $type: "org.hypercerts.claim.activity#workScopeString", scope: "Environmental conservation" },As per coding guidelines: "When README.md is modified, verify that ... all documented properties match actual JSON schema definitions."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` around lines 86 - 88, Replace the placeholder NSID in the workScope example so it matches the actual schema: change the $type value in the workScope example (workScope: { $type: "...#workScopeString", scope: "Environmental conservation" }) to a concrete NSID used by the project (e.g., "org.hypercerts.workscope#workScopeString" or the exact NSID defined in your JSON schema) so the README's workScopeString example is actionable and copy/paste-ready.ERD.puml (1)
194-219:⚠️ Potential issue | 🟠 MajorERD namespace comments and workScopeTag fields are out of sync with lexicon schemas.
The ERD has two categories of mismatches:
Namespace comments (lines 194, 204): Reference
org.hypercerts.ontology.*but the actual lexicons useorg.hypercerts.workscope.*workScopeTag field names (lines 208-216): Use stale names that don't match
tag.json:
label→ should benamekind?→ should becategory?externalReference?→ should bereferenceDocument?🛠️ Suggested fix
-' org.hypercerts.ontology.celExpression +' org.hypercerts.workscope.cel dataclass celExpression { !if (SHOW_FIELDS == "true") expression usedTags[] version createdAt !endif } -' org.hypercerts.ontology.workScopeTag +' org.hypercerts.workscope.tag dataclass workScopeTag { !if (SHOW_FIELDS == "true") key - label - kind? + name + category? description? parent? status? supersededBy? aliases[]? sameAs[]? - externalReference? + referenceDocument? createdAt !endif }As per coding guidelines: "When ERD.puml is modified, verify that all entities referenced correspond to lexicons in lexicons/**/*.json."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ERD.puml` around lines 194 - 219, Update the ERD to match the current lexicons: change the namespace comments referencing org.hypercerts.ontology.* to org.hypercerts.workscope.* for the dataclasses (e.g., celExpression and workScopeTag) and rename the workScopeTag fields to match tag.json — replace label with name, kind? with category?, and externalReference? with referenceDocument?; then verify dataclass workScopeTag and celExpression match the lexicon JSON field set and run the guideline check to ensure all ERD entities correspond to lexicons/**/*.json.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@ERD.puml`:
- Around line 194-219: Update the ERD to match the current lexicons: change the
namespace comments referencing org.hypercerts.ontology.* to
org.hypercerts.workscope.* for the dataclasses (e.g., celExpression and
workScopeTag) and rename the workScopeTag fields to match tag.json — replace
label with name, kind? with category?, and externalReference? with
referenceDocument?; then verify dataclass workScopeTag and celExpression match
the lexicon JSON field set and run the guideline check to ensure all ERD
entities correspond to lexicons/**/*.json.
In `@README.md`:
- Around line 86-88: Replace the placeholder NSID in the workScope example so it
matches the actual schema: change the $type value in the workScope example
(workScope: { $type: "...#workScopeString", scope: "Environmental conservation"
}) to a concrete NSID used by the project (e.g.,
"org.hypercerts.workscope#workScopeString" or the exact NSID defined in your
JSON schema) so the README's workScopeString example is actionable and
copy/paste-ready.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
.changeset/add-cel-work-scope-expressions.mdERD.pumlREADME.mdSCHEMAS.mdlexicons/org/hypercerts/claim/activity.jsonlexicons/org/hypercerts/helper/workScopeTag.jsonlexicons/org/hypercerts/workscope/cel.jsonlexicons/org/hypercerts/workscope/tag.jsonscripts/generate-schemas.js
💤 Files with no reviewable changes (1)
- lexicons/org/hypercerts/helper/workScopeTag.json
🚧 Files skipped from review as they are similar to previous changes (4)
- lexicons/org/hypercerts/workscope/cel.json
- lexicons/org/hypercerts/claim/activity.json
- .changeset/add-cel-work-scope-expressions.md
- scripts/generate-schemas.js
Summary
Implements the two-layer work scope model from the CEL for Hypercerts design document, enabling machine-evaluable, composable work scope definitions on activity records.
org.hypercerts.ontology.celExpression— CEL expression object type withexpression,usedTags(strongRef array to workScopeTag records),version(knownValues:v1), andcreatedAtorg.hypercerts.ontology.workScopeTag— reusable scope atoms with lifecycle fields (status,supersededBy), interop (sameAs),kindwithknownValues, and underscore-separated key convention for CEL compatibilityactivity.workScopeunion now includes[celExpression, strongRef, workScopeString]with CEL as the primary variantKey design decisions
org.hypercerts.ontology.*usedTagsfieldstrongRef[](not plain strings)versionfieldknownValues: ["v1"]object(notrecord)Architecture
Test plan
npm run checkpasses (gen-api, lint, typecheck, build, 7/7 tests)node scripts/check-lexicon-style.js— 0 errors on new files🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Documentation