Repository navigation
perf: reduce duplicate push audit storage #1795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dcoric
wants to merge
23
commits into
finos:main
Choose a base branch
from
dcoric:perf/push-storage-rollups
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+880
−99
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
cbf8554
fix(proxy): avoid duplicating diffs in audit logs
dcoric cc6e851
perf(db): return consistent metadata-only push lists
dcoric 627577f
test(e2e): verify compact push audits through approval
dcoric c33df0f
docs: explain diff storage and push list responses
dcoric 4134790
perf(db): store repeated final audit steps once
dcoric e341b9e
perf(db): update file repository rollups on push changes
dcoric f7952a2
perf(db): refresh MongoDB activity for changed repositories
dcoric 6f7c8c8
test(db): cover rollup recovery and report integration coverage
dcoric 425d44a
docs: describe push storage and activity rollup recovery
dcoric 25a27e1
fix(ui): refresh activity after review decisions
dcoric c63f0e9
fix(ui): parse serialized review timestamps
dcoric 044a561
test(db): cover file activity initialization recovery
dcoric 773cc10
test(db): cover MongoDB activity recovery and deletion races
dcoric 77de4d9
chore: merge main with the PostgreSQL sink
dcoric cf021fe
refactor: separate repository activity from audit storage
dcoric c1746a7
perf(db): compact PostgreSQL push audits and list responses
dcoric d6f44ab
fix(db): preserve MongoDB unset literal types
dcoric ea52907
chore: merge main and retain PostgreSQL coverage
dcoric a47440c
fix(db): trim push summary metadata
dcoric a1ee202
chore: merge main and reconcile diff storage
dcoric 0c62621
chore: merge finos/main into perf/push-storage-rollups
dcoric 2fa28bf
docs(db): explain compactPush and restorePush
dcoric dc5b5bf
chore: merge finos/main into perf/push-storage-rollups
dcoric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /** | ||
| * Copyright 2026 GitProxy Contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import type { Action } from '../proxy/actions'; | ||
|
|
||
| /** | ||
| * List and profile responses contain metadata only. Keep every diff representation | ||
| * (steps, lastStep, and the top-level diff) out of this allowlist. | ||
| * Detail reads and audit writes retain the complete record. | ||
| */ | ||
| export const pushListProjection = { | ||
| _id: 0, | ||
| actionType: 1, | ||
| allowPush: 1, | ||
| attestation: 1, | ||
| authorised: 1, | ||
| autoApproved: 1, | ||
| autoRejected: 1, | ||
| blocked: 1, | ||
| blockedMessage: 1, | ||
| branch: 1, | ||
| canceled: 1, | ||
| commitData: 1, | ||
| commitFrom: 1, | ||
| commitTo: 1, | ||
| error: 1, | ||
| id: 1, | ||
| legacyId: 1, | ||
| method: 1, | ||
| project: 1, | ||
| pusherVerified: 1, | ||
| rejected: 1, | ||
| rejection: 1, | ||
| repo: 1, | ||
| repoName: 1, | ||
| tagData: 1, | ||
| tags: 1, | ||
| timestamp: 1, | ||
| type: 1, | ||
| url: 1, | ||
| user: 1, | ||
| userEmail: 1, | ||
| } as const satisfies Partial<Record<keyof Action | '_id', 0 | 1>>; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /** | ||
| * Copyright 2026 GitProxy Contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import { isEqual } from 'lodash'; | ||
| import { Action } from '../proxy/actions'; | ||
| import { toClass } from './helper'; | ||
|
|
||
| // Internal storage markers that may exist on persisted records but must never | ||
| // reach callers of the database layer. | ||
| type StoredPush = Action & { _lastStepIndex?: number; _activity?: unknown }; | ||
|
|
||
| /** | ||
| * Prepares a push for storage. Works on a shallow copy, so the caller's Action | ||
| * is not modified. Any internal markers already on the input are dropped | ||
| * first. When `lastStep` is identical to the final entry in `steps`, the | ||
| * duplicate copy is replaced with `_lastStepIndex`, a reference to that entry. | ||
| * A `lastStep` that differs from the final step is stored as-is. | ||
| */ | ||
| export const compactPush = (action: Action) => { | ||
| const stored: Partial<StoredPush> = { ...action }; | ||
| delete stored._lastStepIndex; | ||
| delete stored._activity; | ||
| const index = action.steps?.length - 1; | ||
| if (action.lastStep && index >= 0 && isEqual(action.lastStep, action.steps[index])) { | ||
| stored._lastStepIndex = index; | ||
| delete stored.lastStep; | ||
| } | ||
| return stored; | ||
| }; | ||
|
|
||
| /** | ||
| * Reverses compactPush when reading a stored record back into an Action. If | ||
| * the record holds a valid `_lastStepIndex` and no `lastStep`, `lastStep` is | ||
| * rebuilt from that entry in `steps`. Records that store `lastStep` directly | ||
| * (a distinct last step, or historical records) keep it as stored. Internal | ||
| * markers are always removed from the returned Action. | ||
| */ | ||
| export const restorePush = (doc: unknown): Action => { | ||
| const action: StoredPush = toClass(doc, Action.prototype); | ||
| const index = action._lastStepIndex; | ||
| if (index !== undefined && Number.isInteger(index) && index >= 0 && !action.lastStep) { | ||
| action.lastStep = action.steps?.[index]; | ||
| } | ||
| delete action._lastStepIndex; | ||
| delete action._activity; | ||
| return action; | ||
| }; | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Copyright 2026 GitProxy Contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| import * as pushes from '../../../src/db/file/pushes'; | ||
| import { definePushStorageContract } from '../pushStorage.contract'; | ||
|
|
||
| definePushStorageContract('NeDB push storage', pushes, (id) => pushes.db.findOneAsync({ id })); |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.