[4.0.6 Backport] CBG 5394: Document Channel HIstory compaction#8326
Merged
Conversation
Redocly previews |
Contributor
There was a problem hiding this comment.
Pull request overview
Backports “document channel history compaction” into the 4.0.6 line by adding admin endpoints to inspect per-document channel revocation history and to compact (prune) historical channel membership metadata for a document.
Changes:
- Adds admin REST routes and handlers for
GET /{keyspace}/_channel_history/{docid}andPOST /{keyspace}/_channel_history/{docid}/compact. - Implements
GetDocChannelHistoryandCompactDocChannelHistoryondb.DatabaseCollection, including an audit event for compaction. - Adds unit tests for the new behavior and updates the Admin OpenAPI spec to document the new endpoints.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| rest/routing.go | Registers the two new admin keyspace routes for channel history retrieval and compaction. |
| rest/doc_api.go | Implements REST handlers, request parsing/validation, and auditing for the new endpoints. |
| rest/audit_test.go | Adds audit-logging coverage for the new compaction audit event. |
| rest/api_test.go | Adds functional tests for compaction and history retrieval, including REST endpoint coverage. |
| docs/api/paths/admin/keyspace-_channel_history.yaml | New OpenAPI path spec for channel history retrieval. |
| docs/api/paths/admin/keyspace-_channel_history-compact.yaml | New OpenAPI path spec for channel history compaction. |
| docs/api/admin.yaml | Wires the new path specs into the Admin OpenAPI root. |
| db/crud.go | Adds data-layer implementations for computing history and compacting stored metadata. |
| base/audit_events.go | Introduces a new audit event ID and descriptor for “document channel history compact”. |
| base/audit_events_fields.go | Adds a new audit field constant for the compaction sequence. |
Comments suppressed due to low confidence (1)
docs/api/paths/admin/keyspace-_channel_history-compact.yaml:75
- This spec references
../../components/responses.yaml#/Unauthorized-database, but that response doesn’t exist in components/responses.yaml. Also, the endpoint can return 404 for a missing document (covered by tests), but 404 isn’t documented, and the operationId doesn’t match the path.
'403':
$ref: ../../components/responses.yaml#/Unauthorized-database
tags:
- Document
operationId: post_keyspace-_history-compact
Comment on lines
+311
to
+313
| if doc == nil { | ||
| return nil, fmt.Errorf("skipping compaction of document %s, %v ", base.UD(docid), base.ErrNotFound) | ||
| } |
Comment on lines
+48
to
+62
| schema: | ||
| type: object | ||
| additionalProperties: | ||
| x-additionalPropertiesName: doc_id | ||
| type: array | ||
| items: | ||
| type: string | ||
| description: |- | ||
| Array of channel names that were compacted. | ||
| description: |- | ||
| A array of all the compacted channels | ||
| example: | ||
| compacted_channels: | ||
| - channel1 | ||
| - channel2 |
Comment on lines
+35
to
+44
| schema: | ||
| type: object | ||
| additionalProperties: | ||
| type: array | ||
| items: | ||
| type: integer | ||
| format: int64 | ||
| minimum: 1 | ||
| description: Sequences at which the document was removed from this channel. | ||
| description: Map of channel names to their revocation sequences. |
Comment on lines
+972
to
+974
| if req.Seq == 0 { | ||
| return base.HTTPErrorf(http.StatusBadRequest, "missing seq") | ||
| } |
Comment on lines
+283
to
+291
| func (c *DatabaseCollection) CompactDocChannelHistory(ctx context.Context, docid string, seq uint64) ([]string, error) { | ||
| key := realDocID(docid) | ||
| if key == "" { | ||
| return nil, base.HTTPErrorf(400, "Invalid doc ID") | ||
| } | ||
|
|
||
| rawDoc, xattrs, cas, err := c.dataStore.GetWithXattrs(ctx, key, c.syncGlobalSyncMouRevSeqNoAndUserXattrKeys()) | ||
| if err != nil { | ||
| return nil, err |
Comment on lines
+51
to
+59
| '404': | ||
| description: Document not found. | ||
| content: | ||
| application/json: | ||
| schema: | ||
| $ref: ../../components/schemas.yaml#/HTTP-Error | ||
| '403': | ||
| $ref: ../../components/responses.yaml#/Unauthorized-database | ||
|
|
adamcfraser
previously approved these changes
Jun 4, 2026
adamcfraser
left a comment
Collaborator
There was a problem hiding this comment.
Backport looks good - needs a rebase on user history changes.
…8276) # Conflicts: # rest/audit_test.go
adamcfraser
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CBG-5394
Describe your PR here...
Pre-review checklist
fmt.Print,log.Print, ...)base.UD(docID),base.MD(dbName))docs/apiDependencies (if applicable)
Integration Tests