Expand description
Messages between the wrapper and the resident commit service.
What:
The messages between the wrapper and the resident commit service, one JSON object per line.
Why:
A client sends a prepared change with a request identity and waits; the service answers with a landing, a queue
position, a request to prepare again, or a failure from a closed list. The line form needs no framing library and
every field is checked on read, so a damaged or hostile line is refused rather than guessed
(doc/planning/cli-git-resident-service.md, “Protocol and request identity”).
In TS you’d write (pseudocode):
socket.write(JSON.stringify(encodeRequest(request)) + '\n'); const reply = decodeResponse(await readLine(socket));Structs§
- Change
- What: One path a commit changes: a file to set, or a file to delete. Why: The client has already written the file’s content into the repository’s object store, so the service names the object and never reads the user’s worktree.
- Commit
Request - What: A request to land one commit. Why: Every field the service needs to land it on the current branch without asking the client anything.
Enums§
- Client
Message - What a client sends.
- Failure
Code - The closed list of reasons the service gives for not landing a request.
- Service
Message - What the service sends.
Constants§
- ALLOWED_
MODES - Modes a change may give a file.
- MAX_
CHANGES - The most paths one request may change.
- MAX_
LINE_ BYTES - The longest line either side accepts, in bytes.
- PROTOCOL_
VERSION - The protocol version this build speaks; a service and a client agree when their versions are equal.
Functions§
- decode_
client - What: Reads and checks one client line. Why: The service trusts nothing from a socket: sizes, names, paths, modes and the object names are all checked.
- decode_
service - What: Reads one service line. Why: The client checks what it is told as strictly as the service checks what it is sent.
- encode_
client - What: The line for a client message. Why: One object per line, no newline inside any field.
- encode_
service - What: The line for a service message. Why: The same one-object form in the other direction.
- is_
object_ name - Whether
textis a full object name in hexadecimal (40 or 64 digits). - is_
plain_ path - Whether
pathis a plain repository-relative path: no leading slash, no empty,.or..part, no NUL or newline.