team

package
v0.51.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 71 Imported by: 0

Documentation

Overview

Package team implements `hadron team ...` — the team-coordination surface (#369, re-keyed to the Worker model in #428 / hadron-server#974). An Agent carries role metadata and a compiled boot-prompt pointer; the named identity ("Iris") is a WORKER, the casting of an installed Agent into an App (cor:dmo:050:11).

TWO facts about a name, and they are not the same one (cor:agt:020:09, hadron-cli#487). HELD is whose name it is: held by a PERSON, freed only by an explicit release, and what decides whether you may bind. LIVE is whether a worker session is open on it right now — derived from an unended Session, only ever a question about a name already yours, and never a claim that anybody is at the keyboard, since a worker session outlives the chat session that started it. An earlier version of this comment called the second one "taken right now"; that word named both facts at once, which is the defect #487 was filed for.

Index

Constants

View Source
const AgentPIDEnv = delivery.AgentPIDEnv

AgentPIDEnv is the agent's own pid, exported by the Orca launch.

View Source
const BindingFileName = bindingFileName

BindingFileName is bindingFileName for the command package's tests, so they name the file this package owns (cli#1969 F10).

View Source
const GitDirEnv = "HADRON_TEAM_GIT_DIR"

GitDirEnv overrides the git call that locates the worktree binding — for tests, and for environments with no git binary. Exported so the test sandbox names the same string this reads rather than a copy of it: two spellings of one well-known key is how a sandbox silently stops sandboxing (hadron-cli#498).

View Source
const PlainDirCacheName = plainDirCacheName

PlainDirCacheName is plainDirCacheName for the command package's tests, so they name the directory this package owns rather than a second spelling (cli#1969 F10).

View Source
const TeamChatPageSize = 200

TeamChatPageSize is the server's list cap and the default page size; an unbounded read pages with the seq watermark as the cursor (each page's last seq is the next sinceSeq).

EXPORTED for the command tests, which need a FULL page to drive the exhaustive loop past its first iteration — the loop stops on a short page, so a test hard-coding 200 would silently stop exercising exhaustion the day this changes.

Variables

This section is empty.

Functions

func ApprovalAsPersonNote added in v0.51.0

func ApprovalAsPersonNote(f *cmdutil.Factory) func(context.Context, bool)

ApprovalAsPersonNote is the hook behind Factory.NoteApprovingAsPerson (cli#1843). An approval acts as the signed-in person unless --as-worker says otherwise (cli#1872, ruling R10), and nothing on screen said so when the worktree is bound to a worker session. From a bound worktree it prints ONE stderr line per run saying whose approval this is. Nothing sent changes.

The binding is only read, never verified: a note is not an attribution, so an unreadable, missing or unbound state prints nothing (an unbound cwd is the #1855 note's case, and --as-worker has its own refusals).

asWorkerFlag says whether the command has --as-worker to point at; `memory approve-all` does not, so its note stops at who approves. The grant clause names a boot prompt only: an ordinary node's approval follows cor:dmo:120:02 and needs no grant (cor:agt:040:18).

func AuthoredWriteContext added in v0.21.0

func AuthoredWriteContext(f *cmdutil.Factory) func(context.Context, *graphql.Request) context.Context

AuthoredWriteContext is command-local, never a default session on the transport. Snapshot before the first lookup, then verify the binding again for every authored mutation. Other requests retain their existing context.

func BeginInstructedWrite added in v0.36.0

func BeginInstructedWrite(f *cmdutil.Factory) func(context.Context) InstructedWrite

BeginInstructedWrite snapshots the binding NOW; call it before the command's first lookup.

func BeginServerTargetInstructedWrite added in v0.36.0

func BeginServerTargetInstructedWrite(f *cmdutil.Factory) func(context.Context) func(context.Context) (context.Context, bool, error)

BeginServerTargetInstructedWrite is for person writes whose server resolves the target App (cli#1610, Xanthos #72650). Verify the binding locally but do not infer an App from an asset id. A server refusal never triggers fallback.

func CredentialInstructionContext added in v0.36.0

func CredentialInstructionContext(f *cmdutil.Factory) func(context.Context) (context.Context, error)

CredentialInstructionContext verifies a complete same-server worktree binding for an explicit credential instruction (Xanthos ruling #71555). It fails closed, never borrowing the person's authority. Target-App authorization is server-owned in the one credential request; no ambient App lookup is added.

func InstallEndedBindingCheck added in v0.25.0

func InstallEndedBindingCheck(f *cmdutil.Factory)

InstallEndedBindingCheck arms the notice for one root command. Each NewRootCmd installs a fresh one, so one command checks at most once.

func NewCmdTeam

func NewCmdTeam(f *cmdutil.Factory) *cobra.Command

NewCmdTeam builds the `hadron team` command group.

func RetireConfirmPrompt added in v0.41.0

func RetireConfirmPrompt(name, id string) string

RetireConfirmPrompt is the question `worker retire` asks before it acts.

func SetGitDirRunner added in v0.51.0

func SetGitDirRunner(r GitDirRunner) (restore func())

SetGitDirRunner replaces the git call for a test and returns the function that restores it. Tests only: production never calls it.

func WorkerWriteSession added in v0.42.0

func WorkerWriteSession(f *cmdutil.Factory) func(context.Context, ...string) (cmdutil.WorkerWriteContext, error)

WorkerWriteSession is the strict resolver behind `--as-worker` (cli#1872, ruling R10). Unlike AuthoredWriteContext, which is best-effort and attaches nothing when it cannot verify a binding, this one refuses (exit 2, nothing sent) in every case where the bound worker session cannot be proven to be the one for this request: no worktree, no binding, an incomplete binding, a binding for another server, or an --app naming another App. It never falls back to the person: a compile or approve the caller asked to make as the worker must not be recorded as theirs.

The returned function is called immediately before each mutation. It re-reads the binding and refuses if it changed since the resolve (a rebind mid-run), so a batch never sends under a session it did not verify.

Types

type GitDirRunner added in v0.51.0

type GitDirRunner func(ctx context.Context) (stdout, stderr []byte, err error)

GitDirRunner asks git for the current directory's git dir: its stdout, its stderr when it refused, and the error. It is the seam tests replace so "is this a plain directory?" is decided by an injected answer on every platform, not by a shell script on PATH (cli#1969 F6).

type InstructedWrite added in v0.36.0

type InstructedWrite func(ctx context.Context, targetAppID, targetAppRef string) (out context.Context, worker bool, err error)

InstructedWrite yields the context for the one instructed write. Pass the target App's id when the command already holds it (a resolved worker's AppId), else "" and the App ref the write names (id, URN or alias). worker reports whether the worker session was attached (the claim, once admitted, is recorded); false means the call goes out as the person.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL