Skip to content

[4.0.6 Backport] CBG 5394: Document Channel HIstory compaction#8326

Merged
adamcfraser merged 7 commits into
release/4.0.6from
CBG-5394
Jun 5, 2026
Merged

[4.0.6 Backport] CBG 5394: Document Channel HIstory compaction#8326
adamcfraser merged 7 commits into
release/4.0.6from
CBG-5394

Conversation

@RIT3shSapata

@RIT3shSapata RIT3shSapata commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

CBG-5394

Describe your PR here...

  • Backport of Document Channel History compaction

Pre-review checklist

  • Removed debug logging (fmt.Print, log.Print, ...)
  • Logging sensitive data? Make sure it's tagged (e.g. base.UD(docID), base.MD(dbName))
  • Updated relevant information in the API specifications (such as endpoint descriptions, schemas, ...) in docs/api

Dependencies (if applicable)

  • Link upstream PRs
  • Update Go module dependencies when merged

Integration Tests

@RIT3shSapata RIT3shSapata self-assigned this Jun 2, 2026
Copilot AI review requested due to automatic review settings June 2, 2026 13:24
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

Redocly previews

Copilot AI left a comment

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.

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} and POST /{keyspace}/_channel_history/{docid}/compact.
  • Implements GetDocChannelHistory and CompactDocChannelHistory on db.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 thread db/crud.go
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 thread rest/doc_api.go
Comment on lines +972 to +974
if req.Seq == 0 {
return base.HTTPErrorf(http.StatusBadRequest, "missing seq")
}
Comment thread db/crud.go
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
adamcfraser previously approved these changes Jun 4, 2026

@adamcfraser adamcfraser left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backport looks good - needs a rebase on user history changes.

Comment thread .factory/settings.json Outdated
@adamcfraser adamcfraser merged commit eb5f6ab into release/4.0.6 Jun 5, 2026
47 checks passed
@adamcfraser adamcfraser deleted the CBG-5394 branch June 5, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants