Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
267 changes: 267 additions & 0 deletions services/ontology/schemas/accessGrant.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"schemaId": "15d24c04-a4f3-4e45-a00e-0123926fbc87",
"title": "AccessGrant",
"type": "object",
"properties": {
"isReference": {
"type": "boolean"
},
"grantId": {
"type": "string",
"minLength": 1
},
"grantorEName": {
"type": "string",
"minLength": 1
},
"granteeType": {
"type": "string",
"enum": [
"ename",
"public"
]
},
"granteeEName": {
"type": [
"string",
"null"
],
"minLength": 1
},
"resourceType": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*$"
},
"permissions": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string",
"pattern": "^[a-z][a-z0-9-]*:[A-Za-z][A-Za-z0-9]*$"
}
},
"status": {
"type": "string",
"enum": [
"active",
"revoked"
]
},
"validFrom": {
"type": "string",
"format": "date-time"
},
"validUntil": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"updatedAt": {
"type": "string",
"format": "date-time"
},
"revision": {
"type": "integer",
"minimum": 1
},
"revokedAt": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"delegationAllowed": {
"type": "boolean"
},
Comment on lines +82 to +84

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

delegationAllowed can never be true — the field is effectively dead.

CanonicalAccessGrant forces delegationAllowed to const: false while also requiring the key, and AccessGrantReference forbids the key entirely. Since these are the only oneOf branches, no valid AccessGrant instance can have delegationAllowed: true. If delegation support is intended, make the value configurable here; if delegation is unavailable, avoid exposing an authoritative, required field that upstream/downstream consumers might treat as controllable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@services/ontology/schemas/accessGrant.json` around lines 82 - 84, Update the
delegationAllowed definition and its related oneOf schemas, including
CanonicalAccessGrant and AccessGrantReference, so the schema accurately reflects
whether delegation is supported: allow true values through the applicable branch
if delegation is intended, or remove the authoritative required field when
delegation is unavailable. Ensure no branch simultaneously requires
delegationAllowed to be false while another forbids the key.

"canonicalEnvelopeId": {
"type": "string",
"minLength": 1
}
},
"required": [
"isReference",
"grantId",
"grantorEName",
"granteeType",
"createdAt"
],
"oneOf": [
{
"title": "CanonicalAccessGrant",
"properties": {
"isReference": {
"const": false
},
"delegationAllowed": {
"const": false
}
},
"required": [
"isReference",
"grantId",
"grantorEName",
"granteeType",
"granteeEName",
"resourceType",
"permissions",
"status",
"validFrom",
"validUntil",
"createdAt",
"updatedAt",
"revision",
"revokedAt",
"delegationAllowed"
],
"not": {
"required": [
"canonicalEnvelopeId"
]
}
},
{
"title": "AccessGrantReference",
"properties": {
"isReference": {
"const": true
},
"granteeType": {
"const": "ename"
}
},
"required": [
"isReference",
"grantId",
"grantorEName",
"granteeType",
"granteeEName",
"canonicalEnvelopeId",
"createdAt"
],
"not": {
"anyOf": [
{
"required": [
"resourceType"
]
},
{
"required": [
"permissions"
]
},
{
"required": [
"status"
]
},
{
"required": [
"validFrom"
]
},
{
"required": [
"validUntil"
]
},
{
"required": [
"updatedAt"
]
},
{
"required": [
"revision"
]
},
{
"required": [
"revokedAt"
]
},
{
"required": [
"delegationAllowed"
]
}
]
}
}
],
"allOf": [
{
"if": {
"properties": {
"granteeType": {
"const": "ename"
}
},
"required": [
"granteeType"
]
},
"then": {
"properties": {
"granteeEName": {
"type": "string",
"minLength": 1
}
}
}
},
{
"if": {
"properties": {
"granteeType": {
"const": "public"
}
},
"required": [
"granteeType"
]
},
"then": {
"properties": {
"granteeEName": {
"type": "null"
}
}
}
},
{
"if": {
"properties": {
"isReference": {
"const": false
},
"status": {
"const": "revoked"
}
},
"required": [
"isReference",
"status"
]
},
"then": {
"properties": {
"revokedAt": {
"type": "string",
"format": "date-time"
}
}
}
}
Comment on lines +241 to +264

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Revocation timestamp only validated one-way.

This conditional forces revokedAt to a date-time string when status == "revoked", but there's no complementary constraint forcing revokedAt to be null when status is "active". An active canonical grant could carry a stray non-null revokedAt, which is an inconsistent state.

♻️ Proposed fix: add an else branch
     {
       "if": {
         "properties": {
           "isReference": {
             "const": false
           },
           "status": {
             "const": "revoked"
           }
         },
         "required": [
           "isReference",
           "status"
         ]
       },
       "then": {
         "properties": {
           "revokedAt": {
             "type": "string",
             "format": "date-time"
           }
         }
+      },
+      "else": {
+        "properties": {
+          "revokedAt": {
+            "type": "null"
+          }
+        }
       }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
"if": {
"properties": {
"isReference": {
"const": false
},
"status": {
"const": "revoked"
}
},
"required": [
"isReference",
"status"
]
},
"then": {
"properties": {
"revokedAt": {
"type": "string",
"format": "date-time"
}
}
}
}
{
"if": {
"properties": {
"isReference": {
"const": false
},
"status": {
"const": "revoked"
}
},
"required": [
"isReference",
"status"
]
},
"then": {
"properties": {
"revokedAt": {
"type": "string",
"format": "date-time"
}
}
},
"else": {
"properties": {
"revokedAt": {
"type": "null"
}
}
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@services/ontology/schemas/accessGrant.json` around lines 241 - 264, Add a
complementary else branch to the conditional governing revokedAt for
non-reference grants: when status is "active", constrain revokedAt to null,
while preserving the existing date-time validation for revoked grants in the
conditional around isReference and status.

],
"additionalProperties": false
}
Loading
Loading