Skip to content

feat(share): list ready bundles, review and send them from the desk - #242

Open
philbert440 wants to merge 2 commits into
release/0.8.19-rcfrom
feat/share-ready-bundles
Open

philbert440 wants to merge 2 commits into
release/0.8.19-rcfrom
feat/share-ready-bundles

Conversation

@philbert440

Copy link
Copy Markdown
Collaborator

Why

The rh app's Share screen needs to show the team servers and hubs this machine can share to, list the sanitized bundles that are ready to share, and send any of them to any of those servers. It also needs to hide rivethub.cloud when cloud is disabled. This PR is the runtime half. The app builds against the API below.

What changes

  • GET /api/share/bundles returns {"bundles":[{"name","sessions","bytes","open_flags","created_at","sanitized"}]}. It lists the sanitized *.json bundles in $XDG_DATA_HOME/rivethub/share, newest first. Raw bundles, .report.md and .review.local.json siblings, symlinks, names that are not plain stems, and anything that does not parse as a sanitized bundle are left out. Local owner only, like the other desk routes.
  • POST /api/share/drafts/from-bundle with {"name":"<stem>"} returns 201 and a DraftReport, the same as POST /api/share/drafts. The name must be a plain stem: letters, digits, ., _, -, starting with a letter or digit, no .., not a .review.local sibling. Anything else is 400 invalid. The file is read only inside the share folder, without following symlinks. The draft holds the bundle text as written, with no new sanitize pass. When the bundle has a decision review, the draft restores it from the bundle's stamp, its .review.local.json and its .report.md. Open flags show as open. Flags an earlier rh memory sanitize --resolve marked show as resolved. The existing marks, confirm, send and push routes work unchanged.
  • After a send or push succeeds, the bundle .json is deleted, but only if the file still has the size, mtime and inode it had when the draft was made. The .report.md and .review.local.json files stay on the machine.
  • GET /api/share/servers drops every entry SharePolicy::admit refuses and adds cloud_disabled. Each ServerView gets delivery. push is used for a [[hubs]] entry, a team-token login, or a device login to any host other than rivethub.cloud or the configured share server, and hub is then the exact value the push route takes. code is used for rivethub.cloud and the configured share server, and hub is then absent.
  • New refusals. 404 unknown_bundle means no listed bundle has that name. 409 open_flags is returned only when a bundle has open flags and its report or local review file is missing, because then the flags cannot be shown.
  • contract/sent.schema.json and contract/accepted.schema.json are regenerated.

Review notes

  • Capture gets sanitize::restore, which rebuilds a Decision from the stamp, the local review and the report. The scores, scored and trivial counts, top, and threshold exist only in the local report, so they are read back from the report the same crate writes.
  • A draft made from a bundle reports zero totals and empty rules, because the per-change counts live only in the local report and are not parsed back.

Proved with: cargo xtask check --locked --no-nextest-list (GATE OK); cargo nextest run -p cli -p gateway -p rivethub -p wire -p kernel -p capture (1924 passed); new gateway route tests that pin the exact JSON and the bad-name refusals; composition tests for listing, from-bundle push and send with file deletion, a blocked flag marked on the desk and then pushed, and policy filtering with delivery; a capture round-trip test for restore; and mutations (no delete, no policy filter, raw listed, no restore) that each fail a test.

GET /api/share/bundles lists the sanitized bundles in the share folder
with their session count, size, open flags and sanitize time. Raw
bundles, report and review siblings, symlinks and anything that is not
a parseable sanitized bundle are left out.

POST /api/share/drafts/from-bundle loads one listed bundle into a desk
draft as written, so the existing confirm, send and push routes share
it unchanged. A bundle with open flags is refused with open_flags; its
flags are resolved with rh memory sanitize --resolve. After a send or
push succeeds the bundle .json is removed, unless the file was replaced
since the draft was made; the local report and review files stay.

GET /api/share/servers leaves out every server the share policy
refuses, so a stored rivethub.cloud login disappears when cloud is
disabled, and reports cloud_disabled.
… delivery

POST /api/share/drafts/from-bundle now opens a reviewable draft for a
bundle with open flags. The draft restores the decision review from the
bundle's stamp, its local review file and its report, carries flags a
previous resolve already marked, and the existing marks, confirm, send
and push routes resolve the rest. Only a bundle whose report or local
review file is missing is refused, since its flags cannot be shown.

Each server in GET /api/share/servers now carries delivery: push for a
hub entry, a team login or a device login to a hub, with hub set to the
exact value the push route takes; code for rivethub.cloud and the
configured share server, which hand back a share code.
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.

1 participant