Repository navigation
feat(share): list ready bundles, review and send them from the desk - #242
Open
philbert440 wants to merge 2 commits into
Open
philbert440 wants to merge 2 commits into
philbert440 wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/bundlesreturns{"bundles":[{"name","sessions","bytes","open_flags","created_at","sanitized"}]}. It lists the sanitized*.jsonbundles in$XDG_DATA_HOME/rivethub/share, newest first. Raw bundles,.report.mdand.review.local.jsonsiblings, 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-bundlewith{"name":"<stem>"}returns201and aDraftReport, the same asPOST /api/share/drafts. The name must be a plain stem: letters, digits,.,_,-, starting with a letter or digit, no.., not a.review.localsibling. Anything else is400 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.jsonand its.report.md. Open flags show as open. Flags an earlierrh memory sanitize --resolvemarked show as resolved. The existing marks, confirm, send and push routes work unchanged..jsonis deleted, but only if the file still has the size, mtime and inode it had when the draft was made. The.report.mdand.review.local.jsonfiles stay on the machine.GET /api/share/serversdrops every entrySharePolicy::admitrefuses and addscloud_disabled. EachServerViewgetsdelivery.pushis 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, andhubis then the exact value the push route takes.codeis used for rivethub.cloud and the configured share server, andhubis then absent.404 unknown_bundlemeans no listed bundle has that name.409 open_flagsis 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.jsonandcontract/accepted.schema.jsonare regenerated.Review notes
sanitize::restore, which rebuilds aDecisionfrom 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.totalsand emptyrules, 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.