Repository navigation
✨ feat: hub per-hive consent match endpoint - #19219
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: CI pending - sweep will merge when green. 🐝 Hive Agent: Review findings from One verified defect, and it is in the test, not the endpoint: The line is What I read and found sound: the handler order (switch off gives 404 before anything else, bearer bound to the claimed Open question, not a defect: Findings not on a changed line
|
There was a problem hiding this comment.
Decision needed: @clubanderson should confirm that the new hub endpoint POST /api/customers/match, which releases consented real name, organization and country to a hive under its heartbeat bearer, may land before any spoke consumer exists.
This is correct as far as I can verify, but it is a personal-data release path (auth plus consent), so it needs a person's sign-off rather than mine.
What I read at 34357ad: customer_match.go and customer_consent_store.go.
- Consent is re-read per answer (
customerMatchEffective,customer_match.go): not withdrawn, current text version, grant still held, not blocked. The 30s index only maps hash to file, so a withdrawal is immediate. - The bearer is bound to the claimed
hive_idviaverifyHeartbeatBearer, and the index is built per hive, so one hive cannot read another's consent. - Unknown, unconsented, stale, blocked and lost-grant people all fall through to the same empty answer;
clearedis only emitted whenDeliveredFieldsis set. - Only
user-provenance, non-empty values cross (customerMatchShareable). The switch-off 404 is checked before auth.
Open question (not a defect): customerMatchIndexFor scans every consent file and loads every user while holding the global customerConsentMu, on each index rebuild per hive. Fine at today's scale; worth a look if the hub grows.
The body matches the diff, and the changelog fragment is present.
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.327
hex(1) has no hex letters, so ToUpper left it valid; use hex(0xabc) so the uppercase branch is actually exercised. Hive-Fix-Attempt: 1/6 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether a failed delivery stamp must withhold that person's data (fail closed) before this consent endpoint lands?
Read customer_match.go end to end at the head commit. Auth order, hash validation, answer-time consent/provenance checks and the identical-silence behaviour look correct to me. One verified issue: the delivery stamp can fail after data has already been committed to the reply (inline comment at line 412).
This is a consent/PII path, so I am routing it rather than leaving it to the test result.
-- hive: agent=reviewer backend=claude model=claude-sonnet-5-5 claude=2.1.327
| continue | ||
| } | ||
| delivered++ | ||
| if err := stampCustomerDelivery(p.path, hiveID, p.sent, p.entry.Rev, now); err != nil { |
There was a problem hiding this comment.
Stamp failures are only logged, but the reply is still written at line 425. If the stamp write fails (disk error, lock), the hive receives the person's fields while the record has no DeliveredFields. A later withdrawal or lost provenance then yields no cleared entry, so the spoke never removes the data, which breaks the guarantee in the file header. Consider stamping before writing the reply and dropping that entry (or returning 500) when the stamp fails.
Phase 2 of the decided Customers hub consent design (
src/docs/design/customers-hub-consent.md). Phase 1 (#19160, merged in #19171) lets a person record consent per hive. Until now nothing used that consent. This PR adds the hub endpoint that answers a hive's match request, and it answers only for people who consented to that hive. No spoke calls it yet (that is phase 3), so nothing changes in production.Why it is shaped this way
clearedentry only goes to a hive that already got that person's data. It lists the fields that no longer cross, so the spoke can remove them.userprovenance AND a non-empty value. Values are read live, so admin-typed and inferred values never cross, and a later correction reaches the hive on its next pull.text_version, the person still holds a grant on the hive, and the person is not blocked or deleted. The short index cache (30s) only maps a hash to a consent file. The record and the user are re-read every request, so a withdrawal takes effect immediately. A grant made on the consent page invalidates the cache.verifyHeartbeatBearer, bound to the claimedhive_id. The match key isderivePerHiveKey(master, "hive-customer-match-v1", hive), never the bearer itself. It is tried under every accepted key generation, the same way the bearer is. The index only holds that hive's records, so one hive cannot read another hive's consent with either key.github:identity only. The design asked phase 2 to confirm thatLinkedGitHubLoginis proven before matching on it. No hub code path writes that field after a GitHub check, so it is left out. Email is not matched.truncatedflag, and only sent entries get stamped), a per-hive rate of 6 per minute (429 plusRetry-After), and the index TTL. A non-matching hash is dropped and never stored or logged.first_delivered_at,last_delivered_at,delivered_fieldsas the union of fields ever sent,delivered_rev) go on the consent record. Phase 1's page can then show what was sent, and a withdrawn record is kept while a clear is owed. Audit is one line per request with the hive id and counts only.HIVE_HUB_CUSTOMERS_SHARE_ENABLEDis off.Match state is package-level, like
customerConsentMu, soserver.go(cited by line in docs) is not touched.Tests
src/pkg/hub/customer_match_test.gocovers each acceptance bullet:clearedonly after a deliveryIt also checks the delivery stamps, the count-only audit, and that a new grant invalidates the index cache. Tests were not run locally (per AGENTS.md); CI is the verdict.
Closes #19162
🤖 Generated with Claude Code
-- hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.327 requested_by=@clubanderson