Repository navigation
Reach the files of a box through a file service in the box - #115
Merged
Merged
Conversation
The orchestrator read and wrote the files of a box directly on the data volume: the review, the attachments and the disk usage walk. This only works when the orchestrator and the box share a filesystem, and the orchestrator read a tree that the agent controls with its own rights. A new process in the box image, boxes-files, now does all file work of the orchestrator. The orchestrator starts it as an exec, as it starts an adapter, and speaks HTTP/2 over its standard input and output. It runs as the agent, so the chown calls on review and attachment files are gone. A write states the hash it expects, and the file service refuses it when the file changed. Each reply states the protocol version, and the orchestrator refuses a file service of another version. A file operation now starts a stopped box. This applies to the raw download, to the upload and download of an attachment, and to deleting the review, which worked on a stopped box before. The disk usage is measured by the file service before each stop and again on a running box after 15 minutes. It is stored with its time in the boxes table, and the box details show that time. Before, the orchestrator walked the directories on the data volume. The box image now builds with the repository root as its context. The repository at the workspace root is now named "workspace" in the review. Before, it had the name of the host directory, which is the box id. Part of splitbrain#109
4 of 9 tasks
The test "a run of reasoning and tool rows stays a list" sends two prompts in one loop. In the second iteration, both waits were satisfied by the first turn: the answer text was found with last(), which the first turn already showed, and the collapse wait saw only the first turn's reasoning panels at height 0. The gaps were then measured while the second turn still rendered, with an open reasoning panel between two rows, and the test failed on a slow CI runner. The test now waits until the count of answers equals the number of prompts sent, and until no collapsed reasoning panel holds its text any more, as the sibling test in the file does.
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.
Part of #109 (step 4).
Changes
files/buildsboxes-files, a process in the box image. Theorchestrator starts it as an exec, as it starts an adapter, and speaks HTTP/2 over its standard input and output.
It runs as the agent. The operations are list, find-repos, stat, read, raw, write, remove, mkdir, create and size.
The path rules of
review/fs.tsmoved into it. A write needsIf-Matchwith the expected hash orIf-None-Match: *, and goes through a temp file. Every reply carries the protocol version.shared/files.tsholds the protocol version, the routes, the caps andvalidRelativePath.orchestrator/src/files.tskeeps one connection per container and starts the file service at the firstrequest. It checks the shape and the size of each reply, applies timeouts, tries a read once more after a lost
connection, and never tries a write again. A file service of another version, or an image without it (exit code
126 or 127), gives a 409 that names the version found and the version needed.
REVIEW.md, the raw download), the attachments (upload and download)and the disk usage go through the file service. The orchestrator no longer reads box files on the data volume.
The
chowncalls on review and attachment files andchownFdToAgentare gone.a running box again after 15 minutes when the box list or the details ask. A migration adds
disk_bytesanddisk_measured_attoboxes. The API hasdiskMeasuredAt, and the box details show it.node …/boxes-filesis part of the box ingateway/background.ts, so the idle reaper can stop a boxwith a connected file service, and the box-level stop leaves it running.
files-buildstage. Its teststage runs
boxes-files </dev/null.publish.ymluses the new context and runs thefilestests.orchestrator/Dockerfilecopiesfiles/src, because the test helperfiles-in-process.tsimports it.doc/files.md.development.md,storage.md,review.md,rests.md,boxes.md,orchestrator.md,threads.mdand the README are updated.Changes in behavior
box (section 8.5 of the concept).
workspacein the review. Before, it had the box id, from the hostdirectory name.
Tests
files: 53 passed (path rules, operations, the HTTP/2 server, and the realmain.tsover stdio).tsc --noEmitis clean, 856 passed, 1 skipped. The review, attachment and app tests run the realfile service in process. New client tests cover reuse of the connection, the read retry, no write retry, the
version error, the missing command, the caps and the reply shape.
npm run checkis clean. The full suite had two failures in the box info view, which are fixed; the viewtests passed again (18). The e2e harness runs the file service in process.
files-buildstage runs through the link and exits 0 on an empty input.Not tested against a real Docker daemon. The box image build did not run.
e2e/ux.test.ts("a run of reasoning and tool rows stays a list"), which this PR doesnot touch. Its second iteration measured the row gaps while the second turn still rendered, because both of its
waits were already satisfied by the first turn. The second commit makes the test wait for the second turn: 6 of 6
runs and the whole file pass locally.
Notes for the next steps
installAgentSet(tar)becomes a new route of the file service. If it starts a child process, for exampletar,the probe rule in
gateway/background.tsmust also cover the children of the file service. Today it matchesonly the process itself, because the disk walk runs in process.
start, as partof the ready state.
errorwith thismessage, and a note when the last pull failed.
versionErrorinfiles.tsbuilds the message.agents.tsstill writesagents/<id>and callschownToAgent. This goes with the/boxes/agentmount.createWorkspace,createHomeandcreateNixinworkspaces.tsstill chown the newdirectories. They are storage creation and move behind the runtime in step 7.
Runtimeinterface.files.tscallsdk.spawnAdapterExec. It becomesRuntime.spawn(boxId, ['boxes-files']).fileService()is keyed by the container id and becomes keyed by the box id.measureDiskinboxes.tsusesrow.container_id, andstopHeldreadscontainerStatebefore it measures.Both become
Runtime.stateand the box id.SIZE_TIMEOUT_MS). Section 8.4 says it has the timeout of arun.setFileServiceSpawnerForTestsandfiles-in-process.tsare the seams for the tests; a fake runtime can use thesame in-process server.
boxes-files, write and read a file, and check that the filebelongs to
BOX_UID.conformance test can check this code on each runtime.
exited, or the missing-command check inrefuseMissingCommandnever matches.reconnects, and a read in progress is tried once more.
the end of stdin when the orchestrator closes it.