Skip to content

feat: review held sessionize events through the api - #5468

Merged
mbani01 merged 8 commits into
mainfrom
feat/issue-1158-sessionize-review-api
Nov 27, 2026
Merged

mbani01 merged 8 commits into
mainfrom
feat/issue-1158-sessionize-review-api

Conversation

@mbani01

@mbani01 mbani01 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What this adds

Third of four PRs for the review of held Sessionize events. It adds the internal, admin-only API behind the "Event mapping" page of the admin panel (the page is the next PR).

#5463, #5465 and #5467 are merged; this branch is rebased on main.

Refs linuxfoundation/lfx-cdp-insights-ops#1158

Endpoints

Route Permission What it does
GET /event-mapping eventMappingRead Lists held events and the events a person decided, with counts per state.
POST /event-mapping/confirm eventMappingEdit Confirms 1 to 200 events, each on a project. All or nothing in one transaction.
POST /event-mapping/ignore eventMappingEdit Ignores one event.
POST /event-mapping/restore eventMappingEdit Puts a decided event back on hold. Refused once the event started loading.

Both permissions are for the admin role only. Bodies are validated with Zod and validateOrThrow.

Behaviour

  • Suggestions are computed when the list is read. For each held event the handler calls suggestSessionizeMapping (from feat: keep nearby cvent events on held sessionize events #5463) on the stored evidence and resolves the suggested project against the active subprojects. Nothing about a suggestion is stored. A project that does not resolve to exactly one active subproject is shown as "project not in CDP".
  • Agreed name rules. The project alias rule now holds the name rules approved in the Credly template review and the Sched events review (KubeCon → CNCF, Open Source Summit and AI_dev → The Linux Foundation, GraphQLConf, Cephalocon, FinOps, Open Source in Finance Forum, RISC-V, Cloud Foundry, seL4, SODACON, OpenPOWER, next to the earlier PyTorch, SONiC, Jupyter and others). KubeCon is checked first. Each target is exactly one active project in production.
  • Fallback when a Cvent project is not in CDP. When the found Cvent event's project is not a CDP project, the name rule decides the suggestion. Production has 8 such events today (PyTorch and SONiC conferences), which now suggest PyTorch Project and SONiC Foundation.
  • Each row has one state: suggested, unresolved, confirmed or ignored. A confirmed row can be undone until the event has a sync unit.
  • Confirm stores the Cvent event with its source when the chosen project is the suggested one, and neither when the person picked another project.
  • Locks before reads. A confirm takes the per-event advisory locks first, in event key order, and reads the rows after that.
  • Conflicts. A decision on a row that is no longer in the expected state answers 409, and a bulk confirm rolls back completely.
  • Stored evidence is validated. A row whose evidence does not parse fails the request loudly; it is never shown with defaults.

Other changes

  • @crowd/connectors becomes a backend dependency for one pure module. Importing it loads suggestions.ts, matching.ts and nameSimilarity.ts only: no Snowflake, spreadsheet or HTTP code.
  • listActiveSubprojectsForMapping in the data-access layer returns the active subprojects with their project group name in one query.
  • The daily matching run now sorts its decisions by event key, so it takes the per-event locks in the same order as a bulk confirm.

Files that need a code owner

services/libs/data-access-layer/src/sessionize/index.ts, services/libs/data-access-layer/src/segments/index.ts, backend/package.json, pnpm-lock.yaml.

Deploy

No migration. Deploy the API and connectors-worker.

Tests

51 backend tests, 24 data-access-layer database tests, 311 connector tests and the worker tests pass. The database tests prove that a conflict on the third item of a bulk confirm rolls back the first two.

Known limits

  • The list is read from the read replica. A list fetched right after a decision can briefly show the old state; the page (next PR) applies the decision to its own rows.
  • A project that comes from the name-rule fallback keeps the label of the Cvent match it started from.
  • The list has no pagination. It holds about 100 rows today and grows by the events people decide.
  • A bulk confirm that includes an event Sessionize stopped listing that same day can deadlock with the daily run during its few seconds at 05:30 UTC. Postgres aborts one side, nothing is half-written, and a retry succeeds.

@mbani01
mbani01 requested review from a team and lfx-one as code owners November 27, 2026 16:11
Copilot AI balanced review requested due to automatic review settings November 27, 2026 16:11
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cursor

cursor Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Introduces transactional bulk writes and advisory locking on Sessionize mapping data with admin-only auth, but changes matching suggestion rules used in production review flows.

Overview
Adds admin-only REST APIs for reviewing held Sessionize events: list rows with live suggestions and state counts, bulk confirm (up to 200 per transaction), ignore, and restore until onboarding locks the row.

List reads held and decided events from the DB writer (not the replica) and builds each row with suggestSessionizeMapping plus active subproject resolution—states are suggested, unresolved, confirmed, or ignored, with optional Cvent/hint metadata and undo eligibility. Confirm validates bodies with Zod, takes per-event advisory locks in event-key order, checks segment IDs against listActiveSubprojectsForMapping, and persists catalogue event id/source only when the chosen segment matches the suggestion; conflicts roll back the whole batch.

Data layer gains batch confirm, locking, and subproject listing; the connectors worker now applies decisions in the same lock order. Suggestion rules expand project aliases (e.g. KubeCon→CNCF, Open Source Summit→TLF) and export aliasProjectSlug for the API layer. Backend wires @crowd/connectors and new eventMappingRead / eventMappingEdit permissions.

Reviewed by Cursor Bugbot for commit 131f6f0. Bugbot is set up for automated code reviews on this repo. Configure here.

@lfx-one

lfx-one commented Nov 27, 2026 •

Copy link
Copy Markdown

@mbani01 I'm starting review 1 of this pull request now (started 2026-11-27 16:11 UTC using review agent v0.1.34). This usually takes a few minutes. I'll update this comment with the summary when I'm done. If there's no summary here after about 45 minutes, the review stopped: push a new commit, or post a comment that begins with a mention of me followed by re-review, to start another. For help with the review agent, see https://github.com/linuxfoundation/lfx-review-agent/issues.


Hi Mouad BANI, thanks for the detailed description and the thorough tests.

Summary

This pull request adds the admin-only /event-mapping API to list, bulk-confirm, ignore and restore held Sessionize events. It also sorts the daily matching writes into the same lock order. The code is clean and well tested. The one concern is a small race between reading the evidence and taking the event locks in confirm.

Decision

✅ Approved with minor comments

🟡 1 minor

📝 Documentation gaps: none in this repository. See the reminder in Details.

Details

Overall impression: The change keeps to the repository's patterns: plain functions, the queryExecutor, and Zod with validateOrThrow. Both new permissions are admin-only, every handler checks its permission first, and the stored evidence is validated instead of defaulted. The new tests cover the 409 and 400 paths and the all-or-nothing rollback of a bulk confirm.

🟡 Minor: 1 issue: Confirmation derives the catalogue link from evidence read before the event locks are taken

Other reviewers and CI checks: Greptile and Copilot raised the same read-before-lock race. This review agrees and links it in the inline comment. No CI checks were visible on this commit at review time (the combined status was empty and pending). Branch protection and ruleset reads returned 403, so required checks could not be confirmed.

Unread files: pnpm-lock.yaml (generated or lockfile, not reviewed line by line)

Documentation reminder: changed GET /event-mapping, POST /event-mapping/confirm, POST /event-mapping/ignore, POST /event-mapping/restore, eventMappingRead, eventMappingEdit. Please check product pages and external docs; the author and maintainers own those updates.

Rule files: read AGENTS.md, .claude/rules/commit-workflow.md, .claude/rules/skill-guidance.md; skipped CONTRIBUTING.md (not read), .claude/rules/adr-format.md (read but it only applies to docs/adr/)

Questions, problems, or feedback: https://github.com/linuxfoundation/lfx-review-agent/issues

@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no new actionable issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

Adds admin-only APIs to list, confirm, ignore, and restore held Sessionize events.

  • The event-mapping list shows live suggestions and review states for held Sessionize events.
  • Admins can confirm a batch of Sessionize events with one project choice per event.
  • Admins can ignore held events and restore decisions through separate API actions.
  • Bulk reviews and daily matching now lock Sessionize events in the same key order.

Both supplied previous findings are fixed. Neither thread has a supplied comment number.

Reviews (5) · Last reviewed commit: "fix: connect the event mapping endpoints..." · Reviewed by Greptile

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.

🟡 Changes recommended

Confirmation reads evidence before acquiring per-event locks, allowing a concurrent matcher refresh to pair stale catalogue suggestions with new evidence and confirm a project that is no longer suggested.

1 open issue
1 file not reviewed
  • pnpm-lock.yaml: Generated file
What changed in this PR

Adds the admin-only API for reviewing held Sessionize events, building on the existing suggestion and decision-storage layers to support the upcoming Event mapping page.

Changes:

  • Adds list, bulk confirm, ignore, and restore endpoints with permission checks and request validation.
  • Resolves suggestions against active subprojects and returns review states and counts.
  • Adds transactional bulk confirmation, consistent event-key lock ordering, and supporting tests.
File Description
services/​libs/​data-access-layer/​src/​sessionize/​index.ts Adds bulk confirmation and shared event-key ordering.
services/​libs/​data-access-layer/​src/​sessionize/​index.test.ts Tests bulk rollback, duplicates, and subproject lookup.
services/​libs/​data-access-layer/​src/​segments/​index.ts Lists active subprojects with group names.
services/​apps/​connectors_worker/​src/​sessionizeEventMatching.ts Sorts daily decisions by event key.
services/​apps/​connectors_worker/​src/​sessionizeEventMatching.test.ts Verifies decision write ordering.
pnpm-lock.yaml Records the backend connectors dependency.
backend/​tsconfig.check.json Adds the connectors project reference.
backend/​src/​security/​permissions.ts Defines admin-only review permissions.
backend/​src/​api/​index.ts Registers Event mapping routes.
backend/​src/​api/​eventMapping/​reviewRows.ts Validates evidence and builds resolved review rows.
backend/​src/​api/​eventMapping/​reviewRows.test.ts Tests suggestions, states, counts, and malformed evidence.
backend/​src/​api/​eventMapping/​index.ts Wires the four review endpoints.
backend/​src/​api/​eventMapping/​eventSchema.ts Defines shared event-reference validation.
backend/​src/​api/​eventMapping/​eventMappingRestore.ts Restores eligible decisions to held status.
backend/​src/​api/​eventMapping/​eventMappingRestore.test.ts Tests restore validation and permissions.
backend/​src/​api/​eventMapping/​eventMappingList.ts Returns review rows and state counts.
backend/​src/​api/​eventMapping/​eventMappingList.test.ts Tests list responses and access checks.
backend/​src/​api/​eventMapping/​eventMappingIgnore.ts Records ignore decisions as the current user.
backend/​src/​api/​eventMapping/​eventMappingIgnore.test.ts Tests ignore validation and permissions.
backend/​src/​api/​eventMapping/​eventMappingConfirm.ts Validates and confirms batches with catalogue suggestions.
backend/​src/​api/​eventMapping/​eventMappingConfirm.test.ts Tests confirmation inputs, conflicts, and permissions.
backend/​src/​api/​eventMapping/​eventMapping.fixture.ts Provides shared handler-test fixtures.
backend/​package.json Adds the connectors workspace dependency.

Review effort: Balanced

@lfx-one lfx-one left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved with one minor comment: the confirm handler reads the evidence before it takes the per-event locks (details inline). No blocking, security or privacy findings.

Documentation

This pull request changes behavior that may also be described outside this repository, such as product pages or an external docs site. I can't read those, so please check them; the author and maintainers own those updates. Changed here:

  • GET /event-mapping (new route)
  • POST /event-mapping/confirm (new route)
  • POST /event-mapping/ignore (new route)
  • POST /event-mapping/restore (new route)
  • eventMappingRead and eventMappingEdit (new admin-only permissions)

Copilot AI balanced review requested due to automatic review settings November 27, 2026 16:38
@lfx-one

lfx-one commented Nov 27, 2026 •

Copy link
Copy Markdown

@mbani01 I'm starting review 2 of this pull request now (started 2026-11-27 16:38 UTC using review agent v0.1.34). This usually takes a few minutes. I'll update this comment with the summary when I'm done. If there's no summary here after about 45 minutes, the review stopped: push a new commit, or post a comment that begins with a mention of me followed by re-review, to start another. For help with the review agent, see https://github.com/linuxfoundation/lfx-review-agent/issues.


Hi Mouad BANI, thanks for fixing the lock-order race so quickly and for adding tests that prove it.

Summary

These two new commits take the per-event locks before the confirm handler reads the evidence. They also add the agreed project name rules and a fallback to the name rule when a Cvent event's project is not in CDP. The code is clean and well tested, and I found no new problems.

Decision

✅ Approved

Details

Overall impression: The fix for the read-before-lock race is the right one. lockSessionizeEventMappings sorts the keys with the same comparison as the bulk confirm and the daily run, so all three take locks in one order. The handler test checks that the lock call comes before both reads. The data-access-layer test shows a concurrent decision waiting on the lock until the transaction ends. The name rules are exported through aliasProjectSlug, which also gets the length cap that suggestSessionizeMapping already used. The fallback in reviewRows.ts uses the same function for the row list and for the catalogue link stored on confirm, so what an admin sees matches what is saved. An ambiguous hold now shows its Cvent hint event, and its tests check that it stays unresolved.

👏 Nice work: You took the read-before-lock fix to the root by locking first, and you added a test that proves the ordering instead of just asserting it. Adding the PR description's "Locks before reads" note also helps the next reader.

✅ Resolved: Confirmation derived the catalogue link from evidence read before the event locks were taken. It is fixed in e36c5ef: the locks are now taken first, in key order, and the rows are read after that in the same transaction. Greptile and Copilot raised the same point, and the author replied on each thread.

Other reviewers and CI checks: Greptile and Copilot raised only the lock-order issue, and it is now resolved. No CI checks were visible on this commit at review time: the combined status was empty and pending. Branch protection and ruleset reads returned 403, so required checks could not be confirmed.

Unread files: pnpm-lock.yaml (generated or lockfile, not reviewed line by line)

Documentation reminder: changed PROJECT_ALIASES name rules. Please check product pages and external docs; the author and maintainers own those updates.

Rule files: read AGENTS.md; skipped .claude/rules/commit-workflow.md, .claude/rules/skill-guidance.md, .claude/rules/adr-format.md (not read this round), CONTRIBUTING.md (not read)

Questions, problems, or feedback: https://github.com/linuxfoundation/lfx-review-agent/issues

lfx-one
lfx-one previously approved these changes Nov 27, 2026

@lfx-one lfx-one left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved. The read-before-lock race from review 1 is fixed: the confirm handler now takes the sorted per-event locks before it reads the evidence, with tests for the order and for a concurrent decision waiting on the lock. The new name rules and the name-rule fallback add no blocking, minor, security or privacy findings.

Documentation

This pull request changes behavior that may also be described outside this repository, such as product pages or an external docs site. I can't read those, so please check them; the author and maintainers own those updates. Changed here:

  • PROJECT_ALIASES name rules (new project alias rules, and a fallback to the name rule when a Cvent event's project is not in CDP)

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.

🟡 Changes recommended

The alias fallback treats ambiguous Cvent project matches as missing, allowing an incorrect project suggestion and catalogue link to be stored on confirmation.

1 open issue
1 resolved since last review
1 file not reviewed
  • pnpm-lock.yaml: Generated file

Review effort: Balanced

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e36c5ef. Configure here.

@mbani01
mbani01 force-pushed the feat/issue-1158-sessionize-review-decisions branch 2 times, most recently from 02a724b to 4330a04 Compare November 27, 2026 16:49
Base automatically changed from feat/issue-1158-sessionize-review-decisions to main November 27, 2026 16:49
@mbani01
mbani01 dismissed lfx-one’s stale review November 27, 2026 16:49

The base branch was changed.

@mbani01 mbani01 self-assigned this Nov 27, 2026
Confirming passes the suggested event's catalogue source with its Cvent id, an empty
project or source id no longer resolves to a subproject, and a bulk confirmation
rejects duplicate events and sorts them with a proper comparison.

Refs linuxfoundation/lfx-cdp-insights-ops#1158

Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
@mbani01
mbani01 force-pushed the feat/issue-1158-sessionize-review-api branch from e36c5ef to a8ce642 Compare November 27, 2026 16:54
Copilot AI balanced review requested due to automatic review settings November 27, 2026 16:54
Comment thread backend/package.json
@lfx-one

lfx-one commented Nov 27, 2026 •

Copy link
Copy Markdown

@mbani01 I'm starting review 3 of this pull request now (started 2026-11-27 16:54 UTC using review agent v0.1.34). This usually takes a few minutes. I'll update this comment with the summary when I'm done. If there's no summary here after about 45 minutes, the review stopped: push a new commit, or post a comment that begins with a mention of me followed by re-review, to start another. For help with the review agent, see https://github.com/linuxfoundation/lfx-review-agent/issues.


Hi Mouad BANI, thanks for rebasing onto main after the earlier PRs merged.

Summary

This push rebased the branch onto main after #5463, #5465 and #5467 merged, so the diff now holds only the review API, its tests and the supporting data-access changes. The code is clean and well tested, and I found no new problems.

Decision

✅ Approved

Details

Overall impression: The rebase rewrote history, so e36c5ef is no longer in the PR and I reviewed the whole diff again, not only the new commits. The confirm handler still takes the sorted per-event locks before it reads the evidence, and lockSessionizeEventMappings uses the same advisory-lock key and the same sort as upsertSessionizeEventDecision, applyReviewUpdate and the daily run. The handlers check their permission first and validate bodies with Zod and validateOrThrow. The tests cover the 400 and 409 paths and the all-or-nothing rollback of a bulk confirm.

✅ Resolved: Confirmation derived the catalogue link from evidence read before the event locks were taken (finding r1-f1). The locks now come first, so the stored link comes from the evidence the confirm actually updates.

Other reviewers and CI checks: Copilot's alias-fallback comment is marked resolved on its side, and you replied on it. I agree that the case needs two active subprojects with one source id, and it only produces a suggestion that a person still confirms. Copilot's new comment asks for pg-promise connections instead of SequelizeRepository.getQueryExecutor. That helper returns the queryExecutor the repository rules ask for, and the other /api handlers use it the same way, so I did not raise it. The required check DCO passed on a8ce642. Combined commit statuses were empty.

Unread files: pnpm-lock.yaml (generated or lockfile, not reviewed line by line)

Documentation reminder: no new items. Changed behaviors were named in my earlier reminders.

Rule files: read AGENTS.md, .claude/rules/commit-workflow.md, .claude/rules/skill-guidance.md, .claude/rules/adr-format.md, CONTRIBUTING.md; skipped none

Questions, problems, or feedback: https://github.com/linuxfoundation/lfx-review-agent/issues

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.

🟡 Changes recommended

The new event-mapping endpoints extend the prohibited legacy Sequelize database path and need the prescribed connection executors while preserving the confirmation transaction.

1 open issue
1 resolved since last review
1 file not reviewed
  • pnpm-lock.yaml: Generated file

Review effort: Balanced

lfx-one
lfx-one previously approved these changes Nov 27, 2026

@lfx-one lfx-one left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved. The branch was rebased onto main after #5463, #5465 and #5467 merged, so I reviewed the whole diff again. The earlier lock-before-read fix is still in place, and I found no blocking, minor, security or privacy findings.

Copilot AI balanced review requested due to automatic review settings November 27, 2026 17:06
@lfx-one

lfx-one commented Nov 27, 2026

Copy link
Copy Markdown

@mbani01 A recent review was posted within the last 5 minutes: #5468 (comment). I won't re-review yet. Push another update after 5 minutes if you want another pass.

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.

🔵 Needs a closer look

The acknowledged deadlock window between bulk confirmation and daily matching/deactivation warrants a DAL/worker code owner’s review of production contention and retry behavior.

No open issues 🎉

1 resolved since last review
1 file not reviewed
  • pnpm-lock.yaml: Generated file

Review effort: Balanced

The writer config now follows the backend's own credential choice:
the shared user when it is set, else the api user.

Refs linuxfoundation/lfx-cdp-insights-ops#1158

Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 17:10

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.

🔵 Needs a closer look

A code owner needs to assess the shared Sessionize DAL transaction and locking changes and accept the documented deadlock window between bulk confirmation and daily deactivation, as PostgreSQL runtime validation was not performed.

No open issues 🎉

1 file not reviewed
  • pnpm-lock.yaml: Generated file

Review effort: Balanced

@mbani01
mbani01 merged commit 9eb2a71 into main Nov 27, 2026
19 checks passed
@mbani01
mbani01 deleted the feat/issue-1158-sessionize-review-api branch November 27, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants