Skip to content

✨ Inbox: transcribe first, then share audio-only items - #18401

Merged
kubestellar-prow[bot] merged 3 commits into
v5from
feat/inbox-transcribe-then-share
Nov 16, 2026
Merged

kubestellar-prow[bot] merged 3 commits into
v5from
feat/inbox-transcribe-then-share

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Choosing RFC…, Knowledge (or, later, spek) from the Inbox 🔗 Share → Hive menu on an item that has audio but no text now transcribes it first and shares when the transcript completes. Audio-only items no longer dead-end on "use 🎧 Transcribe first".

  • Backend: ShareWhenReady stores a ShareIntent (destination, actor, repo, short dialog params; never item text or secrets) with the item state, calls the existing Transcribe path (consent, budget, caps honoured) and runs the share from runTranscription. Failure or skip marks the intent failed with the reason and sends nothing. ResumeIntents (called from Sweep) resumes intents after a restart. DIBS still routes straight away; items with text share immediately.
  • Hook for the spek PR: Service.RegisterIntentRunner("spek", func(ctx, it, ShareIntent) error); the dialog choices travel in ShareIntent.Params (the route API accepts params). On the UI side add one entry to inboxShareHiveActions. The spek seed endpoint is not on v5 yet, so only RFC and Knowledge are wired.
  • UI: progress bar reads "Transcribing, then → RFC" with the existing ETA; failed intent shows an error pill with the reason and Retry in the menu; RFC… and Knowledge are disabled with the reason when transcription is unavailable, plus an owner-only "⚙ Transcription settings…" entry; the old "use 🎧 Transcribe first" reason is gone. Bulk Knowledge waits per item.
  • Roles: POST /api/inbox/route and /api/inbox/dismiss now admit owner and read-write (read stays 403); the Hive group and selection are shown to read-write. Settings (auto-routing, dibs URL/token, RFC repo) stay owner-only. Each share is audited with the acting user.
  • Tests: Go (intent run on completion, failure, unavailable, DIBS unaffected, restart resume, no item text in the state file, old state loads, hook, role matrix) and node (menu states, progress label, failed pill).

🤖 Generated with Claude Code

@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#18408 ✨ Inbox: record recordings directly in hive (backend) same files src/pkg/dashboard/api_inbox.go
src/pkg/inbox/inbox.go
src/pkg/inbox/service.go
src/pkg/inbox/transcription.go
#18405 ✨ Inbox: send items into an Inception (spek) session CONFLICT src/docs/inbox-voice-sources.md (conflict)
src/pkg/dashboard/inbox_share_menu_test.go (conflict)
src/pkg/dashboard/static-src/js/inbox.js (conflict)
src/pkg/dashboard/static/index.html (conflict)
src/pkg/inbox/inbox.go
src/pkg/inbox/store.go
#18407 ⚠️ Retire /api/campaigns, campaign Jam and Recheck same files src/pkg/dashboard/static/index.html

@hivecommons-hive

hivecommons-hive Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Failing checks:

  • runtime-tests

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

Review findings from adjudicator-2 (folded here because this head already carries its hive review):

Security review (head 1fefa64)

  1. High, in-scope: read-write users can send private transcripts to an arbitrary GitHub repo. handleInboxRoute (api_inbox.go, requireInboxShareRole) is now open to read-write. req.Repo is checked only by inboxRepoOK (api_inbox.go:505), which accepts any owner/name. It is passed through ShareWhenReady and Service.Route (service.go:290-293). Route falls back to the configured Spek.Repo only when the repo is empty. Before this PR the route was owner-only. A read-write session can now file the item's content as an RFC issue in any repo the hive's token can write to, including a public one. Settings stay owner-only, but the configured RFC repo is not enforced.

    Suggested fix: for non-owner roles, ignore the request repo or require it to equal the configured one. Add a test to the role matrix.

    +	if req.Repo != "" && !isOwnerRole(r.Header.Get("X-Hive-Role")) && req.Repo != svc.Config().Spek.Repo {
    +		jsonError(w, "repo override requires owner", http.StatusForbidden)
    +		return
    +	}
  2. Low, in-scope: Params is unbounded. inboxRouteRequest.Params map[string]string is persisted into the state file via SetIntent with no limit on key count or value length. Its comment says the values are short dialog choices. Please cap it, for example at most 8 keys, 64 characters per key and 256 per value, and reject the request otherwise.

Not verified: the spek.go Deliver path and the Store.SetIntent file permissions. I did not read them.

Review findings from adjudicator (folded here because this head already carries its hive review):

Correctness review at head 1fefa64 (src/pkg/inbox/shareintent.go, store.go, transcription.go).

1. A share can run twice when a Sweep lands during the transcription tail (medium, in-scope)

  • runTranscription stores the Done record, then calls writeMachineFact, and only then calls finishIntents (transcription.go:~427-435).
  • Sweep calls ResumeIntents (service.go:~360). Its ok && rec.Status == TranscriptionDone case (shareintent.go:~193) calls finishIntents for the same item.
  • finishIntents reads intents with Store.Intents and clears one only after run succeeds. Nothing claims an intent, so both goroutines can run the same IntentRunner.
  • For a registered runner such as spek, this can create two sessions. For spek_rfc, the second Route may return ErrRouteBusy or re-file.
  • Fix: claim the intent atomically before running it.
// store.go
func (s *Store) ClaimIntent(key, dest string) bool {
	s.mu.Lock(); defer s.mu.Unlock(); s.load()
	e := s.entries[key]
	if e == nil || e.Intents[dest] == nil || e.Intents[dest].Status != IntentWaiting { return false }
	e.Intents[dest].Status = IntentRunning // new const; IntentKeys must still treat it as in flight
	_ = s.save()
	return true
}

In finishIntents, add if !s.Store.ClaimIntent(key, dest) { continue } before run.

  • A crash mid-run would leave an intent stuck in IntentRunning. ResumeIntents should reset such intents to waiting at startup.

2. A stale Failed/Skipped record can fail a fresh intent, so the share is lost (medium, in-scope)

  • ShareWhenReady calls SetIntent (shareintent.go:~115) and then Transcribe (~118). Transcribe writes the queued record only after txMu and precheck.
  • In that window, or on a Retry after a failed intent, the store still holds the old Failed or Skipped record.
  • A concurrent Sweep → ResumeIntents then takes the ok && (Failed||Skipped) case (~195). It calls finishIntents, which marks the new intent failed (~143) with the previous run's reason.
  • The new transcription still starts and completes, but no intent is waiting, so the share never happens.
  • The Retry case makes this more likely, because a Retry always starts from a Failed record.
  • Fix: only treat a terminal record as the intent's outcome if it is newer than the intent.
-		case ok && (rec.Status == TranscriptionFailed || rec.Status == TranscriptionSkipped):
-			s.finishIntents(it, rec)
+		case ok && (rec.Status == TranscriptionFailed || rec.Status == TranscriptionSkipped) && !rec.UpdatedAt.Before(oldestWaitingIntent(s.Store.Intents(key))):
+			s.finishIntents(it, rec)
  • Apply the same guard to the Done case. oldestWaitingIntent returns the earliest CreatedAt among waiting intents.
  • Alternatively, take txMu around the SetIntent + Transcribe pair.

3. Dismiss response over-reports and the share runs on the transcription worker (low, in-scope)

  • In handleInboxDismiss (api_inbox.go, ~l.549-555), waiting audio-only items increment n, which is returned as dismissed. They are not dismissed yet.
  • The UI can treat them as done, and a failed transcription never dismisses them.
  • Fix: return dismissed = n - waiting or document dismissed as "accepted".
  • finishIntents runs each IntentRunner synchronously inside runTranscription, before the deferred txDequeue. A slow or hanging runner (up to routeTimeout) therefore blocks the next queued transcription.
  • A go/Run dispatch, or moving the call after dequeue, would avoid that.

Not verified: whether Content() (service.go deliver) reads the machine transcript from the store, so that spek_rfc after transcription sends real text. The new tests may cover it, but I did not read them in full.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing

13 mutant(s) in changed files are not reached by any test (NOT COVERED). A maintainer may apply the mutation/acknowledged label to accept this.

File Line Mutation
src/pkg/dashboard/api_inbox.go 485 ARITHMETIC_BASE
src/pkg/dashboard/api_inbox.go 487 CONDITIONALS_NEGATION
src/pkg/dashboard/api_inbox.go 488 ARITHMETIC_BASE
src/pkg/dashboard/api_inbox.go 551 INCREMENT_DECREMENT
src/pkg/dashboard/api_inbox.go 556 ARITHMETIC_BASE
src/pkg/inbox/shareintent.go 125 CONDITIONALS_NEGATION
src/pkg/inbox/shareintent.go 128 CONDITIONALS_NEGATION
src/pkg/inbox/shareintent.go 157 ARITHMETIC_BASE
src/pkg/inbox/shareintent.go 193 CONDITIONALS_NEGATION
src/pkg/inbox/shareintent.go 195 CONDITIONALS_NEGATION
src/pkg/inbox/shareintent.go 195 CONDITIONALS_NEGATION
src/pkg/inbox/shareintent.go 197 CONDITIONALS_NEGATION
src/pkg/inbox/shareintent.go 197 CONDITIONALS_NEGATION

ℹ️ 1 mutant(s) on added lines were SKIPPED because gremlins v0.6.0 only honours the first lines added lines of each default-context hunk, so non-contiguous edits in one hunk are partly missed. This does not affect the verdict.

File Line Mutation
src/pkg/dashboard/api_inbox.go 499 CONDITIONALS_NEGATION

Verdict: uncovered (#17349).

Signed-off-by: Andy Anderson <andy@clubanderson.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
Signed-off-by: Andy Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the feat/inbox-transcribe-then-share branch from ff516a3 to 1fefa64 Compare November 16, 2026 13:08
@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 16, 2026

@hivecommons-hive hivecommons-hive Bot 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.

HUMAN DECISION NEEDED — Confirm that widening inbox share/dismiss from owner-only to read-write sessions belongs in a "transcribe first, then share" PR. @clubanderson

Reviewed at head 1fefa64 against the PR title and diff, since no linked issue was found. The transcribe-then-share core is in scope and matches the description: shareintent.go implements ShareWhenReady, finishIntents and ResumeIntents, and DIBS still routes directly.

  1. Authorization widening (in-scope, needs a human). src/pkg/dashboard/api_inbox.go replaces requireOwnerRole with requireInboxShareRole on handleInboxRoute and handleInboxDismiss. Read-write sessions can now push items, including private audio transcripts, to the RFC repo. Before this PR only owners could. The title doesn't mention it, though the PR body does ("Roles:"). The transcribe-first feature doesn't need it. Either confirm the policy change explicitly, or split it into its own PR.

  2. Bulk dismiss behavior change (in-scope, low). handleInboxDismiss now calls ShareWhenReady, which calls Route(DestDismiss) for items that have text. Route runs s.handOff(...) in addition to Store.Dismiss (src/pkg/inbox/service.go:277-281). The old bulk path only called Dismiss. Bulk "knowledge only" now triggers a hand-off it never triggered before. Also, a ShareWhenReady error that isn't ErrTranscribeUnavailable now aborts the whole batch with a 500 (api_inbox.go, dismiss loop).

  3. Inconsistent handling when transcription is unavailable (in-scope, low). The PR body says Knowledge is disabled in the UI when transcription is unavailable. The bulk dismiss API instead silently falls back to an immediate svc.Dismiss for audio-only items. That is the dead-end-free behavior the PR removes elsewhere, and it marks the item knowledge-only without a transcript.

I did not run the tests or the JS/UI changes. My review of inbox.js and index.html was limited to the diff.

— hive: agent=adjudicator-3 backend=claude model=claude-sonnet-5-5 claude=2.1.325

@clubanderson clubanderson added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 16, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow
kubestellar-prow Bot merged commit 67cd9df into v5 Nov 16, 2026
91 of 93 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/inbox-transcribe-then-share branch November 16, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. conflicts-with-open-pr Open PR has a merge conflict with another open PR dco-signoff: yes Indicates the PR's author has signed the DCO. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant