Skip to main content

Module work

Module work 

Source
Expand description

The seat’s working tree: what a scan of it found, when that was, and the loop that keeps it fresh for the seats a view is showing.

The row is pushed, not polled. A view used to read the tree through whatever read happened to need it, which for a client meant a whole-record encode every time it wanted one number. Here the scan runs for a seat somebody is looking at, its answer is stored beside the process walk, and the row moves by itself as SessionUpdate::WorkChanged.

A seat nobody holds is not scanned: the hold IS what looking means, so a fleet of unheld seats costs nothing. A HELD seat costs one scan per SNAPSHOT_STALENESS while its tree is still, at most one per POKE_INTERVAL while it moves, and one when its PR lookup is due - the record a read serves carries the PR the last scan knew, so this loop is where the refresh is paid. And a seat whose row has not moved announces nothing, however often it is scanned - the frame says the tree moved, never that time passed.

Re-exports§

use std::collections::HashMap; 🔒
use std::path::Path; 🔒
use std::path::PathBuf; 🔒
use std::sync::Arc; 🔒
use std::sync::Mutex; 🔒
use std::time::Duration; 🔒
use std::time::Instant; 🔒
use forge_agent::env::file_index::start_change_watch; 🔒
use forge_agent::env::processes::SCAN_STALENESS; 🔒
use forge_primitives::SessionSlot; 🔒
use forge_primitives::git::GitIssueRef; 🔒
use forge_primitives::git::GitPrInfo; 🔒
use forge_primitives::git_diff::BaseState; 🔒
use forge_primitives::git_diff::GitDiffSnapshot; 🔒
use forge_primitives::git_diff::GitWorkView; 🔒
use forge_primitives::git_diff::PrRefresh; 🔒
use crate::protocol::SessionUpdate; 🔒
use crate::workspace::Workspace; 🔒

Structs§

Announced 🔒
The row a seat’s viewers were last told, which is what keeps a still seat from announcing itself again every time it is read.
Held 🔒
HeldFileIndex
A seat’s walked file index, and when it was taken.
HeldSeats 🔒
The seats a view is showing, and the loop each one runs.
Taken 🔒
A first hold’s share of the seat: the mark the record’s read fires, the wake a reported mutation fires, and the sender that stops the loop.
WorkSnapshot
A seat’s last scan of its working tree, and when it was taken.
WorkState
What one agent’s working tree looks like, and what git said about it.

Enums§

Gate
The repo gate, as a view reads it. Its own type so the view does not have to name the scanner’s.

Constants§

INDEX_STALENESS
How long a walked file index answers for: the window the socket’s own read served it for before the push landed, so a seat’s @ list is no fresher and no staler than it was.
PINNED_GATE_WAIT
How long a drawing read waits for a scan already in flight.
POKE_INTERVAL
How often a held seat looks at its tree.
SNAPSHOT_STALENESS
How long a scan answers for: the staleness rule for the snapshot every view draws, so all views live with one freshness.

Statics§

TEST_PINNED_GATE_WAIT 🔒

Functions§

adopted_measurement 🔒
The base measurement a scan adopts: the one its caller passed, else the checkout’s latest when that was established before the scan began.
git_work_view
The tree behind a row’s depth, as both the record and its frames carry it: the two layers a row draws, with Clean and ScanFailed both reading as nothing to state - which is what the layer means, and the row above still carries the gate that says which.
local_bash_commands 🔒
The commands a walk hands the OS scan: each running local_bash task’s own command.
pinned_gate_wait 🔒
The bound a drawing read uses: production’s, or a test’s shorter one.
reads_again 🔒
Whether a read whose answer was taken at read_at should be taken again, on the same three reasons for every read this module owns.
set_pinned_gate_wait
A shorter gate wait for a test, in milliseconds; 0 restores production’s.
should_scan
Whether the tree should be read again.
spawn_work_watch 🔒
One seat’s scan loop: the tree is watched, the poke reads it and walks the seat’s process tree and its files, and whatever moved goes to whoever is showing the seat.
stopped_while_waiting 🔒
Whether the seat’s watch was stopped while it waited for the record’s mark: the holder went (the sender is dropped) or the stop fired. Either way the reads it was about to take are owed to nobody.
walk_moved 🔒
Whether a walk carries news: the entries the seat’s viewers were last told against the ones this walk found.
work_from_scan
The row a scan answers, from the scan and the directory it was taken of.