feat: add DingTalk answer feedback workflow #6

Merged
zheromiku merged 1 commits from feature/answer-feedback into main 2026-07-21 16:00:18 +08:00
Owner

Summary

  • Add native DingTalk AI Card callbacks for thumbs-up, thumbs-down, and six unresolved-reason codes.
  • Keep one current feedback state per tenant/channel/answer/actor with idempotent state transitions.
  • Bind feedback only to successfully delivered Card answers through the stored DingTalk outTrackId.
  • Add feedback counts to audit lists and safe per-user feedback details to audit turn details.

Data integrity and security

  • Tenant and channel are fixed server-side; Card params cannot override identity or scope.
  • The actor comes from the authenticated DingTalk Stream callback userId.
  • Unknown or ambiguous action IDs are acknowledged with zero writes.
  • PostgreSQL advisory locking plus row locking serializes concurrent updates.
  • Raw callbacks, Card content, params, CorpId, provider IDs, tokens, and WeKnora identifiers are not exposed by feedback audit JSON.
  • Migration adds a partial unique index so one Card provider_message_id resolves to one answer per tenant/channel.

Verification

  • 9 target Go packages: 385 tests passed, 0 failed.
  • go vet: passed for all target packages.
  • Race detector: passed for feedback, DingTalk, and PostgreSQL Store packages.
  • git diff --check: passed.
  • PostgreSQL 16.14 isolated rehearsal: migration up twice, feedback create/replay/change/reason/clear, multi-user isolation, invalid target rejection, audit projection, unique-index rejection, down twice, and up twice all passed.
  • Independent pre-commit review: passed with 0 security concerns and 0 logic errors.
  • Production compatibility read: 2 eligible Card targets and 0 duplicate provider-ID groups.

External prerequisite

The DingTalk AI Card template must be updated to use these action IDs before real UI acceptance:

  • dobotai_feedback_up
  • dobotai_feedback_down
  • dobotai_reason_incorrect
  • dobotai_reason_not_resolved
  • dobotai_reason_irrelevant
  • dobotai_reason_unclear
  • dobotai_reason_outdated
  • dobotai_reason_other

Not performed

  • Not merged.
  • Not deployed.
  • Production database schema and data unchanged.
  • DingTalk Card template unchanged.
## Summary - Add native DingTalk AI Card callbacks for thumbs-up, thumbs-down, and six unresolved-reason codes. - Keep one current feedback state per tenant/channel/answer/actor with idempotent state transitions. - Bind feedback only to successfully delivered Card answers through the stored DingTalk `outTrackId`. - Add feedback counts to audit lists and safe per-user feedback details to audit turn details. ## Data integrity and security - Tenant and channel are fixed server-side; Card params cannot override identity or scope. - The actor comes from the authenticated DingTalk Stream callback `userId`. - Unknown or ambiguous action IDs are acknowledged with zero writes. - PostgreSQL advisory locking plus row locking serializes concurrent updates. - Raw callbacks, Card content, params, CorpId, provider IDs, tokens, and WeKnora identifiers are not exposed by feedback audit JSON. - Migration adds a partial unique index so one Card `provider_message_id` resolves to one answer per tenant/channel. ## Verification - 9 target Go packages: 385 tests passed, 0 failed. - `go vet`: passed for all target packages. - Race detector: passed for feedback, DingTalk, and PostgreSQL Store packages. - `git diff --check`: passed. - PostgreSQL 16.14 isolated rehearsal: migration up twice, feedback create/replay/change/reason/clear, multi-user isolation, invalid target rejection, audit projection, unique-index rejection, down twice, and up twice all passed. - Independent pre-commit review: passed with 0 security concerns and 0 logic errors. - Production compatibility read: 2 eligible Card targets and 0 duplicate provider-ID groups. ## External prerequisite The DingTalk AI Card template must be updated to use these action IDs before real UI acceptance: - `dobotai_feedback_up` - `dobotai_feedback_down` - `dobotai_reason_incorrect` - `dobotai_reason_not_resolved` - `dobotai_reason_irrelevant` - `dobotai_reason_unclear` - `dobotai_reason_outdated` - `dobotai_reason_other` ## Not performed - Not merged. - Not deployed. - Production database schema and data unchanged. - DingTalk Card template unchanged.
zheromiku added 1 commit 2026-07-21 15:40:23 +08:00
zheromiku merged commit da69226481 into main 2026-07-21 16:00:18 +08:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Weknora/dobotai-platform#6