NAME

Langertha::Skeid::NodeFiles - Nodes from a second, less trusted file, under the constraints the main config sets

VERSION

version 0.005

SYNOPSIS

node_files:
  - path: /etc/skeid/gpm/nodes.yaml
    allow_api_key_env: '^SKEID_NODE_GPM_[A-Z0-9_]+_API_KEY$'
    allow_api_key_ref: false
    allow_url_hosts: [ '*.cai-gpm.svc' ]
    allow_kinds: [ documents, chat ]
    trust: internal                    # default external (ADR 0032)

DESCRIPTION

A node file is a list of nodes that someone other than the author of the main config writes -- a GPU manager publishing where its models run. Whoever can write that file must not be able to make Skeid send an environment variable or a broker secret of its choosing, as a node key, to a URL of its choosing (ADR 0031). So the main config names each such file together with what a node from it may say, and this module holds the checks; Langertha::Skeid reads the files and merges what passes into the nodes section.

A node from a node file is checked field by field. Any failing check rejects that node, and only that node: the rest of the file still loads. The rule that failed is reported by name with the node's position in the file, never with the value that broke it.

normalize_config

my $entries = Langertha::Skeid::NodeFiles->normalize_config($cfg->{node_files});

The node_files section, checked and filled with its defaults. It belongs to the main config, so a malformed section fails the load like any other:

  • path -- required, a file path; each path once.

  • allow_api_key_env -- a regular expression an api_key_env must match whole. Absent: no node of this file may name a variable.

  • allow_api_key_ref -- default false: no node of this file may name a broker reference.

  • allow_url_hosts -- required, at least one host pattern. A node's url must be http or https to a host one of them matches, case-insensitively. * stands for exactly one DNS label: *.cai-gpm.svc matches gpu-1.cai-gpm.svc, not cai-gpm.svc and not a.b.cai-gpm.svc.

  • allow_kinds -- default [chat]: the node kinds this file may add (chat, documents).

  • trust -- default external: the trust zone of every node of this file, internal or external (ADR 0032). The file's writer cannot change it; see "check".

read_file

my $nodes = Langertha::Skeid::NodeFiles->read_file($path);   # dies when it cannot

The node list of one node file: a YAML list of nodes, or a mapping whose only key is nodes. A file that does not parse, says anything but nodes, is larger than 1 MiB, nests deeper than 16 levels or uses a YAML alias dies -- the caller keeps that file's last good list. The message names the file and the line, never its content.

check

my $rule = Langertha::Skeid::NodeFiles->check($skeid, $entry, $node);
# undef: the node may load; else the name of the rule it broke

Checks one node of a node file against its entry from "normalize_config". The rules, in the order they are checked: entry (not a mapping), field (a field a node file may not set: capacity or an unknown one), id, url (missing), url_host (not http(s) to an allowed host, or credentials in the URL), api_key_env, api_key_ref, trust (the node names a trust other than its entry's), key_required (the entry is external and the node names no api_key_env or api_key_ref), kind, invalid (a value the main config would refuse too -- an unknown engine or rerank format, a header that is no token), so that a broken node of a less trusted file cannot fail the load of the main config.

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-skeid/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.