plugins¶
Package plugins provides typed build services (GDS 0010) and publishers (GDS 0009). Build plugins transform source, complete HTML and static assets through Plugin, Plugin_Session, Text_Result and Assets_Result. The CLI runs installed programs in separate processes: a failing plugin cannot mutate the host’s memory. Native linked callbacks remain trusted application code, not a memory-isolation boundary.
The publisher interface defines how a complete, built site reaches a host, such as GitHub Pages, through a publisher that an application links in or that runs as an installed program.
A publisher is a Publisher value: an ID, versions, and typed procedures. An application lists the publishers it links in a Registry, finds one by ID, and works through a few owners, each released by its own procedure:
Session load / unload one publisher, its configuration and target
Snapshot snapshot / release_snapshot a frozen, checked copy of a built site
Plan plan / release_plan what publishing the snapshot would change
Result publish, status, recover / release_result a verified outcome
Each owner keeps its memory in an arena of its own, taken from the allocator its procedure was called with; releasing it frees everything, and releasing a zero or failed owner is harmless. Failure is a Problem with directions, never a panic; when an allocator refuses memory, a procedure returns plugins.memory (exit 3) and nothing it made halfway. A publisher runs only when an application calls it: nothing here discovers, downloads, or starts code by itself.
Installed publishers are programs that speak a JSON Lines protocol (process_publisher and serve); the machine registry (read_machine, register, unregister) records which programs a user chose to run, pinned by their SHA-256.
Types
- plugins.Assets_Context :: struct¶
-
- session: ^Plugin_Session¶
- assets: []Plugin_Asset¶
- allocator: runtime.Allocator¶
- plugins.Assets_Proc :: #type proc(ctx: ^Assets_Context) -> Problem¶
-
Assets_Proc supplies portable generated files; collect_assets owns copied output.
- plugins.Capability :: enum u8¶
-
Capability is an optional operation a publisher has.
- Status¶
-
status: the outcome of an operation, read again.
- Recover¶
-
recover: settle an operation interrupted at its remote boundary.
- plugins.Change :: struct¶
-
Change is one file publishing adds, changes, or removes.
- path: string¶
- kind: Change_Kind¶
- plugins.Change_Kind :: enum u8¶
-
Change_Kind is what publishing does to a file of the target.
- Added¶
- Changed¶
- Removed¶
- plugins.Entry :: struct¶
-
Entry is one file of a snapshot: its path from the root, with / between folders, its size, and the SHA-256 of its contents. Schema 1 publishes every file as a regular, non-executable file.
- path: string¶
- size: i64¶
- digest: [32]u8¶
- plugins.Handshake :: struct¶
-
Handshake is the first line a publisher program writes: the protocol, the highest minor version of each major version it speaks, the interface version it was built against, what it is, its optional operations, and the snapshot schemas it reads.
- protocol: string¶
- id: string¶
- name: string¶
- version: string¶
- capabilities: []string¶
- snapshot_schemas: []int¶
- hooks: []string¶
-
build-plugin protocol; absent for publishers.
- plugins.Html_Context :: struct¶
-
- session: ^Plugin_Session¶
- input: Html_Input¶
- text: string¶
- allocator: runtime.Allocator¶
- plugins.Html_Input :: struct¶
-
- path: string¶
- docname: string¶
- language: string¶
- text: string¶
- assets_url: string¶
- plugins.Html_Proc :: #type proc(ctx: ^Html_Context) -> Problem¶
-
Html_Proc supplies complete UTF-8 HTML in the callback allocator before staging.
- plugins.Line_Reader :: struct¶
-
Line_Reader reads lines from a file, a chunk at a time, keeping what follows a line.
- file: ^os.File¶
- buffer: [16 * 1024]u8¶
- start: int¶
- end: int¶
- plugins.Load_Context :: struct¶
-
Load_Context is what a publisher’s load gets: the session to fill in (source, target, data), and the allocator of its memory.
- allocator: runtime.Allocator¶
- plugins.Load_Options :: struct¶
-
Load_Options are a session’s settings. Zero values are the defaults.
- config: string¶
-
the publisher’s configuration file, such as pages.toml.
- dry_run: bool¶
-
the session only plans: it never writes to the target.
- wait_seconds: int¶
-
wait_seconds is how long publish waits for a deployment to be confirmed: 0, the publisher’s default; below 0, not at all (the outcome is then at most Accepted).
- cancel: ^bool¶
-
cancel, when set, asks the publisher to stop once the value it points to is true; it cannot undo a write the target accepted. The caller keeps it alive.
- cancelled: proc() -> bool¶
-
cancelled is an optional cancellation probe, polled by the process adapter. A signal handler may set cancel with an atomic store instead; both are checked.
- request_timeout: time.Duration¶
-
request_timeout bounds the whole exchange with a program, including writing its request. Zero means DEFAULT_REQUEST_TIMEOUT; negative values are refused.
- plugins.Load_Proc :: #type proc(ctx: ^Load_Context) -> Problem¶
-
Load_Proc reads the publisher’s configuration (ctx.session.options.config) and fills in the session: source, target, and data, allocated with ctx.allocator, the session’s arena. A problem it returns is copied out before the session’s memory is freed.
- plugins.Machine :: struct¶
-
Machine is the registry’s entries.
- entries: []Machine_Entry¶
- plugins.Machine_Entry :: struct¶
-
Machine_Entry is one registered program.
- id: string¶
- name: string¶
- version: string¶
- path: string¶
-
absolute.
- sha256: string¶
-
the program’s SHA-256, in hexadecimal.
- capabilities: bit_set[Capability]¶
- registered: string¶
-
the date it was registered, YYYY-MM-DD.
- protocol_name: string¶
-
empty is the original publisher protocol.
- hooks: []string¶
-
build-plugin hook names; empty for publishers.
- plugins.Plan :: struct¶
-
Plan is what publishing a snapshot to a session’s target would do: the generation it publishes (the snapshot’s digest), the target state it was compared with (baseline, as the publisher names it; „“ for an empty target), whether the target already holds the generation, and the changes. plan makes it and release_plan frees it; a zero Plan is not usable, and a plan is used only with the session and snapshot it was made from.
- generation: [32]u8¶
- target: string¶
- baseline: string¶
- unchanged: bool¶
- summary: string¶
-
what the publisher wants a person to see first, such as the account.
- id: string¶
-
the plan’s name in its session, for the process protocol.
- data: rawptr¶
-
the publisher’s own.
- session: ^Memory¶
- memory: ^Memory¶
- plugins.Plan_Context :: struct¶
-
Plan_Context is what a publisher’s plan gets: its session, the snapshot to compare, and the plan to fill in, whose generation is already set.
- allocator: runtime.Allocator¶
- plugins.Plan_Proc :: #type proc(ctx: ^Plan_Context) -> Problem¶
-
Plan_Proc compares ctx.snapshot with the target, reading only, and fills in ctx.plan, allocating in ctx.allocator, the plan’s arena.
- plugins.Plugin :: struct¶
-
Plugin is an explicit table of services. A publisher is one kind of plugin; build plugins provide typed source, HTML, and asset procedures. Nil means absent. A table cannot mix publication with build hooks: a build never invokes a publisher.
- id: string¶
- name: string¶
- version: string¶
- load: Plugin_Load_Proc¶
- unload: Plugin_Unload_Proc¶
- source: Source_Proc¶
- assets: Assets_Proc¶
- executable: string¶
-
process_plugin sets this; native tables leave it empty.
- plugins.Plugin_Asset :: struct¶
-
Plugin_Asset is one generated file. path is a relative portable output path. The host prefixes it with _static/plugins/ID, refuses duplicates and stages every file.
- path: string¶
- data: []u8¶
- plugins.Plugin_Load_Context :: struct¶
-
- session: ^Plugin_Session¶
- allocator: runtime.Allocator¶
- plugins.Plugin_Load_Proc :: #type proc(ctx: ^Plugin_Load_Context) -> Problem¶
-
Plugin_Load_Proc prepares session-owned state and declares loaded inputs.
- plugins.Plugin_Options :: struct¶
-
Plugin_Options are borrowed only by load_plugin, which copies their strings.
- config: string¶
- project: string¶
- builder: string¶
- language: string¶
- request_timeout: time.Duration¶
-
zero: one minute; negative: invalid.
- cancelled: proc() -> bool¶
- plugins.Plugin_Registry :: struct¶
-
Plugin_Registry borrows explicit tables. Keep them alive while their sessions exist.
- plugins.Plugin_Session :: struct¶
-
Plugin_Session owns load state. Only data, dependencies and cache_key belong to the plugin. The SDK retains its descriptor, copied options and memory owner across calls.
- options: Plugin_Options¶
- data: rawptr¶
- dependencies: []string¶
-
additional files read by load; host hashes them before reuse.
- cache_key: string¶
-
configuration outside those files, such as a selected env value.
- memory: ^Memory¶
- plugins.Plugin_Unload_Proc :: #type proc(session: ^Plugin_Session)¶
-
Plugin_Unload_Proc closes resources, including after partial load; the SDK frees memory.
- plugins.Problem :: struct¶
-
Problem is a failure: its code („pages.credential“), title, the path or name it concerns, what went wrong, a hint that says what to do, and the exit status a command returns for it (0: no problem).
- code: string¶
- title: string¶
- path: string¶
- message: string¶
- hint: string¶
- exit: int¶
- plugins.Publish_Context :: struct¶
-
Publish_Context is what a publisher’s publish gets: a plan its plan made, and the snapshot it was made from, which publish has checked again.
- allocator: runtime.Allocator¶
- plugins.Publish_Proc :: #type proc(ctx: ^Publish_Context) -> Result¶
-
Publish_Proc carries out ctx.plan and returns its verified outcome, allocated in ctx.allocator, the result’s arena.
- plugins.Publisher :: struct¶
-
Publisher describes a publisher: what it is, the interface version it was built against, its optional operations, and its procedures. status and recover are nil unless capabilities lists them. executable is set only by process_publisher, for an installed program; a publisher linked in leaves it „“.
- id: string¶
- name: string¶
- version: string¶
- capabilities: bit_set[Capability]¶
- unload: Unload_Proc¶
- publish: Publish_Proc¶
- status: Status_Proc¶
- recover: Recover_Proc¶
- executable: string¶
- plugins.Recover_Context :: struct¶
-
Recover_Context asks the publisher to settle an operation interrupted at its target.
- allocator: runtime.Allocator¶
- plugins.Recover_Proc :: #type proc(ctx: ^Recover_Context) -> Result¶
-
Recover_Proc settles an operation interrupted at the target’s boundary; the result is allocated in ctx.allocator.
- plugins.Registry :: struct¶
-
Registry lists the publishers an application offers. It borrows the slice, which the caller keeps alive and unchanged while the registry is used.
- plugins.Result :: struct¶
-
Result is the outcome of publish, status, or recover: a State, the operation’s ID, the generation it concerns (hexadecimal), the URL the site is seen at, and, unless the outcome is verified, a problem that explains it. Its strings are in its own memory, which release_result frees.
- operation: string¶
- generation: string¶
- url: string¶
- memory: ^Memory¶
- plugins.Session :: struct¶
-
Session is one publisher, loaded with its configuration and target. load makes it and unload frees it; a zero Session is not usable. data is the publisher’s own state, in the session’s memory; only its procedures read it.
- options: Load_Options¶
- target: string¶
-
the target, for people: „github.com/owner/repo, branch gh-pages“.
- data: rawptr¶
- memory: ^Memory¶
- plugins.Snapshot :: struct¶
-
Snapshot is a complete, checked site: the folder that holds it, its files in order of their paths‘ bytes, their total size, and its digest, which names the generation. snapshot makes it and release_snapshot frees it; a zero Snapshot is not usable.
- root: string¶
- bytes: i64¶
- digest: [32]u8¶
- mode: Snapshot_Mode¶
- memory: ^Memory¶
- plugins.Snapshot_Mode :: enum u8¶
-
Snapshot_Mode is how a snapshot holds its files.
- Copy¶
-
copies the folder into a private folder, which release_snapshot removes.
- Borrow¶
-
checks the folder where it is; the caller keeps it unchanged and keeps it.
- Adopt¶
-
checks a private folder where it is, and release_snapshot removes it.
- plugins.Snapshot_Options :: struct¶
-
Snapshot_Options bound a snapshot. Zero values are the defaults.
- mode: Snapshot_Mode¶
- temp_dir: string¶
-
Copy: where the private folder is made; „“: the system’s.
- max_files: int¶
-
0: 100,000.
- max_file_bytes: i64¶
-
0: 100 MiB less a byte, the largest file GitHub accepts.
- max_bytes: i64¶
-
0: 1 GiB, the largest GitHub Pages site.
- no_index: bool¶
-
accept a site without index.html at its root.
- plugins.Source :: struct¶
-
Source is what a session publishes, as its publisher’s configuration says: a Guidedog project to build as HTML (with warnings as errors when strict), or a folder holding a site already built; and the URL the site is seen at.
- project: string¶
- site: string¶
- base_url: string¶
- strict: bool¶
- plugins.Source_Context :: struct¶
-
Hook inputs are borrowed for the call. Set text to the complete replacement, using allocator for generated text. The SDK returns an owned copy, including unchanged text.
- session: ^Plugin_Session¶
- input: Source_Input¶
- text: string¶
- allocator: runtime.Allocator¶
- plugins.Source_Input :: struct¶
-
Source_Input describes one complete primary document before parsing. Includes are read by the engine and are not silently passed through a primary-source hook.
- path: string¶
- docname: string¶
- format: string¶
- language: string¶
- text: string¶
- plugins.Source_Proc :: #type proc(ctx: ^Source_Context) -> Problem¶
-
Source_Proc supplies complete UTF-8 source in the callback allocator before parsing.
- plugins.State :: enum u8¶
-
State is where a publication stands. The zero value, Not_Started, is no outcome.
- Not_Started¶
- Unchanged¶
-
the target already holds this generation; nothing was written.
- Accepted¶
-
the host accepted the generation; its deployment is not confirmed.
- Pending¶
-
the deployment of the generation is under way.
- Live¶
-
the generation is confirmed live.
- Failed¶
-
nothing was published, or the deployment of the generation failed.
- Unknown¶
-
the outcome is not known: inspect it before writing again.
- plugins.Status_Context :: struct¶
-
Status_Context asks for the outcome of the operation named operation; „“ asks for the last one the publisher knows of.
- operation: string¶
- allocator: runtime.Allocator¶
- plugins.Status_Proc :: #type proc(ctx: ^Status_Context) -> Result¶
-
Status_Proc reads an operation’s outcome again, writing nothing; the result is allocated in ctx.allocator.
- plugins.Text_Result :: struct¶
-
Text_Result and Assets_Result own hook values; release them before unloading session.
- text: string¶
- memory: ^Memory¶
- plugins.Unload_Proc :: #type proc(session: ^Session)¶
-
Unload_Proc releases what load acquired outside the session’s arena: a lock, a child program, a token’s bytes. It is called after a failed load too.
- plugins.Version :: struct¶
-
Version is a major and minor version. A minor version adds only optional things to the major version it belongs to; a major version changes or removes something.
- major: u16¶
- minor: u16¶
Procedures
- plugins.capabilities_named :: proc(names: []string) -> bit_set[Capability]¶
-
capabilities_named are the capabilities names lists; unknown names are ignored.
- plugins.capability_names :: proc(caps: bit_set[Capability]) -> []string¶
-
capability_names are the protocol’s names of the capabilities in caps, in a list allocated with context.allocator.
- plugins.check_plugin :: proc(r: Plugin_Registry, id: string, options: Plugin_Options) -> Problem¶
-
check_plugin exercises a declared build service with representative valid inputs. It checks two fresh loads, repeated results and assets; it never invokes publishers. The caller owns returned problem text in context.allocator. Native tables run trusted code directly; use process_plugin on a verified executable for crash isolation. Passing checks demonstrates interoperability, not a sandbox or a safety proof.
- plugins.collect_assets :: proc(s: ^Plugin_Session) -> Assets_Result¶
-
collect_assets returns generated files in its own arena. The host decides when and where to stage them; a plugin receives no writable output-directory handle.
- plugins.config_dir :: proc() -> (string, Problem)¶
-
config_dir is the folder of Guidedog’s machine state: $GUIDEDOG_CONFIG_DIR, or a guidedog folder in the user’s configuration folder. It allocates the path.
- plugins.digest_hex :: proc(d: [32]u8) -> string¶
-
digest_hex is a digest in lowercase hexadecimal, allocated with context.allocator.
- plugins.exit_status :: proc(r: Result) -> int¶
-
exit_status is the exit status a command returns for r: 0 when its outcome is verified (Live or Unchanged), EXIT_ACCEPTED for Accepted or Pending, EXIT_UNKNOWN for Unknown, and its problem’s status (1 at least) for Failed or no outcome.
- plugins.field_array :: proc(o: json.Object, key: string) -> (json.Array, bool)¶
-
field_array is the array field key of o.
- plugins.field_bool :: proc(o: json.Object, key: string) -> (bool, bool)¶
-
field_bool is the boolean field key of o.
- plugins.field_int :: proc(o: json.Object, key: string) -> (int, bool)¶
-
field_int is the integer field key of o.
- plugins.field_object :: proc(o: json.Object, key: string) -> (json.Object, bool)¶
-
field_object is the object field key of o.
- plugins.field_string :: proc(o: json.Object, key: string) -> (string, bool)¶
-
field_string is the string field key of o; ok is false when it is absent or not a string.
- plugins.find_entry :: proc(m: Machine, id: string) -> (Machine_Entry, bool)¶
-
find_entry is the entry of m with the ID id, and whether there is one.
- plugins.find_plugin :: proc(r: Plugin_Registry, id: string) -> (Plugin, bool)¶
-
find_plugin returns a borrowed descriptor and whether its exact ID exists in r.
- plugins.find_publisher :: proc(r: Registry, id: string) -> (Publisher, bool)¶
-
find_publisher returns the publisher with exactly the ID id, and whether r has it.
- plugins.inspect_entry :: proc(path: string) -> (Machine_Entry, Problem)¶
-
inspect_entry describes the program at path as a registry entry: it checks that path is an absolute path to a native program (not a script), takes its SHA-256, and runs it in protocol mode to read its handshake. Running it runs its code; call it only for a program the user chose. The entry is allocated with context.allocator.
- plugins.inspect_program :: proc(executable: string, timeout := HANDSHAKE_TIMEOUT) -> (Handshake, Problem)¶
-
inspect_program runs the program at executable in protocol mode, reads its handshake, and ends it. Running it runs its code: call it only for a program the user chose. The caller owns the returned handshake, allocated with context.allocator.
- plugins.load :: proc(r: Registry, id: string, options: Load_Options) -> (Session, Problem)¶
-
load opens a session of the publisher id of r with options: it checks the registry, and has the publisher read its configuration and target. The caller owns the session, made with context.allocator, and frees it with unload, also after a failed load.
- plugins.load_plugin :: proc(r: Plugin_Registry, id: string, options: Plugin_Options) -> (Plugin_Session, Problem)¶
-
load_plugin opens one build plugin. The session owns copied options and load state. Call unload_plugin after success or failure; no publisher is invoked here.
- plugins.machine_path :: proc() -> (string, Problem)¶
-
machine_path is the registry’s file: MACHINE_FILE in config_dir.
- plugins.memory :: proc() -> Problem¶
-
memory is plugins.memory (exit 3), the problem of work whose memory ran out. Nothing in it is allocated.
- plugins.memory_refused :: proc(allocator: runtime.Allocator) -> bool¶
-
memory_refused reports whether an SDK owner’s allocator has refused memory. Check it before a write after using helpers that do not return allocation errors. Other allocators are not inspected: their callers must check each allocation result.
- plugins.parse_json :: proc(text: string, max_nesting := MAX_NESTING) -> (json.Value, Problem)¶
-
parse_json parses text as JSON, with integers as integers, refusing text that is not UTF-8, nesting deeper than max_nesting, and duplicate keys. The value is allocated with context.allocator.
- plugins.parse_message :: proc(line: string) -> (json.Object, Problem)¶
-
parse_message parses one line as a JSON object, as parse_json does.
- plugins.plan :: proc(s: ^Session, snapshot: ^Snapshot) -> (Plan, Problem)¶
-
plan compares snapshot with s’s target and returns what publishing it would change. It only reads the target. The caller owns the plan, made with context.allocator, and frees it with release_plan.
- plugins.process_html :: proc(s: ^Plugin_Session, input: Html_Input) -> Text_Result¶
-
process_html receives a complete rendered HTML page before it is staged. Its owned Text_Result keeps the replacement and problem until release_text frees them.
- plugins.process_plugin :: proc(entry: Machine_Entry) -> (Plugin, Problem)¶
-
process_plugin makes a typed build-plugin table from inspected machine metadata. Verify its checksum with verify_entry before offering it in a registry.
- plugins.process_publisher :: proc(id, name, version, executable: string, capabilities: bit_set[Capability]) -> Publisher¶
-
process_publisher is a Publisher that runs the program executable in protocol mode, one child program a session: load starts it and checks its handshake, unload ends it. It is the same publisher as the one linked into that program, reached through the process protocol. id, name, version, and capabilities are what the program declared when it was registered; a handshake that differs is refused.
- plugins.process_source :: proc(s: ^Plugin_Session, input: Source_Input) -> Text_Result¶
-
process_source returns an owned replacement. An absent source hook is an identity.
- plugins.publish :: proc(s: ^Session, snapshot: ^Snapshot, pl: ^Plan) -> Result¶
-
publish publishes the plan pl, made by plan from s and snapshot, after checking that the snapshot’s files are still what was planned. It returns the outcome, which the caller frees with release_result. A session made with dry_run never publishes.
- plugins.publisher_plugin :: proc(p: Publisher) -> Plugin¶
-
publisher_plugin wraps an existing publisher without changing its API or protocol.
- plugins.read_handshake :: proc(r: ^Line_Reader) -> (h: Handshake, p: Problem)¶
-
read_handshake reads and checks a publisher program’s handshake, allocated with context.allocator; the caller owns it.
- plugins.read_line :: proc(r: ^Line_Reader, limit: int) -> (line: string, p: Problem)¶
-
read_line reads the next line, without its line break, allocated with context.allocator. It fails at the end of the input, on a read error, or when the line is over limit bytes.
- plugins.read_machine :: proc(path: string) -> (Machine, Problem)¶
-
read_machine reads the registry at path; a missing file is an empty registry. The entries are allocated with context.allocator.
- plugins.read_plugin_config :: proc(ctx: ^Plugin_Load_Context) -> (string, Problem)¶
-
read_plugin_config reads and fingerprints the configuration bytes used by load.
- plugins.read_plugin_file :: proc(ctx: ^Plugin_Load_Context, path: string) -> (string, Problem)¶
-
read_plugin_file reads a UTF-8 load dependency, bounded to 8 MiB. Relative paths are resolved from options.project. Its bytes contribute to cache_key, so a file changed between load and the host’s later hash cannot associate old state with a new key.
- plugins.recover :: proc(s: ^Session) -> Result¶
-
recover settles an operation interrupted at the target’s boundary: it reads what the target holds and finishes or reports the operation, never forcing the target back. The caller frees the result with release_result.
- plugins.register :: proc(path: string, e: Machine_Entry) -> Problem¶
-
register adds e to the registry at path, which it creates, with its folder, readable only by the user. It refuses an ID that is registered already. What it reads and writes is allocated with context.allocator.
- plugins.release_assets :: proc(r: ^Assets_Result)¶
-
release_assets frees owned files and problems; zero or repeated release is safe.
- plugins.release_plan :: proc(pl: ^Plan)¶
-
release_plan frees a plan. A zero or released plan is harmless.
- plugins.release_result :: proc(r: ^Result)¶
-
release_result frees a result. A zero or released result is harmless.
- plugins.release_snapshot :: proc(s: ^Snapshot)¶
-
release_snapshot frees s and, unless it was borrowed, removes its private folder. A zero or released snapshot is harmless.
- plugins.release_text :: proc(r: ^Text_Result)¶
-
release_text frees the result’s owned memory and clears it; repeated release is safe.
- plugins.select_version :: proc(h: Handshake) -> (Version, bool)¶
-
select_version is the protocol version a host speaking PROTOCOL_VERSION and a publisher whose handshake is h share: the same major version, at the lower minor version; false when they share none.
- plugins.serve :: proc(r: Registry, id: string, input, output: ^os.File) -> int¶
-
serve runs the publisher id of r in protocol mode for a host: it writes the handshake to output, then answers the host’s requests from input until the host unloads it or closes input. A publisher program calls it when started with PROTOCOL_FLAG. It returns the program’s exit status: 0, or 2 when the registry has no such publisher. It allocates owners and one arena per request with context.allocator. Use a backing allocator that frees memory, so repeated requests retain only the current plan.
- plugins.serve_plugin :: proc(p: Plugin, input, output: ^os.File) -> int¶
-
serve_plugin exposes a Plugin table over standard streams. Publisher tables retain the released publisher protocol. Build tables use the build-plugin protocol. Return to main before os.exit so the program’s own deferred cleanup runs. The server owns and frees request and session memory before returning an exit status.
- plugins.snapshot :: proc(dir: string, options: Snapshot_Options = {}) -> (Snapshot, Problem)¶
-
snapshot freezes the site in dir: every regular file below it, checked and digested, held as options.mode says. It refuses a folder with a symbolic link or special file, two paths for one file, paths that differ only in case or that Git or a static host cannot serve, a site over the limits, and one without index.html; a refusal leaves no private folder behind. The caller owns the snapshot, made with context.allocator, and frees it with release_snapshot.
- plugins.state_name :: proc(s: State) -> string¶
-
state_name is the protocol’s name for s, such as „live“.
- plugins.state_named :: proc(name: string) -> (State, bool)¶
-
state_named is the State the protocol calls name, and whether there is one.
- plugins.status :: proc(s: ^Session, operation: string) -> Result¶
-
status reads the outcome of operation again („“ for the last one), without writing. The caller frees the result with release_result.
- plugins.supported :: proc(v: Version) -> bool¶
-
supported tells whether this package can work with a publisher built against v: the same major version, and a minor version it knows.
- plugins.try_lock :: proc(file: ^os.File) -> bool¶
-
Verfügbarkeit: Windows, Darwin, Linux.
try_lock takes an exclusive, nonblocking lock on file, which it borrows. Close the file after unlock to release it. It returns false if locked or unusable. Opens conflict even in one process; a process-wide fcntl lock cannot protect two linked publishers.
- plugins.unload :: proc(s: ^Session)¶
-
unload closes s: the publisher’s own state, then s’s memory. A zero session is harmless.
- plugins.unload_plugin :: proc(s: ^Plugin_Session)¶
-
unload_plugin closes resources with the session’s allocator, including failed load.
- plugins.unlock :: proc(file: ^os.File) -> bool¶
-
Verfügbarkeit: Windows, Darwin, Linux.
unlock releases a lock taken with try_lock, borrowing file without closing it. It returns false for an unusable file. Explicit release also unlocks descriptors briefly inherited by another thread’s fork; closing only the parent’s copy would not.
- plugins.unregister :: proc(path, id: string) -> Problem¶
-
unregister removes the entry id from the registry at path. It removes nothing else: not the program, a site, nor a stored credential. It allocates with context.allocator.
- plugins.valid_id :: proc(id: string) -> bool¶
-
valid_id tells whether id can name a publisher: 2 to 32 lowercase ASCII letters, digits, and hyphens, starting with a letter.
- plugins.validate_plugins :: proc(r: Plugin_Registry) -> Problem¶
-
validate_plugins checks tables without running code. All failures explain a fix.
- plugins.validate_registry :: proc(r: Registry) -> Problem¶
-
validate_registry checks r: every publisher has a valid, unique ID, a name, a version, an interface version this package supports, and the procedures its capabilities call for. It reads only; no publisher runs. A problem’s text is allocated with context.allocator.
- plugins.verify_entry :: proc(e: Machine_Entry) -> Problem¶
-
verify_entry checks that the program e names is still the one registered: it exists and has the registered SHA-256. A problem’s text is allocated with context.allocator.
- plugins.verify_snapshot :: proc(s: ^Snapshot) -> Problem¶
-
verify_snapshot reads s’s folder again and checks that it holds exactly s’s files with s’s contents: a frozen site that changed is refused before anything is published.
- plugins.write_message :: proc(file: ^os.File, v: any) -> Problem¶
-
write_message writes v as one JSON line, made with context.allocator.
Constants
- plugins.API_VERSION :: Version{1, 1}¶
-
API_VERSION is the version of this package’s publisher interface.
- plugins.BUILD_PROTOCOL_NAME :: "guidedog-build-plugin"¶
- plugins.BUILD_PROTOCOL_VERSION :: Version{1, 0}¶
- plugins.CONFIG_VARIABLE :: "GUIDEDOG_CONFIG_DIR"¶
-
CONFIG_VARIABLE, when set, names the folder that holds Guidedog’s machine state instead of the user’s configuration folder, for tests and portable installations.
- plugins.DEFAULT_REQUEST_TIMEOUT :: 5 * time.Minute¶
-
DEFAULT_REQUEST_TIMEOUT bounds a process request, including its write and response.
- plugins.EXIT_ACCEPTED :: 6¶
-
Exit statuses a publishing command returns beyond 0 (verified), 1 (failed, nothing published), 2 (usage or configuration), 3 (memory), and 4 (files).
the host accepted the publication; the live site is not confirmed yet.
- plugins.EXIT_UNKNOWN :: 7¶
-
what happened is not known; inspect with status or recover.
- plugins.HANDSHAKE_TIMEOUT :: 10 * time.Second¶
-
HANDSHAKE_TIMEOUT bounds inspection of an explicitly chosen publisher program.
- plugins.MACHINE_FILE :: "plugins.toml"¶
-
MACHINE_FILE is the registry’s file name in config_dir.
- plugins.MAX_PLUGIN_ASSETS :: 256¶
- plugins.MAX_PLUGIN_ASSET_BYTES :: 16 * 1024 * 1024¶
- plugins.MAX_PLUGIN_TEXT :: 8 * 1024 * 1024¶
- plugins.MAX_REQUEST :: 1024 * 1024¶
-
MAX_REQUEST bounds a request line; MAX_RESPONSE a response line or handshake.
- plugins.MAX_RESPONSE :: 64 * 1024 * 1024¶
- plugins.PLUGIN_API_VERSION :: Version{1, 0}¶
-
PLUGIN_API_VERSION versions the build-plugin contract independently of publishers.
- plugins.PROTOCOL_FLAG :: "--guidedog-protocol"¶
-
PROTOCOL_FLAG is the argument that starts a publisher program in protocol mode.
- plugins.PROTOCOL_NAME :: "guidedog-publisher"¶
-
PROTOCOL_NAME names the protocol in a handshake.
- plugins.PROTOCOL_VERSION :: Version{1, 0}¶
-
PROTOCOL_VERSION is the version of the process protocol (protocol.odin).
- plugins.SNAPSHOT_SCHEMA :: 1¶
-
SNAPSHOT_SCHEMA is the version of the snapshot manifest and its digest.
Foreign imports
- foreign import plugins.system "system:c"¶
-
Verfügbarkeit: Darwin, Linux.