[Bug] Explicit ACL grant on a `restricted` asset is ineffective on the `acl/check` path — empty-ACL fast path short-circuits with `visibility_restricted` before lazy ACL loading
Summary
On MemoryCore 2.0.0-beta.1, granting a team member explicit read access to an asset with visibility=restricted (via acl/grant) has no effect on the acl/check path: the check still returns {allowed: false, reason: "visibility_restricted"}. The documented sharing model (private by default; grant specific users via acl/grant + visibility=restricted) is therefore not actually reachable for the check endpoint.
Source evidence
MemoryCore/src/metadata/service/metadata-service.ts, checkAssetPermission() (2.0.0-beta.1):
- :1511-1521 — the check first runs an empty-ACL fast path:
checkPermission({ ..., aclRecords: [] }), so role defaults can pass without a table lookup. - :1525 —
if (fast.reason !== "no_permission") return fast;— for arestrictedasset the fast path rejects withreason: "visibility_restricted", and this early return fires: avisibility_restrictedrejection is notno_permission, so the function returns here. - :1528 —
const aclRecords = await this.allAclRecords(params.asset_id);— the lazy ACL load that would surface the explicit grant is unreachable forrestrictedassets. - :1371 — the documented intent says the opposite: the code comment there states that to make an asset readable by a specific user/agent one should use
acl/grant+visibility=restricted.
Measured (standalone Gateway, node 22)
Repro sequence on the meta API: create owner + member (same team) + guest; owner creates an asset with visibility=restricted; owner issues acl/grant (action=read, grantee=member); then:
acl/checkas the member (the grantee):{allowed: false, reason: "visibility_restricted"}— expectedallowed: truevia the explicit grant.- Sanity checks around it behave correctly, isolating the bug to this path:
acl/checkas guest →{allowed: false, reason: "not_team_member"};visibility=teamasset + member →{allowed: true, reason: "role_default:member"}.
Suggested fix
Load the real ACL records for restricted visibility before the fast path can reject (e.g. pass a "may have grants" hint, or defer the fast-path early-return when asset.visibility === "restricted" and ACL records exist), so the lazy-load re-check becomes reachable for restricted assets. Regression test: grant on a restricted asset, then acl/check as grantee must return allowed: true while a non-grantee member stays denied.
Environment
Found during an integration spike against a throwaway copy of the TAM tree (product tree untouched; Gateway standalone, SQLite default). Happy to open a PR with a fix + regression test if that is preferred.
Source: TencentCloud/TencentDB-Agent-Memory