Skip to content

feat: connect report-result stats review flow (rebased onto main) - #96

Merged
diese-tech merged 4 commits into
mainfrom
claude/report-match-commands-ready-p317uz
Aug 31, 2026
Merged

feat: connect report-result stats review flow (rebased onto main)#96
diese-tech merged 4 commits into
mainfrom
claude/report-match-commands-ready-p317uz

Conversation

@diese-tech

Copy link
Copy Markdown
Owner

What

Carries the full contents of #90 and merges current main into it, resolving the six conflicts that accumulated after the trade workflow (#94) and scoped roster roles / drops (#95) landed.

Functionally this is #90/report-result atomically creates/recovers the pending result and match report, authorizes the host review link through a dedicated enter-match-stats capability, mirrors host-submitted screenshots, and posts the admin stats-review link idempotently. This PR adds no new behavior of its own beyond the conflict resolution.

This supersedes #90, which is stuck at mergeable_state: dirty. Close #90 in favor of this branch, or cherry-pick the merge commit onto it — whichever you prefer.

Conflict resolutions

All six were union-style; no behavior from either side was dropped.

File Resolution
apps/bot/src/index.ts Kept main's help: / tr_ / dr_ / trade: button routes, added mr_stats: ahead of sc_up:. No prefix collisions.
lib/command-access.ts OperationalCapability is now the union of both sides — trade from main, enter-match-stats from #90. Kept the SAL_MATCH_STATS_ROLE_IDS override and its fail-closed validation.
lib/command-access.test.ts Kept both sides' assertions in the admin-override test, plus #90's three match-stats capability tests.
lib/outbox-projections.ts Unioned the discord.js and channels imports; match_report review rows route to projectSubmittedMatchReport ahead of the legacy pending_stat_record branch. Dropped #90's duplicate messageHasMarker helper — main independently added an identical one for the trade/drop projections, so callers now share one definition.
packages/db/src/queries/index.ts Export match-reports alongside main's roster-trades, roster-drops, roster-role-mappings.
docs/commands.md Took main's fuller command table, applied #90's updated /report-result description.

Notes for review

Dependencies and rollout

  • Still depends on feat(stats): add host match-report review flow sal-site#262 (host match-report review page and the internal host-token route this branch calls). Merge and deploy #262 first — this branch's issueMatchReportHostReviewLink posts to /api/internal/match-reports/[id]/host-token, which only exists there. Note #262's contract lock is still at db-v1.17.0 and needs refreshing to db-v1.20.0.
  • Configure SAL_SITE_URL and SAL_SITE_INTERNAL_TOKEN (matching sal-site's INTERNAL_SERVICE_TOKEN).
  • Optionally configure SAL_MATCH_STATS_ROLE_IDS for a narrower stats-entry role; unset falls back to the operator allowlist, and admins always retain access.

No bot deployment or production write was performed from this branch.

Verification

Run against the merge result, not either parent:

  • pnpm typecheck — 5/5 tasks
  • pnpm test — 182 passing (144 bot including the 7 report-result-stats tests, 31 db, 7 shared)
  • pnpm lint — 3/3
  • pnpm build — 3/3
  • pnpm check:db-contract — verified diese-tech/sal-database db-v1.20.0 (20260823130000)

Full Discord → deployed site → database verification still requires #262 deployed and the secrets above set.


Generated by Claude Code

diese-tech and others added 3 commits August 18, 2026 23:52
Resolves the six conflicts that accumulated after the trade (#94) and
scoped roster roles / drops (#95) work landed on main.

Resolutions, all union-style — no behavior from either side dropped:

- apps/bot/src/index.ts: keep main's help/tr_/dr_/trade: button routes and
  add the mr_stats: route ahead of sc_up:. No prefix collisions.
- lib/command-access.ts: OperationalCapability becomes the union of both
  sides ('trade' from main, 'enter-match-stats' from this branch). The
  SAL_MATCH_STATS_ROLE_IDS override and its fail-closed validation are kept.
- lib/command-access.test.ts: keep both sides' assertions in the admin
  override test, plus the three match-stats capability tests.
- lib/outbox-projections.ts: union the discord.js and channels imports;
  route match_report review rows to projectSubmittedMatchReport ahead of
  the legacy pending_stat_record branch. Dropped this branch's duplicate
  messageHasMarker helper — main introduced an identical one for the trade
  and drop projections, so the callers now share that single definition.
- packages/db/src/queries/index.ts: export match-reports alongside main's
  roster-trades, roster-drops, and roster-role-mappings.
- docs/commands.md: take main's fuller command table and apply this
  branch's updated /report-result description.

Note for review: hasCommandAccess now runs validateCommandAccessEnv on
every call, so a malformed (optional) SAL_MATCH_STATS_ROLE_IDS fails
closed for /report-result and /log-scouter, not just the stats button.
That is this branch's intended fail-closed posture; leaving the variable
unset keeps the operator-allowlist fallback.

Verification on the merge result:
- pnpm typecheck: 5/5 tasks
- pnpm test: 182 passing (144 bot, 31 db, 7 shared)
- pnpm lint: 3/3, pnpm build: 3/3
- pnpm check:db-contract: verified against released db-v1.20.0

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MxSTraGzCWDmpCS4h6tCYC

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc5ce901e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/bot/src/lib/match-result-discord.ts
Addresses the Codex P1 on this PR. AGENTS.md "No Silent Mutations" requires
every state change to `matches` to write an `audit_logs` entry with the
actor and old/new values, but setProofThread did a bare `.update()`.

I originally raised this rather than patching it, on the grounds that the
gap predated this branch and that the audit actor would have to be
synthetic. Both concerns turned out to be wrong on closer inspection:

- Not synthetic. Within this branch every proof-thread write flows through
  match-result-discord.ts, which holds action.requestedByDiscordId — the
  operator whose /report-result submission caused the thread to exist. That
  is a real Discord identity, so the audit row has a genuine actor.
- Not a schema change. audit_logs.action_type is plain text with no CHECK
  constraint and no enum, so the new "proof_thread_recorded" action type is
  a code-level contract only and needs no database release.

setProofThread now reads the current pointer, writes the update, and records
the audit entry. Both the first attachment and the crash-recovery
re-attachment go through it, so the history reads the same either way rather
than recording a pointer on retry but not on first creation.

Verification:
- new coverage in matches.test.ts for both call shapes: first attachment
  (null previous pointer) and recovery over a stale pointer, asserting the
  actor and the old/new values that land in audit_logs
- proof-thread.test.ts and report-result-stats.test.ts assert the actor is
  threaded through rather than dropped
- pnpm test — 186 passing (144 bot, 33 db, 9 shared), up from 182
- pnpm typecheck 5/5, pnpm lint 3/3, pnpm build 3/3
- pnpm check:db-contract — db-v1.20.0 (20260823130000)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MxSTraGzCWDmpCS4h6tCYC
@diese-tech
diese-tech merged commit 5fee153 into main Aug 31, 2026
10 checks passed
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.

2 participants