[EPIC] Add declarative always-visible activation to prompt_unit tools #174
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/prolog-rlm#174
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Extend the existing
prompt_unitinterface so any tool/unit may declaratively opt into always-visible model context without introducing a separate core-tool registry or parallel interface.This is an implementation epic only. The design deliberately reuses the current prompt compiler/catalog/unit machinery.
Research / current behavior
Current prompt compiler behavior is evidence-driven:
prompt_unit{...}values;mandatory_context:truecurrently means only that once selected, context packing may not choose an omitted representation;compiledmode still requires positive activation evidence before a unit becomes a candidate;selected_tool_schemas/2emits schemas only from surviving selected entries, so a non-selected tool is absent from the provider-visible tool list;context_deactivation_does_not_unregister_runtime_toolexplicitly proves this behavior;Relevant existing research:
research/RLM-RESEARCH-011-managed-context-tool-discovery.orgestablishes that contextual activation/deactivation is correct for ordinary tools, but also states that mandatory host units and dependencies must not compete with untrusted metadata ranking.Design decision
Use the same
prompt_unitinterface. Add one normalized field:with supported values:
Default remains
relevantso existing behavior is unchanged.Example:
No
core_tool/1registry. No second catalog. No privileged side channel. Any ordinary tool/unit may opt in declaratively.Exact semantics
activation:relevantCurrent behavior:
needs(...), dependency closure, or compatibility mode;mandatory_context:true, token packing cannot omit it.activation:alwaysWhen a unit is registered and otherwise eligible, the compiler must seed it into the candidate set without requiring prompt evidence.
An always-active unit MUST NOT disappear merely because:
candidate_limitis exhausted by ordinary relevant candidates.It must still obey trusted eligibility boundaries:
available:true;activation:alwaysis visibility policy, not authorization. Invocation still rechecks the normal runtime capability/authority/tool execution path.Negative user text
Do not allow ordinary natural-language negation such as
"without foo"to remove anactivation:alwaysunit. The host explicitly declared the model-visible interface persistent.Host-controlled
denied:[Unit]/ explicit policy narrowing may still reject it when that denial represents trusted compile input. Keep this distinction explicit in implementation and tests; do not let untrusted prose rewrite host activation policy.Conflict / supersession
Always-active units should not be silently removed by ordinary relevance-ranked conflict or supersession logic.
Preferred rule for this slice:
This avoids a host-declared permanent interface being silently mutated by prompt ranking.
Token packing
No new packer behavior is required.
Existing
mandatory_context:truesemantics remain canonical:rlm_context_budgetreturns a structural failure.For a tool intended to be permanently callable by the model, recommended declaration is:
activationcontrols selection;mandatory_contextcontrols packing after selection.Exact implementation files
1.
prolog/rlm_prompt_compiler.plA. Normalize the new field
In
normalize_unit_spec/2, after availability/visibility-style policy fields are normalized, add:Add
activation:Activationto the normalizedprompt_unit{...}dict.Add a normalizer with exactly two accepted values:
If string compatibility is desired, normalize through the same name normalization convention used by other enum-like fields, but the canonical stored values must remain atoms
relevant/always.B. Tool-registry import defaults
In
tool_schema_unit_spec/3, imported runtime tools should remain:by default.
Add an import option that can declaratively mark chosen tools always-active without creating another interface. Preferred shape:
or a generic unit activation map if one already fits existing option conventions:
Choose one approach and document it. Do not hard-code tool names in
rlm_prompt_compiler.pl.C. Candidate generation
Refactor
initial_candidates/.../root_candidate_status/...so always-active eligible units enter the candidate frontier independently of relevance evidence.The implementation should make the ordering explicit:
activation:alwaysunits;candidate_limitonly to the ordinary relevant frontier, not to the always-active set;Do not fake always-visible behavior by assigning an arbitrarily huge lexical score and leaving it subject to
candidate_limit.D. Negative evidence
Split trusted compile denial from natural-language negative evidence.
For
activation:always:Input.denied/ host denial may reject;text_negation(...)must not remove it;Preserve existing behavior for
activation:relevant.E. Conflict / supersession handling
Update
apply_supersession/...andapply_conflicts/...(or introduce a pre-resolution policy helper) so host-declared always-active units cannot be silently displaced by relevance scoring.Required observable results:
F. Explainability
prompt_explain/3andCompiled.reasonsmust expose why an always-active unit is present. Expected reason term:If rejected by trusted policy, explanation must say the actual reason (
unavailable, capability denied, discovery scope denied, explicit host denial, dependency failure, etc.), notno_matching_evidence.G. Fingerprint
Ensure
activationis material to catalog/spec fingerprinting. A unit changing fromrelevanttoalwaysmust change compiled/catalog fingerprints even if every other field is identical.2.
test/rlm_prompt_compiler_test.plAdd focused regression coverage.
Required tests:
always_activation_without_lexical_match_is_selectedactivation:always;Compiled.tool_schemas.relevant_activation_without_evidence_remains_hiddenalways_tool_survives_unrelated_turn_without_reregistrationcandidate_limit_does_not_evict_always_toolcandidate_limit;natural_language_negation_does_not_hide_always_toolwithout <alias>/do not use <alias>;trusted_explicit_denial_can_reject_always_tooldenied:[tool(...)];capability_denied_always_tool_is_not_exposeddiscovery_scope_denied_always_tool_is_not_exposedunavailable_always_tool_is_not_exposedavailable:false;always_tool_over_budget_fails_structurally_when_mandatoryactivation:always,mandatory_context:true;always_tool_schema_is_rendered_and_callable_surface_presentprompt_render(...).tool_schemascontains exact schema even on unrelated prompt.relevant_conflict_cannot_evict_always_toolconflicting_always_units_fail_structurallyrelevant_superseder_cannot_remove_always_toolactivation_changes_fingerprinttool_registry_import_can_mark_selected_tool_always_visible3. Documentation target
There is currently substantial prompt-compiler design in
research/RLM-RESEARCH-010-symbolic-prompt-compiler.organdresearch/RLM-RESEARCH-011-managed-context-tool-discovery.org, but no obvious dedicateddocs/prompt-compiler.mdruntime contract surfaced by the current audit.Implementation should either:
docs/prompt-compiler.md, preferred if the runtime now needs a stable user/operator contract; orThe documentation must define:
and additionally distinguish:
Document that
activation:alwaysnever grants authority and remains constrained by availability, discovery scope, capabilities, dependencies, and final runtime authorization.4. Research design note
Before implementation, update the canonical research/design record rather than creating a competing architecture.
Preferred target:
research/RLM-RESEARCH-011-managed-context-tool-discovery.orgAdd a short follow-up section recording that the original contextual-deactivation rule remains correct for
activation:relevant, while host-declared always-visible tools are represented through the same unit algebra using explicit activation policy.Do not rewrite the original research conclusion into “all tools visible by default.” Default remains contextual narrowing.
Public contract
Normalized unit shape after this epic should be conceptually:
Non-goals
core_toolsubsystem;rlm_context_budgetunless a failing regression proves current mandatory-unit behavior insufficient;Acceptance gate
Implementation is complete only when all of the following hold:
prompt_unitcan declareactivation:always;activation:relevant;tool_schemaswithout prompt evidence;Implementation sequence
activationinprompt_unit.Do not broaden this epic into a separate tool architecture. The point is to make the existing interface expressive enough to represent both contextual and persistent model-visible tools.
ADARD dependency update: #183 clarifies that
activation:alwaysis a generic host-ownedprompt_unitpolicy, not tool-specific. It must apply equally toskill(...)andinstruction(...). The default RLM operating skill bundle depends on this invariant: unrelated input/candidate limits/user prose cannot evict it;mandatory_context:trueprevents silent packing omission; trusted host configuration may disable it. Permanence never grants authority.