Documentation
¶
Overview ¶
Package fakesock is the fake inbox socket of plan 9.5: a unix-domain server standing in for a Claude Code session's `CLAUDE_CODE_MESSAGING_SOCKET`, so the socket poster (6.7, U-17, U-19, U-20) and later the watcher can be tested against a real socket with no Claude process anywhere near.
It records, per accepted connection, every physical line it read: the auth lines separately from the user frames, plus the lines that were neither (A.2 says the real harness silently drops those, so a test can prove nothing malformed was ever sent). It can Stall — accept and never read, so a write deadline fires — CloseAtOnce, or Abandon its listener while leaving the socket file in place so a dial gets ECONNREFUSED.
The socket lives under os.MkdirTemp("/tmp", "bsk"), never t.TempDir(): macOS caps sun_path at 103 bytes and a t.TempDir path is already about 91 of them (7.3). The socket file is chmodded to 0600 like the real one. Everything is torn down in a Cleanup: held and live connections are closed first, otherwise the reader wait would hang the package.
Index ¶
- Constants
- type Connection
- type Server
- func (s *Server) Abandon()
- func (s *Server) Accepted() int
- func (s *Server) Close()
- func (s *Server) CloseAtOnce(on bool)
- func (s *Server) Connections() []Connection
- func (s *Server) Dir() string
- func (s *Server) Frames() []string
- func (s *Server) Path() string
- func (s *Server) Stall(on bool)
- func (s *Server) WaitAccepted(n int, timeout time.Duration)
- func (s *Server) WaitDone(n int, timeout time.Duration)
- func (s *Server) WaitFrames(n int, timeout time.Duration) []string
Constants ¶
const OverlongLine = "<line dropped: over 1 MiB>"
OverlongLine is recorded in Invalid for a line the reader dropped as longer than protocol.MaxLineBytes.
const SocketName = "inbox.sock"
SocketName is the file name inside the server's private directory.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// Auth holds the token of every valid auth line, in order.
Auth []string
// Frames holds the content of every valid user line, in order.
Frames []string
// Invalid holds every line that was neither, verbatim (an over-long
// line is recorded as OverlongLine).
Invalid []string
// Lines is how many physical lines were read, valid or not.
Lines int
// Held reports a connection accepted while stalled: never read.
Held bool
// Done reports that the peer closed and the reader finished.
Done bool
}
A Connection is the snapshot of one accepted connection.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server is one fake inbox socket.
func (*Server) Abandon ¶
func (s *Server) Abandon()
Abandon closes the listener but leaves the socket file in place, so a dial finds a socket nobody listens on: ECONNREFUSED.
func (*Server) Accepted ¶
Accepted is how many connections the listener has accepted so far, held and closed-at-once ones included. A refused pre-check shows as zero (U-19).
func (*Server) Close ¶
func (s *Server) Close()
Close stops the listener, closes every held and live connection, waits for the readers, and removes the private directory. Safe to call more than once; New registers it as a Cleanup.
func (*Server) CloseAtOnce ¶
CloseAtOnce makes every connection accepted from now on be closed immediately, before anything is read.
func (*Server) Connections ¶
func (s *Server) Connections() []Connection
Connections snapshots every accepted connection in acceptance order.
func (*Server) Frames ¶
Frames is every user-line content recorded so far, across connections, in arrival order.
func (*Server) Stall ¶
Stall makes every connection accepted from now on be held and never read. Connections already being read are unaffected; held connections stay held until Close.
func (*Server) WaitAccepted ¶
WaitAccepted polls until at least n connections have been accepted.