origin

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 34 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package origin is the single owner of "this workspace's origin clients".

Production code constructs a *jira.Client only through Client (the workspace's origin) or Connected (a candidate site/email/token, used when verifying a credential the user just typed). The wiki client is Wiki — the same split (builtIn in-process handler vs connected site). jira.New stays exported for tests that stand up httptest servers; a gate test fails if production files grow a new direct call.

Index

Constants

View Source
const DefaultProjectKey = "STD"

DefaultProjectKey is the project seeded into a new built-in origin so create/createmeta have somewhere to file. Issuetap also creates a project on first write if a caller names another key.

View Source
const DefaultSpaceKey = "LOC"

DefaultSpaceKey is the wiki space seeded into a new built-in origin so page create has somewhere to file. Short and obviously local — not a display name, and not a site-specific key.

View Source
const LegacyYAMLRel = "origin/issuetap.yaml"

LegacyYAMLRel is the pre-SQLite persist path. When PersistRel is absent and this file exists, NewEmbedded seeds from it as FixturePath once. The YAML is left in place as a rollback asset.

View Source
const PersistRel = "origin/issuetap.db"

PersistRel is the workspace-relative path of the issuetap write-through SQLite state file (WAL). The file is the origin; gadak.db remains a disposable cache filled by sync.

View Source
const ProbePath = "/api/v1/issues/sync/progress/"

ProbePath is how port_fallback and views open decide whether a loopback port is a gadak UI serve (X-Gadak / X-Gadak-Profile). It is not used to route origin writes. A leftover serve-origin.json from a previous version is ignored (GDK-936).

View Source
const ProbeTimeout = 700 * time.Millisecond

ProbeTimeout is the probe's budget and the single owner of the number (GDK-1004): it used to live as a second literal in cmd/gadak's port fallback, and nothing compared the two, so a tune on one side would leave the other probing on a stale budget. Callers outside this package read this constant; ProbeGadakOnPort applies it when handed timeout <= 0. gdk1004_timeout_gate_test.go fails on any pair of copies that disagrees.

View Source
const RESTPrefix = "/api/v1/origin"

RESTPrefix is the serve passthrough root. A client request to /rest/api/3/issue is sent to <serve> + RESTPrefix + /rest/api/3/issue. Paired remote clients reach this machine's origin through this prefix.

Variables

View Source
var (
	ErrUnsupported      = errors.New("this origin does not support that")
	ErrNoVersionCatalog = unsupported("linear: project versions are not supported on this origin")
	ErrNoIssueLinks     = unsupported("linear: issue links are not supported on this origin")
	ErrNoCreateFields   = unsupported("linear: create-time field metadata is not supported on this origin")
	ErrNoMediaRef       = unsupported("linear: inline comment media is not supported; the file is attached to the issue")
	ErrNoRemoteLinks    = unsupported("this origin does not support remote issue links — they need a built-in or paired workspace")
	// ErrNoCommentEdit is origin-neutral: both origins this tree ships
	// implement the face, so the miss is a wrapper that does not forward it
	// or a future origin — the sentence must not blame Linear or Jira.
	ErrNoCommentEdit = unsupported("this origin does not support comment edit or delete")
)

These strings were the linearWriter stubs' Error() values. Callers that type-assert a missing face must return the same text (GDK-641).

ErrUnsupported is the cause of that whole class: a permanent "this origin cannot do that", distinct from a transport failure. failJira branches on it. The four ErrNo* wrap it so errors.Is(err, ErrUnsupported) is true while errors.Is(err, ErrNoIssueLinks) (and the other three) keep matching and Error() stays the original sentence (GDK-685).

View Source
var ErrExportRefused = errors.New("origin: export refused")

ErrExportRefused is the export half's gate: the workspace's origin is not the embedded tracker running in this process (Jira, Linear, or a pairing), so there is nothing here in the built-in tracker's own format to hand out. The CLI prints it; the serve maps it to 400 export_refused.

View Source
var ErrLinearCycleByDates = unsupported("Linear cycles start and end by their dates — edit the cycle's dates in Linear; gadak does not start or close them")

ErrLinearCycleByDates is the refusal for starting or closing a sprint on a Linear origin: a cycle has no state to flip — it begins and ends by its dates, so the edit belongs in Linear's cycle settings (or the date fields, which UpdateSprint does carry).

View Source
var ErrLinearCycleCadence = unsupported("Linear generates its cycles from the team's cadence — set the cadence in the team's settings; gadak does not file one")

ErrLinearCycleCadence is what Linear's own refusal of cycleCreate is translated into (GDK-1678). Measured on a workspace with cycles switched on: the mutation is in the schema and the server answers "Cycle creation is not supported." — cycles come from the team's cadence setting, not from a call. The origin's sentence is kept in the wrapped error; this one says what to do instead.

View Source
var ErrNoIssueAssigneeRead = unsupported("this origin cannot read one issue's current assignee")

ErrNoIssueAssigneeRead is the face-miss refusal for AsIssueAssigneeReader. The assign write surfaces it as a failed read (GDK-2063): refuse and name the limitation, or --force.

View Source
var ErrNoIssueTypes = unsupported("linear: this origin has no issue types")

ErrNoIssueTypes is the edit --type refusal (GDK-962): Linear has no issue types, so asking to change one is refused, never silently dropped — the same class as create --type being dropped before GDK-741. The CLI refuses before fetching any catalog (a Linear type catalog cannot exist), and linearWriter.UpdateFields refuses the issuetype field itself so any other surface sending it inherits the same sentence.

View Source
var ErrNoSprints = unsupported("this origin has no sprints — sprints are Jira Software's and Linear's cycles, and this workspace's origin is neither")

ErrNoSprints is the refusal for an origin with no sprints.

View Source
var ErrWorkspaceFrozen = errors.New("this workspace is frozen — no requests leave for the origin; unfreeze with `gadak config set frozen false`")

ErrWorkspaceFrozen: frozen means no request leaves for the origin — pulls and writes alike (GDK-507 decision). The gate lives here, on the client mint, so every surface (CLI verbs, REST writes, per-issue resync, the api escape hatch, page writes) refuses in one place instead of each carrying its own check. A scrubbed demo fixture with a live credential must neither re-pollute its mirror nor create real issues on the origin.

View Source
var LinearEndpoint string

LinearEndpoint, when non-empty, is the GraphQL URL Linear() installs on the client. Tests point it at httptest; production leaves it empty so New keeps linear.Endpoint. This is not a config.json field — an install URL must not become a persisted setting.

Functions

func ActorTrailer added in v0.21.0

func ActorTrailer(a config.ResolvedActor) string

ActorTrailer is the one trailing line an agent-authored write carries on a Jira or Linear origin: "— via gadak · <Name> (<slug>)" with a display name, "— via gadak · <slug>" without. Empty when the actor has no slug (nothing to attribute). Exactly one line, no link, no emoji — the line is a machine-written literal, and docs/RECIPES.md filters on it verbatim.

func AssigneeDisplayName added in v0.24.3

func AssigneeDisplayName(u *User) string

AssigneeDisplayName is how a report names a holder: the display name, the id when the origin sent none, "" when there is no holder. Callers that need prose for "no holder" own that wording themselves — the CLI says "(nobody)", the REST 409 sends current_assignee: null.

func AssigneeID added in v0.24.3

func AssigneeID(u *User) string

AssigneeID is the holder's id, "" for unassigned (nil or no id). The one spelling of "who holds the issue" the preflight compares.

func BodyDialect added in v0.22.0

func BodyDialect(cfg *config.Config) adf.Dialect

BodyDialect is how this workspace's origin holds an issue body (GDK-1637): wiki markup as a plain string on a Jira Server origin, markdown-shaped text everywhere else — Cloud Jira, Linear, and the built-in tracker. The dialect comes from the origin type, never from sniffing the string; there is no fallback from one to the other.

func BodyValue added in v0.22.0

func BodyValue(cfg *config.Config, text string, doc json.RawMessage) json.RawMessage

BodyValue is the value this origin's body field takes for the text a person typed: doc — the markdown conversion (jira.Doc, jira.DocWithMedia, or adf.FromMarkdownWith) — on a markdown origin; the raw string itself on a Jira Server origin, whose body field is wiki markup carried verbatim, never converted in either direction (GDK-1637). The Server branch does not consult doc, so a caller may pass the conversion unconditionally.

func BuiltInHandler added in v0.22.0

func BuiltInHandler(cfg *config.Config) (http.Handler, error)

BuiltInHandler is the in-process issuetap HTTP surface for this workspace. The serve RESTPrefix passthrough uses it so a paired remote client lands on the same origin the UI already holds. Always embeds.

func Client

func Client(cfg *config.Config) (*jira.Client, error)

Client is the single owner of "this workspace's Jira client". A connected workspace gets the same jira.New(site, email, token) as before. A built-in workspace embeds issuetap over the persist SQLite file (WAL). A paired remote workspace talks to the home serve's RESTPrefix passthrough. BaseURL stays empty so stored browse links are /browse/KEY rather than a fake https origin a person might click.

func Close

func Close() error

Close checkpoints every live built-in origin (WAL) and drops the sessions. Safe to call more than once. The process owner (cmd/gadak main) calls this on the way out. Writes commit before ACK; Close is a checkpoint, not a debounce flush.

In-flight constructors are waited on (they publish, then this snapshots) so Close never closes a half-built Embedded. There is no permanent closed flag: Client after Close must open a new session (persist is the origin; the process is allowed to come back).

func CloseBuiltIn added in v0.22.0

func CloseBuiltIn(cfg *config.Config) error

CloseBuiltIn checkpoints and drops the live session for cfg's persist. Waits an in-flight constructor for the same key. No-op when nothing is live. Callers that marked SetInProcess unmark it themselves — this only owns the session.

func Connected

func Connected(site, email, token string) *jira.Client

Connected builds a client for an explicit site/email/token — verifying a credential the user just typed, not "this workspace's origin".

func ConnectedServer added in v0.22.0

func ConnectedServer(base, token string) *jira.Client

ConnectedServer builds a client for an explicit Server base URL and PAT — the Connected sibling for the deployment that has no email (GDK-1640). Same role: verifying a credential the user just typed.

func CreatesVersionsByName added in v0.17.0

func CreatesVersionsByName(w Writer) bool

CreatesVersionsByName reports whether w mints a project version from a fixVersions add {"name": token}. True for issuetap (builtIn in-process, routed serve, paired home). False for Cloud Jira and Linear (GDK-678).

func CurrentDescription added in v0.20.1

func CurrentDescription(ctx context.Context, cfg *config.Config, key string) (raw json.RawMessage, found bool, err error)

CurrentDescription reads KEY's description as the origin holds it right now — never the mirror, which is a stale cache while a decision about the write's next instant is being made (GDK-1001, GDK-1396: the markdown loss guard and placeholder substitution both work from this). found is false when the origin returned no row for the key; the write that follows is then the authority on whether the issue exists.

func DefaultConfluenceConfig

func DefaultConfluenceConfig() *config.ConfluenceConfig

DefaultConfluenceConfig is what initBuiltIn writes so the wiki sync pass is on and scoped to the seeded space. Presence of the block is the on switch (internal/sync/confluence.go).

func Describe

func Describe(cfg *config.Config) (kind, origin string)

Describe answers doctor: which kind of workspace, and where the origin is. Connected reports "jira" — "jira+linear" when the Linear source is on (no hostname or key either way; doctor is safe to paste). Built-in reports the persist path.

func EmbeddedSnapshot added in v0.22.0

func EmbeddedSnapshot(cfg *config.Config) ([]byte, error)

EmbeddedSnapshot returns this workspace's built-in origin as the seed YAML — the format LegacyYAMLPath files and NewEmbedded re-seeds from, gaining its export half here (GDK-768: the format was import-only; Snapshot had no caller). Read-only, and through the live session, so a running serve exports without a second opener of the persist file.

Transport, not the stored kind, is the gate: a paired workspace is also OriginGadak, but its origin is another machine's serve — constructing the embedded origin here would mint a fresh empty persist on the wrong machine, the quietly-wrong-origin class the pairing contract exists to prevent. The first refusal asks origin type, not the stored kind (GDK-1793's audit), so a paired workspace falls through to the paired sentence below instead of being told its own origin's format is foreign to it.

func FoldPairedError added in v0.17.0

func FoldPairedError(cfg *config.Config, err error) error

FoldPairedError is the single owner of the remote-device pairing sentence. On a paired workspace, 401 and dial failures become a PairingError whose Error() is the first line a person should see. Other workspaces pass err through.

func ForgetLive

func ForgetLive()

ForgetLive drops cached embedded sessions without closing them. Tests use this to simulate a second process: the serve handler still holds the graph, but Client no longer finds it in this process.

func InProcessAuthB64 added in v0.17.0

func InProcessAuthB64() string

InProcessAuthB64 is the base64 payload of the in-process Basic credential the local CLI presents to the origin passthrough. Exported so the server's pairing gate can rewrite a *validated* Bearer into the exact Authorization shape the embedded issuetap graph has always seen: the gate authenticates the caller, then speaks to the origin as the in-process user it always did (GDK-433).

func IsInProcess added in v0.18.0

func IsInProcess(cfg *config.Config) bool

IsInProcess reports whether this process owns cfg's persist.

func IsPairingFailure added in v0.17.0

func IsPairingFailure(err error) bool

IsPairingFailure reports a pairing/dial/auth failure that create must not relabel as a missing --project flag.

func LegacyYAMLPath added in v0.17.1

func LegacyYAMLPath(dir string) string

LegacyYAMLPath is the absolute pre-SQLite persist path inside a profile directory. Empty dir yields empty path.

func Linear added in v0.16.1

func Linear(cfg *config.Config) (*linear.Client, error)

Linear is the single owner of "this workspace's Linear client" — the same role Wiki plays for Confluence (GDK-258: a third source beside the Jira client, never a facade behind its Transport). There is no built-in variant: issuetap has no Linear surface, and the block carries its own credential rather than the Atlassian one.

func LinkPhrase added in v0.22.0

func LinkPhrase(direction, inward, outward string) string

LinkPhrase is the sentence one link row prints for a direction: the type's own description ("blocks" / "is blocked by"), or "" when the pair does not name one. The mirror's links.direction is the wire pair ("Blocks outward") and stays a contract column; this is the human line (GDK-1734) — reading "blocks NMB-2" instead of "Blocks outward NMB-2".

func LinkTypeByID added in v0.24.0

func LinkTypeByID(id, direction string, catalog []jira.IssueLinkType) (lt jira.IssueLinkType, inwardDescription bool, err error)

LinkTypeByID answers the machine path: the client picked a row out of the catalog this server handed it, so the id and the direction it sends back are an identity already decided, not words a person typed (GDK-1983). Exact id match only, no fuzzy fold over names and descriptions — that fold is what can refuse a choice the UI itself offered, because Jira lets two types carry the same inward or outward phrase and does not enforce uniqueness. A miss is a refusal that calls the id by its name, never a guess at what was meant.

It is the same rule CLAUDE.md states for transitions after GDK-1982: a client that chose from the catalog is not re-interpreted by the human vocabulary resolver. The human path stays where people type — the CLI, and any older client still sending `type`.

direction is which end the requesting issue takes, and it is required: the caller that knows the id knows it, and an absent one is a client bug rather than a default worth inventing. "inward" means the phrase displayed on the requesting issue is the type's inward description, which is what the caller's inwardDescription result has always meant.

func LiveServeFor added in v0.19.0

func LiveServeFor(profile string) (serveaddr.Record, bool)

LiveServeFor returns the first live UI serve advertising profile, found through the home-root run directory (serveaddr) and the identity probe — not leftover serve-origin.json, which GDK-936 made meaningless.

This is the single owner of that discovery walk (GDK-987): until it, two copies of the same serveaddr.List → ProbeGadakOnPort loop lived in originbind.RefuseIfOpen (builtIn→connected conversion refusal) and pairflow.AdvertisedEndpoint (the pairing endpoint default), and a guard added to one copy would silently miss the other. Consumers keep their own framing of the record: RefuseIfOpen wraps PID/Addr in WorkspaceOpenError, AdvertisedEndpoint upgrades Addr to a URL.

func OpenHolder added in v0.18.1

func OpenHolder(persist string) int

OpenHolder reports the PID of another live process holding this persist, or 0. This process's own mark is not a holder — the caller is asking whether it must stand aside for someone else.

A marker naming a dead PID is removed here rather than reported: the alternative is a workspace that refuses conversion forever after one crash, with nothing on screen explaining why.

func OwnerStatus

func OwnerStatus(cfg *config.Config) string

OwnerStatus is the doctor line for a built-in workspace. There is no exclusive persist owner after GDK-936 (WAL); leftover serve-origin.json is ignored. Empty when the workspace is not builtIn.

func PairedConfluenceConfig added in v0.20.0

func PairedConfluenceConfig() *config.ConfluenceConfig

PairedConfluenceConfig is the paired twin: what pairing writes so the wiki pass is on. Spaces stays empty — every team space the home origin lists — because this side has no site of its own to name and cannot see which keys the home machine seeded (GDK-1276: without the block a paired workspace mirrored issues but reported its wiki as not configured).

func PairedServerVersion added in v0.22.0

func PairedServerVersion(endpoint string) string

PairedServerVersion is the gadak version the serve at endpoint last reported on a response header, or "" when it never did. The pair-time record reads this right after VerifyPaired — the one round trip every pairing already makes — so the credential stores what the serve itself said, not a guess.

func PairedStatus added in v0.17.0

func PairedStatus(cfg *config.Config) (*pairing.Remote, error)

PairedStatus is the single owner of "is this workspace paired with a remote gadak serve?". status, doctor, profiles, and pairing list read this instead of opening remote-origin.json themselves. Built-in is excluded: the same file on the home machine only carries the local pairing-gate token (`_home`), not a remote origin.

func PersistPath

func PersistPath(dir string) string

PersistPath is the absolute issuetap SQLite state path inside a profile directory.

func PersistUserVersion added in v0.23.0

func PersistUserVersion(path string) (version int, ok bool)

PersistUserVersion reads the persist file's schema stamp (PRAGMA user_version) over a read-only connection — never through issuetap, so no caller of this can itself migrate anything (GDK-1967: doctor prints the stamp, and the dev-migration log line names the versions it is about to move). ok is false when the file is missing or its stamp unreadable.

func RefuseBodyPlaceholders added in v0.22.0

func RefuseBodyPlaceholders(cfg *config.Config, text string) error

RefuseBodyPlaceholders is the gate every text→body write without a body to substitute from runs (create, comment): a placeholder stands for a node of the body it was read from, and this write has no such body. A Jira Server origin never has: its bodies are verbatim strings with nothing behind a marker, so the refusal does not apply (GDK-1637).

func ResetInProcess added in v0.18.0

func ResetInProcess()

ResetInProcess clears every ownership mark. Tests only — production unmarks per workspace (Runtime.Close / closeEntry).

func ResolveCreateSource added in v0.17.2

func ResolveCreateSource(ctx context.Context, cfg *config.Config, db *store.DB, project string) (string, error)

ResolveCreateSource picks the origin a create files to — the create-side sibling of WriterFor's per-key routing. A project the mirror already knows as Linear routes there (same idea as store.KeySource; create has no issue key yet, so the project key is the only routing fact); a Linear-only workspace (no Atlassian credential) always routes to Linear, even before the first team is mirrored. CLI withCreateSession and REST createWriter both call this — one routing rule, not two copies that can drift (GDK-820).

func ResolveLinkType added in v0.17.0

func ResolveLinkType(token string, catalog []jira.IssueLinkType) (lt jira.IssueLinkType, inwardDescription bool, err error)

ResolveLinkType matches token against the catalog. An all-digit token is a type id and uses the outward description convention. Otherwise the type name and its outward description are outward; a match on the inward description reports inwardDescription. The caller assigns POST issue ends because Jira's issue response displays type.inward for outwardIssue and type.outward for inwardIssue.

That last sentence is the whole direction contract, and it is measured, not read (GDK-1599, on a live Cloud site 2026-09-09): one issue's payload carried `outwardIssue: <other>` for type Blocks (inward "is blocked by", outward "blocks"), and the other issue's own changelog recorded Jira's words for the same link — "This work item is blocked by <the first>". So the issue whose element names the counterpart under outwardIssue is the one that blocks: it is the link's inward end, and it displays the outward phrase. internal/server/link.go and jira.Client.LinkIssues restate this; this comment is where the evidence lives. The measurement also settled that the built-in origin agrees — issuetap 69037e6 corrected its projection, and its conformance round-trip is green against the pinned version.

func SessionsConstructed

func SessionsConstructed() uint64

SessionsConstructed is how many times constructBuiltIn ran. Tests use a delta to prove a live session was reused.

func SetInProcess

func SetInProcess(cfg *config.Config, v bool)

SetInProcess marks/unmarks this process as the persist owner of cfg's workspace. Keyed by persist path — the same key as live — so owning one workspace's persist does not disable routing for any other (STD-3).

func SiteRelative added in v0.22.0

func SiteRelative(base, raw string) (string, error)

SiteRelative turns an origin-stated absolute URL into the site-relative path a jira.Client may request, and refuses one that points anywhere else (GDK-1639).

Jira Server states an attachment's bytes as an absolute URL and serves them nowhere else. The transport refuses absolute URLs on purpose — the Authorization header must never leave the configured site (atlhttp resolveURL) — so the address has to be reduced to a path before it can be asked for, and the reduction is exactly where that guarantee would be lost if it were skipped.

A URL on another scheme or host is refused rather than fetched credential-less: an origin that answers with someone else's address is either misconfigured or hostile, and neither is something to follow.

func SyncFetchesRemoteLinks(cfg *config.Config, w any) bool

SyncFetchesRemoteLinks is deliberately narrower than hasRemoteLinks: the remote-link read is one request per issue, which is free in-process and one tailnet round-trip per issue on a paired workspace — a full sync of a thousand-issue mirror would pay a thousand of them for a feature most issues do not use. So a paired workspace's rows arrive through the write -through path (`gadak ref` refreshes the issue it touched) and a sync leaves them alone (nil preserves). Widen this only with a protocol that answers for many issues at once.

func TransportIsEmbedded

func TransportIsEmbedded(rt http.RoundTripper) bool

TransportIsEmbedded reports whether c talks to an in-process issuetap handler. Tests use this instead of naming the unexported type.

func TransportIsServe

func TransportIsServe(rt http.RoundTripper) bool

TransportIsServe reports whether c talks to a live serve passthrough.

func VerifyPaired added in v0.17.0

func VerifyPaired(ctx context.Context, endpoint, token string) (jira.User, error)

VerifyPaired proves a pairing offer before anything is saved (GDK-433 verify-before-save): one GET /rest/api/3/myself over the exact transport the paired workspace would use. A serve that answers 401 surfaces as jira.ErrAuth; an unreachable or broken endpoint surfaces as a transport error — the caller tells those apart without retrying. The offer string itself never enters an error. Deliberately no actor header (GDK-586): verification must not provision an agent identity on an origin the workspace does not exist on yet.

func ViewerActorFrom added in v0.23.0

func ViewerActorFrom(ctx context.Context) (slug, name, kind string, ok bool)

ViewerActorFrom is viewerActorFrom exported for the server package's tests — the one way to read back what withViewerActor attached without driving a full origin write. Same shape as TransportIsEmbedded: a test seam, not a second production reader.

func Wiki

func Wiki(cfg *config.Config) (*confluence.Client, error)

Wiki is the single owner of "this workspace's Confluence client". A connected workspace gets confluence.New(site, email, token). A built-in workspace shares the in-process issuetap handler with Client.

func WithViewerActor added in v0.23.0

func WithViewerActor(ctx context.Context, slug, name, kind string) context.Context

WithViewerActor carries a per-request acting identity as this context's own: the server package derives it from headers it trusts (viewer.go) and handlerTransport stamps it over the session actor for the requests riding this context — one person's write attributed to that person, not to whatever agent the process was started as. kind is config.ActorKindPerson or Agent, and rides with the slug so X-Issuetap-Actor-Type follows the override (GDK-1973). Only the embedded transport honors it: a paired serve forwards requests this process did not witness the peer of, and its own session actor is the truth there.

Types

type AssignVerdict added in v0.24.3

type AssignVerdict int

AssignVerdict is what the assign preflight decided.

const (
	// AssignWrite sends the write.
	AssignWrite AssignVerdict = iota
	// AssignNoop: the origin already holds the target, so nothing is sent —
	// whatever the cache says and whatever force says, because sending the
	// same assignee changes nothing.
	AssignNoop
	// AssignStale: the origin's holder is not the one the cache showed.
	// Replacing them unseen is the stale-overwrite defect; the caller
	// refuses (CLI exit 75, REST 409 assignee_changed) unless force.
	AssignStale
)

func DecideAssign added in v0.24.3

func DecideAssign(current *User, cacheAssigneeID string, cacheRowKnown bool, target string, force bool) AssignVerdict

DecideAssign judges the preflight read. No-op first — the target already holds the issue on the origin, cache and force notwithstanding. Stale only when the caller did not force, the mirror has a row to compare, and that row's assignee id differs from the origin's holder. current is the origin's holder as read: a caller whose read failed handles that refusal itself and does not consult this (a nil current here would read as "unassigned", which is not a fact the caller has).

type Attachment added in v0.17.0

type Attachment = jira.Attachment

type Capabilities added in v0.22.0

type Capabilities struct {
	// IssueWrite is exactly config.HasAtlassianCredential — the Jira-family
	// write predicate the web already mirrors as `originWritable` (GDK-1090):
	// built-in, a jira-server site+PAT, a cloud site+email+token, or a
	// pairing remote. Linear is deliberately not counted: a Linear key rides
	// its own per-key path (credential.linear), which the web's write gate
	// already asks per issue. The alias is pinned by test — the wire field
	// and this axis must not drift.
	IssueWrite bool `json:"issueWrite"`
	// WikiWrite is whether origin.Wiki constructs — page writes (create,
	// edit, comment; GDK-380/381/382) can reach the origin: paired or
	// in-process issuetap always; a cloud site needs the full credential;
	// jira-server has no Confluence surface (errNoWikiServer) and Linear
	// none at all (errNoWikiOrigin). The Confluence *source* being switched
	// on is a separate axis (confluenceEnabled): this says the write path
	// exists, not that pages are mirrored.
	WikiWrite bool `json:"wikiWrite"`
	// Identity is what auth/me answers from — a credential plus a non-empty
	// cfg.Email. False on built-in and paired workspaces by construction
	// (no email to answer with) even though both write fine; that split is
	// the whole point of this block (GDK-1090's near-miss).
	Identity bool `json:"identity"`
	// OriginDeepLink is whether issues have a page on the origin the client
	// can link to. Jira family: the site's /browse/KEY (OriginBaseURL
	// carries the site). Linear: true with an empty base — a Linear
	// workspace has no site; the link is the per-issue URL the mirror
	// stores (web lib/issue-origin.ts, GDK-1308). Gadak's own tracker:
	// false — its /browse/KEY is this app, not an origin page.
	OriginDeepLink bool `json:"originDeepLink"`
	// OriginBaseURL is the site an origin page URL is built from — empty
	// except on the Jira family. Never a credential; the browse page is
	// public regardless of token state.
	OriginBaseURL string `json:"originBaseUrl"`
	// CredentialRequired is whether this workspace's write credential is a
	// site token the app's credential surface (the personal-token dialog,
	// PUT credential) can edit. True only on the Jira family reached as a
	// site: a built-in writes through its in-process origin, a paired one
	// keeps its credential in remote-origin.json on the home machine, and a
	// Linear key is config, not a site token. This is the axis the SyncTab
	// entry point needed (GDK-1148's paired residual): advising any of
	// those three to "set credentials" sells a concept that does not exist
	// there, while hiding it on a connected workspace would take away the
	// only in-app way to rotate a real token.
	CredentialRequired bool `json:"credentialRequired"`
}

Capabilities is the origin's own statement of what it can do — the block config.json carries so no surface has to guess it from the workspace kind, an empty site URL, or auth/me's identity (GDK-1152). The class of defect this closes: every new workspace kind used to cost a full audit of every surface, because each re-derived "can this origin accept X" from whatever signal was nearby. With this block the cost is one row in the table test (capabilities_table_test.go — that table is the documentation).

Every value is owned by a predicate that already existed — the same ones the write paths and auth/me answer from. Nothing here introduces a new judgment about the workspace; it only names the questions.

func CapabilitiesOf added in v0.22.0

func CapabilitiesOf(cfg *config.Config) Capabilities

CapabilitiesOf states cfg's origin capabilities. Nil-safe like Describe. The branch order mirrors Wiki()'s own (paired, then built-in, then the kind ladder) so the bool cannot drift from the constructor it summarizes.

type Comment added in v0.17.0

type Comment = jira.Comment

type CommentEditor added in v0.22.0

type CommentEditor interface {
	UpdateComment(ctx context.Context, key, id string, body json.RawMessage) (Comment, error)
	DeleteComment(ctx context.Context, key, id string) error
}

CommentEditor is PUT/DELETE /rest/api/3/issue/{key}/comment/{id} — the edit-side sibling of Writer.AddComment (GDK-1647). body is what a post sends (the caller routes through BodyValue), so an edit and a create on the same origin speak the same dialect. Jira Cloud, Jira Server and the built-in tracker implement it via jiraWriter; Linear over GraphQL. A wrapper that hides the face (the actor trailer) forwards it in trailer.go — without the forwarder every workspace with a resolved actor would read as "this origin cannot do that" while the unit tests stayed green.

func AsCommentEditor added in v0.22.0

func AsCommentEditor(w Writer) (CommentEditor, error)

AsCommentEditor returns w as CommentEditor, or ErrNoCommentEdit.

type CommentVisibility added in v0.17.0

type CommentVisibility = jira.CommentVisibility

type CreateFieldCatalog added in v0.17.0

type CreateFieldCatalog interface {
	CreateFields(ctx context.Context, projectIDOrKey, issueTypeID string) ([]CreateFieldMeta, error)
}

CreateFieldCatalog is what this project+type requires and accepts at create time — the create-side sibling of EditMeta (GDK-254). An origin that cannot answer is missing the face; callers degrade, they do not block. Linear: AsCreateFieldCatalog returns ErrNoCreateFields.

func AsCreateFieldCatalog added in v0.17.0

func AsCreateFieldCatalog(w Writer) (CreateFieldCatalog, error)

AsCreateFieldCatalog returns w as CreateFieldCatalog, or ErrNoCreateFields.

type CreateFieldMeta added in v0.17.2

type CreateFieldMeta = jira.CreateFieldMeta

type CreateMetaIssueType added in v0.17.0

type CreateMetaIssueType = jira.CreateMetaIssueType

type CreateMetaProject added in v0.17.0

type CreateMetaProject = jira.CreateMetaProject

type FieldMeta added in v0.17.0

type FieldMeta = jira.FieldMeta

type GadakProbe added in v0.16.1

type GadakProbe struct {
	IsGadak bool
	Profile string
}

GadakProbe classifies a loopback GET to the progress endpoint. Exported so cmd/gadak's port fallback and views open use this single copy (GDK-423). Guards: ProbeTimeout context, no Origin header, X-Gadak required, profile from X-Gadak-Profile.

func ProbeGadakOnPort added in v0.16.1

func ProbeGadakOnPort(port string, timeout time.Duration) GadakProbe

type IssueAssigneeReader added in v0.24.3

type IssueAssigneeReader interface {
	IssueAssignee(ctx context.Context, key string) (*User, error)
}

IssueAssigneeReader is the preflight read of the assign write (GDK-2063): the issue's current assignee on the origin, one read. `gadak assign` compares it with the mirror's issues.assignee_id before writing — a mismatch means the origin moved since the mirror last saw the issue, and replacing that assignee silently is the stale-overwrite defect. nil is "unassigned". Jira Cloud, Jira Server and the built-in tracker answer via jiraWriter (GET /issue/{key}?fields=status,assignee, the same read claim's Cloud fallback judges); Linear via linearWriter (one issue(id:) fetch). An origin that cannot answer does not implement the face, and the caller treats that like a failed read — it says so, never writes blind.

func AsIssueAssigneeReader added in v0.24.3

func AsIssueAssigneeReader(w Writer) (IssueAssigneeReader, error)

AsIssueAssigneeReader returns w as IssueAssigneeReader, walking wrappers (the actor trailer), or ErrNoIssueAssigneeRead.

type IssueLink = jira.IssueLink

type IssueLinkType added in v0.17.2

type IssueLinkType = jira.IssueLinkType

type IssueLinker added in v0.17.0

type IssueLinker interface {
	IssueLinkTypes(ctx context.Context) ([]IssueLinkType, error)
	LinkIssues(ctx context.Context, typeID, outwardKey, inwardKey string) error
	// IssueLinks is the live projection with link ids (the mirror carries
	// none), and DeleteIssueLink takes one of those ids back (GDK-1205).
	IssueLinks(ctx context.Context, key string) ([]IssueLink, error)
	DeleteIssueLink(ctx context.Context, id string) error
}

IssueLinker is GET /rest/api/3/issueLinkType plus POST /rest/api/3/issueLink. Names and inward/outward descriptions can be renamed; writes send the id. Linear has relations but no counterpart in this adapter yet (GDK-19): AsIssueLinker returns ErrNoIssueLinks.

func AsIssueLinker added in v0.17.0

func AsIssueLinker(w Writer) (IssueLinker, error)

AsIssueLinker returns w as IssueLinker, or ErrNoIssueLinks.

type MediaRef added in v0.17.0

type MediaRef interface {
	MediaRef(ctx context.Context, attachmentID string) (mediaID, filename string, err error)
}

MediaRef resolves an attachment id to the media UUID Jira needs in an ADF comment node plus the filename. Linear has no counterpart; AsMediaRef returns ErrNoMediaRef and the comment path already degrades on that error.

func AsMediaRef added in v0.17.0

func AsMediaRef(w Writer) (MediaRef, error)

AsMediaRef returns w as MediaRef, or ErrNoMediaRef.

type NamedID added in v0.17.0

type NamedID = jira.NamedID

type PairingError added in v0.17.0

type PairingError struct {
	// contains filtered or unexported fields
}

PairingError is the remote-device first line for a failed home-serve round trip: cause and next action, no REST method/path. err, when set, is the typed client error the folded response would have produced — wrapped, not swallowed, so callers that classify on it (the sync pass's 501 degrades, ref's upgrade hint) keep seeing what they classify on.

answer is set only by folds of a response (the 501 route-not-implemented sentence): it marks the error as the origin's answer so the client's Do loops skip the retry ladder (httppolicy.IsAnswer, GDK-1762) — the measured defect was every new verb on a paired workspace waiting out 1+2+4+8 s of backoff before the upgrade hint. Dial failures folded into a PairingError leave answer false and keep their retries: a transport error may heal; an answer will not change.

func (*PairingError) Answer added in v0.22.0

func (e *PairingError) Answer() bool

Answer implements httppolicy's folded-answer marker; see the struct comment for which constructors set it.

func (*PairingError) Error added in v0.17.0

func (e *PairingError) Error() string

func (*PairingError) Unwrap added in v0.22.0

func (e *PairingError) Unwrap() error

type PersistForwardRefusedError added in v0.23.0

type PersistForwardRefusedError struct {
	Path         string // the persist file
	Have         int    // schema version found in the file
	Want         int    // schema version this build writes
	BuildVersion string // the dev build's own version string
}

PersistForwardRefusedError means this open refused to migrate the built-in origin's persist forward because the binary is a dev build and the file may still belong to an installed release (GDK-1967) — the persist-side twin of store.SchemaForwardRefusedError, wrapped around issuetap's own refusal so the message names the build, the override and the copy recipe in gadak's words. The file was left exactly as the release wrote it. Recognise it with errors.As.

func (*PersistForwardRefusedError) Error added in v0.23.0

type RemoteLink = jira.RemoteLink

type RemoteLinker added in v0.19.2

type RemoteLinker interface {
	RemoteLinks(ctx context.Context, key string) ([]RemoteLink, error)
	SetRemoteLink(ctx context.Context, key string, rl RemoteLink) error
	DeleteRemoteLink(ctx context.Context, key, id string) error
}

RemoteLinker is Jira's remote issue links (GDK-1032): a pointer at something outside this tracker. gadak writes them only on an issuetap-backed origin (builtIn / paired) — a Cloud site would show them to the whole team, and a cross-workspace pointer is personal.

func AsRemoteLinker added in v0.19.2

func AsRemoteLinker(cfg *config.Config, w Writer) (RemoteLinker, error)

AsRemoteLinker returns w as RemoteLinker when this workspace's origin is issuetap-backed, else ErrNoRemoteLinks. The face test alone would not do: a connected Cloud site is the same *jira.Client type and would answer the route, publishing a personal cross-workspace pointer to the whole team.

type Sprint added in v0.22.0

type Sprint struct {
	ID    int64
	Name  string
	State string
}

Sprint is one sprint as the origin states it back after a write.

type SprintBoard added in v0.22.0

type SprintBoard interface {
	MoveToSprint(ctx context.Context, sprintID int64, keys []string) error
	MoveToBacklog(ctx context.Context, keys []string) error
	CreateSprint(ctx context.Context, boardID int64, name, goal string) (Sprint, error)
	UpdateSprint(ctx context.Context, sprintID int64, fields map[string]any) (Sprint, error)
}

SprintBoard is the sprint surface of the write path (GDK-1655). A Jira origin answers it from Jira Software's boards and sprints; a Linear origin from its cycles — one board per team, the cycle ids derived into the sprint integer space (GDK-1667). What Linear cannot carry is the state verb: a cycle begins and ends by its dates, so UpdateSprint's "state" key refuses (ErrLinearCycleByDates) instead of guessing. The built-in tracker has no sprints at all; there is no fallback — a workspace on it says so.

func AsSprintBoard added in v0.22.0

func AsSprintBoard(w Writer) (SprintBoard, error)

AsSprintBoard returns w as SprintBoard, or ErrNoSprints.

type Transition added in v0.17.0

type Transition = jira.Transition

type User added in v0.17.0

type User = jira.User

type Version added in v0.17.2

type Version = jira.Version

type VersionCatalog added in v0.17.0

type VersionCatalog interface {
	ProjectVersions(ctx context.Context, projectKey string) ([]Version, error)
	CreatesVersionsByName() bool
}

VersionCatalog is GET /rest/api/3/project/{key}/versions. Linear has no counterpart (GDK-516): AsVersionCatalog returns ErrNoVersionCatalog.

CreatesVersionsByName is the issuetap mint-by-name capability (GDK-678): a fixVersions add {"name": token} creates the version when it is missing from the catalog. Cloud Jira is false — unknown names 400, and creating a version is a separate project-admin permission. Same shape as sync.OSNotifier.Supported: a boolean on the face that already owns the verb, not a workspace-kind string.

func AsVersionCatalog added in v0.17.0

func AsVersionCatalog(w Writer) (VersionCatalog, error)

AsVersionCatalog returns w as VersionCatalog, or ErrNoVersionCatalog.

type Writer added in v0.16.1

type Writer interface {
	CreateMeta(ctx context.Context, projects []string) ([]CreateMetaProject, error)
	CreateIssue(ctx context.Context, fields map[string]any) (string, error)
	EditMeta(ctx context.Context, key string) (map[string]FieldMeta, error)
	UpdateFields(ctx context.Context, key string, fields map[string]any) error
	EditIssue(ctx context.Context, key string, fields, update map[string]any) error
	Transitions(ctx context.Context, key string) ([]Transition, error)
	Transition(ctx context.Context, key, transitionID string, fields map[string]any, comment json.RawMessage) error
	AddComment(ctx context.Context, key string, adf json.RawMessage, visibility *CommentVisibility, internal bool) (Comment, error)
	SetAssignee(ctx context.Context, key, accountID string) error
	SearchUsers(ctx context.Context, query string) ([]User, error)
	PriorityCatalog(ctx context.Context) ([]NamedID, error)
	Upload(ctx context.Context, key, filename string, file io.Reader) ([]Attachment, error)
}

Writer is the write surface of an origin: the verbs every origin implements and the server and CLI call when writing through. Jira (connected) and built-in (issuetap speaks the Jira API) satisfy it via jiraWriter wrapping *jira.Client; a Linear adapter implements the same verbs over GraphQL (GDK-358). The method vocabulary is Jira-shaped (EditMeta, Transitions) so existing callers keep working; the types are origin DTOs (GDK-665), not internal/jira names.

Capability negotiation stays EditMeta/CreateMeta: an origin that cannot edit a field omits it there, and the existing UI already turns fields on and off from that answer. An unsupported verb returns an honest error, never a silent no-op.

Optional faces (VersionCatalog, IssueLinker, CreateFieldCatalog, MediaRef) are not part of Writer. Callers type-assert via As*; a missing face returns the matching ErrNo* string, never a silent no-op (GDK-641).

func WithActorTrailer added in v0.21.0

func WithActorTrailer(w Writer, cfg *config.Config) Writer

WithActorTrailer stamps agent-authored writes with the actor trailer. It returns w unchanged when no actor resolves, when actor.trailer is explicitly false (config set actor.trailer false — the one switch for the trailer and any ledger derived from it), or when the workspace origin is the built-in tracker, local or paired, where X-Issuetap-Actor already carries the identity. The origin's kind has a single owner, (*config.Config).OriginType — never re-derived from the site host.

func WriterFor added in v0.16.1

func WriterFor(cfg *config.Config, source string) (Writer, error)

WriterFor picks the write path for one issue's source — the caller reads it from the mirror (store.KeySource), because a key's shape cannot tell a Linear "MID-5" from a Jira "MID-5". Jira and built-in rows share the Jira client (wrapped); "linear" routes to the GraphQL adapter (GDK-361). An empty source (a key the mirror does not know yet, or a create) routes to the default origin.

Jump to

Keyboard shortcuts

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