mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 14:08:21 +00:00
* feat: Audit Resource ACL Changes and Fail Closed by Default * fix: Keep Non-Reversible Admin Audit Handlers Fail-Open * docs: Narrow AUDIT_LOG_FAIL_CLOSED Description * fix: Audit and Restore ACL and Insights Changes in One Pass * fix: Break Audit and Insights Permission Type Cycle * test: Cover Resource ACL Audit Scenarios * refactor: Audit Resource Permission Changes Before Writing * test: Align Concurrent Revoke Audit Expectation * fix: Skip Deleting ACL Entries That Were Not Audited * fix: Read ACL Snapshots Through the Write Session * fix: Never Block Revocations on Audit Outages and Normalize Principal Keys * fix: Let an Explicit Public Disable Win Over a Public Update * fix: Audit Duplicate ACL Rows as Combined Permissions * fix: Audit Permission Changes Under One Target and Dedupe Revokes * fix: Audit Capability Grants Before Writing Them * feat: Serialize Resource Permission Updates With a Per-Resource Lease * fix: Fence the Resource Lease Before Writes and Always Audit Grant Assignments * fix: Renew the Resource Lease Before Each ACL Write Phase * fix: Serialize System Grant Assignment and Revocation With a Per-Grant Lease * fix: Keep Leases Alive During Audits, Bound Lock Index Wait, Canonicalize Audit Target IDs * fix: Retry Deferred Revoke Audits Under the Lease and Audit Canonical Principal and Role IDs * test: Expect Role IDs in Permission Audit Metadata * fix: Read Mutation Snapshots From the Primary Outside Transactions * fix: Flush Deferred Audits Before Cache Invalidation, Keep Renewals Monotonic, Keep Role Case in Grant Lease Keys * refactor: Map the Busy Permission Error to Its Code in the API Package * style: Sort Lease Imports and Type the Renewal Spec Read * fix: Keep Success Audits After Commit, Report Downgrades as Revocations, Code Audit Outages * refactor: Move the Audit Outage Code to Its Own Module * fix: Translate Lock Failures, Lease Non-Transactional Sessions, and Code Grant Audit Outages * fix: Sanitize Lease Renewal Failures at the Permission Boundary * fix: Annotate the Unavailable Error Code for Isolated Declarations * fix: Keep the Admin Route Fail-Closed Opt-In and Document Lease Clock Skew Safety * fix: Translate Grant Lease Store Failures to a Retryable 503 * fix: Log Failed Grant Audit Writes With Safe Metadata Only * test: Detect Raw Error Arguments in the Grant Audit Log Spec * feat: Make Permission Lease Limits Configurable and Localize Retryable Sharing Failures * fix: Bound Lock Index Readiness by the Lease Wait and Carry the Resource ID in Every Audit Entry * test: Cover Lease Config Reaching the Leases and the Sharing Dialog Failure Messages * fix: Load App Config on the Sharing and Grant Routes and Log Failed Lease Releases * perf: Load App Config Only on the Grant Mutation Routes
61 lines
3.6 KiB
Markdown
61 lines
3.6 KiB
Markdown
# ACL write compatibility
|
|
|
|
Role-only sharing preserves independently administered permission bits while updating role bits,
|
|
roleId, grantedBy and grantedAt in one conditional document update. The persistence layer also uses
|
|
that same mutation operation for add/remove bit requests. Removing a bit wins if it appears in both
|
|
masks. Neither path uses MongoDB bit-update operators.
|
|
|
|
## Deployment configuration
|
|
|
|
```yaml
|
|
permissions:
|
|
maxWriteAttempts: 3
|
|
leaseTtlMs: 30000
|
|
leaseWaitMs: 3000
|
|
```
|
|
|
|
`leaseTtlMs` (1000 to 600000) and `leaseWaitMs` (0 to 60000) apply only where transactions are
|
|
unavailable: sharing updates and system grant changes then take a per-resource or per-grant lease,
|
|
renewed while the update runs, and answer 409 when it stays contended past `leaseWaitMs`. The lease only
|
|
coordinates instances that run this version, so during a rolling upgrade of a deployment without
|
|
transactions an older instance can still write without it; finish the upgrade before relying on the
|
|
ordering between audit entries and ACL writes.
|
|
|
|
The sharing endpoint passes this setting to the persistence operation. The value must be an integer
|
|
from 1 through 100, including the initial attempt. Internal callers can override the same validated
|
|
budget per call. A session alone does not imply a transaction: comparison reads use primary unless
|
|
an active transaction owns the read preference.
|
|
|
|
## Concurrency and failures
|
|
|
|
Each observed ACL document is its own unit of completion. A conditional write checks the snapshot's
|
|
bits and role/audit metadata. Only a definite no-match retries that document. Already completed
|
|
documents are never replayed because a different document conflicts. Duplicate ACL documents are
|
|
processed individually and keep their own independent bits; this change does not deduplicate them
|
|
or add a uniqueness constraint.
|
|
|
|
If an observed ACL is deleted during mutation, the request fails rather than recreating that grant.
|
|
A missing principal at the initial read can still be granted access. If another writer inserts it
|
|
first, the operation reads and updates that entry instead of treating a no-op upsert as success.
|
|
Concurrent inserts can still create duplicate identities without a unique index; each completed
|
|
write is atomic, but the entire resource is not serialized.
|
|
|
|
Standalone deployments do not get batch atomicity. If a later document fails, earlier writes can
|
|
remain committed. Errors include completedEntries (acknowledged writes before failure) and whether
|
|
an active transaction was present. This count does not settle ambiguous network failures or prove a
|
|
transaction committed. MongoDB error labels are retained for the transaction owner's handling.
|
|
No automatic retry is performed for ambiguous write errors or transaction write-conflict errors.
|
|
|
|
## Upgrading
|
|
|
|
No data migration, collection reset, or permission reset is required. Missing legacy permBits
|
|
fields are interpreted as zero. Nonnegative 31-bit integers preserve bits outside the known enum.
|
|
Null, fractional, negative, or larger values fail explicitly instead of being truncated. Investigate
|
|
those rows against authoritative role and audit records; do not blanket-reset grants.
|
|
|
|
Old binaries do not gain these safeguards during a rolling upgrade. Drain old writers before relying
|
|
on the new behavior. Storage remains unchanged, but rolling back also restores the old implementation's
|
|
limitations. A separate Insights field and any associated migration are not part of these PRs.
|
|
|
|
MongoDB-backed tests cover the update contract. Live DocumentDB and Cosmos DB compatibility has not
|
|
been certified by this change; the original reported engine/version restriction remains unverified.
|