/** * NAMED FULL-PROXY POSTURES, AND WHY THEY ARE NOT THE COMPRESSION PRESETS. * * `src/compress/options.ts` already has four names -- `balanced`, `aggressive`, * `conservative`, `lossless` -- and every one of them reaches exactly one thing: * the compression dials. Nothing a preset can say turns tool deferral on, nothing * it can say shapes a response, and nothing it can say changes how many tool * definitions stay loaded. An operator who wants the whole proxy leaned on has to * know eight environment variables by name and set them one at a time, which means * the configuration that actually saves the most is the one nobody can ask for. * * A POSTURE IS THAT ASK, AS ONE WORD. It names a compression preset, a set of * registry features, and the value-carrying variables that have no registry entry * because they carry a number rather than a yes. `applyPosture` seeds each of them * into the environment with setdefault semantics, so every reader in the package * keeps working untouched and an operator who set one explicitly still wins. * * THE NAME CARRIES THE CONSENT, WHICH IS THE WHOLE DESIGN. * * The features that are on in `Stable` are on because they were measured and kept, * and they are recoverable: a deferred tool schema is one search away, an elided * body is one `Read` away. The features that are NOT on by default in `Stable` are * a different kind of thing -- they change what the agent is given beyond what * shipping defaults chose, and some of them remove model reasoning that no offline * instrument can price. So: * * A POSTURE MAY NAME A FEATURE THAT STABLE DOES NOT RUN BY DEFAULT ONLY IF THE * POSTURE'S OWN NAME ENDS IN `-lossy`. * * That rule is derived from the registry rather than written down twice -- the * registry already records `defaultEnabledIn` for every feature -- and a test * enforces it, so a later posture cannot quietly acquire a response-side feature * while keeping a reassuring name. `max-lossy`, never `max`. * * AND THE CHANNEL STILL DECIDES. A posture does not set a feature's own variable; * it seeds `TOKEN_OPTIMIZER_FEATURES`, which is the existing "the operator asked * for it" channel, so `resolveRollout` applies exactly the rule it already applies * and reports `blocked_by_channel` for anything this channel does not carry. A * posture can ask. It cannot grant. * * WHAT A POSTURE MAY NEVER TOUCH. The four consent-bearing variables the feature * registry deliberately excludes -- proxy capture, the accounting ledger, and the * two measurement holdouts -- are absent here for the same reason they are absent * there: capture writes conversation content to a directory, a ledger writes a file, * and a holdout spends real money on a control arm. The operator has to say where * and how much, and a one-word posture cannot say it for them. A test pins this. */ import type { PresetName } from '../compress/options.js'; import { FeatureName } from '../rollout/features.js'; /** The environment variable that names a posture. */ export declare const POSTURE_ENV = "TOKEN_OPTIMIZER_POSTURE"; /** * The suffix a posture's name must carry to be allowed a non-default feature. * * NOT DECORATION. It is the only thing between an operator typing one word and a * proxy that drops thinking blocks out of the conversation, so it is checked by * `POSTURES`' own test rather than by whoever adds the next posture remembering. */ export declare const LOSSY_SUFFIX = "-lossy"; export declare const PostureName: { /** What the package ships. Named so an operator can say it back deliberately. */ readonly Default: "default"; /** Every lossless lever pulled: nothing here is unrecoverable. */ readonly Lean: "lean"; /** Deferral kept, elision held back. For a workload that re-reads. */ readonly Careful: "careful"; /** Nothing lossy at all, for comparing a transcript against an unmodified one. */ readonly Audit: "audit"; /** Lean, plus every response-side feature the channel will carry. */ readonly MaxLossy: "max-lossy"; }; export type PostureName = (typeof PostureName)[keyof typeof PostureName]; export interface Posture { readonly name: PostureName; /** One line, printed in the disclosure. */ readonly summary: string; /** The compression preset this posture implies. */ readonly compression: PresetName; /** * Registry features the posture ASKS for, seeded through `TOKEN_OPTIMIZER_FEATURES`. * The channel decides whether the ask is granted. */ readonly features: readonly FeatureName[]; /** * Value-carrying variables the posture pins. * * These have no registry entry because a registry entry is a yes-or-no and these * are numbers; every one of them must still be read by a shipped reader, which is * what `posture-readers.test.ts` proves by calling the reader rather than by * grepping for the name. */ readonly values: Readonly>; } export declare const POSTURES: Readonly>; /** The variable a posture seeds to choose the compression dials. */ export declare const COMPRESSION_ENV = "TOKEN_OPTIMIZER_COMPRESSION"; /** * Does a posture's name permit it the features it names? * * Exported because the test that enforces the rule has to ask the same question * the table was built to answer, and a rule checked by a copy of itself is not * checked at all. */ export declare function postureIsHonestlyNamed(posture: Posture): boolean; /** Every variable any posture can write. Nothing outside this set is seeded. */ export declare function postureVariables(): readonly string[]; export interface AppliedPosture { /** What the operator typed, verbatim. */ readonly requested: string; /** Null when the name matched no posture. */ readonly posture: Posture | null; /** Variables this call wrote, because nothing had set them. */ readonly seeded: readonly string[]; /** Variables left exactly as the operator had them. */ readonly respected: readonly string[]; } /** * Every variable a posture sets, and the value it sets, for a name it knows. * * ONE PLACE THAT DECIDES WHAT A POSTURE IS. `applyPosture` seeds these into a * live environment and `--print-env` prints them for an operator to export * themselves; a second construction of the same set would eventually differ * from the one the proxy actually runs, and the printed exports would then * describe a configuration nobody runs. * * INDEPENDENT OF THE CURRENT ENVIRONMENT, deliberately: this is what the * posture means, not what it would change here. `applyPosture` is the function * that respects what the operator has already set. */ export declare function postureEnv(name: string): Readonly> | null; /** The posture the environment names, or undefined when it names none. */ export declare function postureFromEnv(env?: NodeJS.ProcessEnv): string | undefined; /** * Seed a posture's variables into the environment, without overriding any. * * SETDEFAULT, NOT ASSIGNMENT, and the distinction is the whole reason this is * safe to call at start-up. An operator who set `TOKEN_OPTIMIZER_PROXY_KEEP_TOOLS` * meant it; a posture that overwrote it would make the inspector, the doctor and * every reader in the package agree on a value the operator never chose. So an * already-set variable is reported as respected and left alone. * * A BLANK VARIABLE COUNTS AS UNSET, because every reader in this package already * treats it that way -- `keepToolsFromEnv`, `smallToolCharsFromEnv` and * `presetFromEnv` all fall through on an empty string. Treating it as set here * would mean `VAR= token-optimizer-proxy` quietly defeated the posture while * nothing else in the process could tell the difference. * * AN UNKNOWN NAME IS NOT FATAL AND NOT SILENT. The proxy fails open everywhere but * the cleartext-upstream check, so a typo must not take a session down -- but it * must not be swallowed either, which is why the name travels back on the result * for `postureNotice` to print. * * Returns null when no posture was asked for, which is the normal case. */ export declare function applyPosture(requested?: string | undefined, env?: NodeJS.ProcessEnv): AppliedPosture | null; /** * The start-up disclosure. One block, printed every time, never once. * * MODELLED ON `captureNotice` DELIBERATELY, for the reason that notice gives: an * operator must not be able to leave something on by accident and not notice. A * posture is one word that can turn on five features, so the word is not evidence * that anyone understood what it did -- the block is. It names what is on, what the * channel refused, what of the operator's own settings it left alone, and the exact * variable that turns each thing off. * * IT REPORTS THE RESOLVER'S ANSWER, NOT THE POSTURE'S REQUEST. The posture asks; * `resolveRollout` decides. Printing the ask would claim features this channel * never carried, which is the failure this package keeps finding in its own code: * a capability that is named everywhere and reached nowhere. */ export declare function postureNotice(applied: AppliedPosture, env?: NodeJS.ProcessEnv): string; //# sourceMappingURL=posture.d.ts.map