CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 56s
CI & Build / integration (push) Successful in 1m4s
CI & Build / Python tests (push) Successful in 1m55s
CI & Build / Build & push image (push) Successful in 44s
Step 2 of the Scribe -> Grimoire rename. - src/scribe -> src/grimoire, and every import, patch target, module path, hypercorn entry point and `python -m grimoire.restore` with it; pyproject, uv.lock and the frontend package are named grimoire. - Image git.fabledsword.com/bvandeusen/fabledgrimoire; CI's Postgres service runs as grimoire / grimoire_test. - Compose files default the DB user, database and (prod) volume to grimoire, each overridable from .env, so an install created as Scribe keeps its data by setting POSTGRES_USER, POSTGRES_DB and PGDATA_VOLUME. - Backups are written as grimoire-<ts>.tar with format grimoire-backup-tar. Archives named scribe-* with the scribe-backup-tar manifest still restore and are still counted at the destination (folder and S3), with tests. - Exports, the MCP auth realm, the ASGI scope key and the persistent logger carry the new name. Kept on purpose: the secret-sealing key label stays "scribe.secrets.v1", because every stored secret was derived under it. Plugin identity (plugin name, hooks, env vars, .scribe marker, skills) is step 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
3.1 KiB
Python
71 lines
3.1 KiB
Python
"""The specs are the registry.
|
|
|
|
Three lists sit beside the arms — the tuning table, the ranked rows of the
|
|
telemetry registry, and the rule-usage denominator — and all three are read
|
|
off the pipeline's specs rather than kept by hand. These
|
|
pin the derivation itself: every arm is tunable, every ranked source is
|
|
measured with the declaration its spec carries, and the rule-usage
|
|
denominator counts exactly the rule surfaces a ranker chose.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from grimoire.services import retrieval_pipeline as rp
|
|
from grimoire.services.retrieval_registry import POINTS, UNBIDDEN
|
|
from grimoire.services.retrieval_surfaces import SURFACES
|
|
from grimoire.services.rule_usage import RANKED_SOURCES, is_ambient
|
|
|
|
|
|
def test_every_arm_is_one_tunable_surface_in_the_order_settings_lists_them():
|
|
assert [arm.source for arm in rp.TUNED_ARMS] == list(SURFACES)
|
|
for arm in rp.TUNED_ARMS:
|
|
assert arm.tuning is not None, f"{arm.source} has no floor or budget"
|
|
# The join key: the surface a tuner moves and the rows it is judged by
|
|
# must name the same arm.
|
|
assert arm.tuning.name == arm.source
|
|
assert SURFACES[arm.source] is arm.tuning
|
|
|
|
|
|
def test_every_ranked_source_is_measured_as_its_spec_declares():
|
|
sources = [spec.source for spec in rp.RANKED]
|
|
assert len(sources) == len(set(sources)), f"a source is declared twice: {sources}"
|
|
for spec in rp.RANKED:
|
|
d = spec.declared
|
|
assert d is not None and d.what.strip(), f"{spec.source} declares nothing"
|
|
point = POINTS[spec.source]
|
|
assert point.kind == UNBIDDEN
|
|
assert point.what == d.what
|
|
# A quiet source must say why, and only a quiet source may.
|
|
assert point.expects_traffic == (not d.quiet_because)
|
|
assert point.quiet_because == d.quiet_because
|
|
|
|
|
|
def test_the_slots_are_measured_but_never_tuned():
|
|
for slot in (rp.PREFERENCE_SLOT, *rp.NOTE_SLOTS):
|
|
assert slot.source in POINTS
|
|
assert slot.source not in SURFACES
|
|
|
|
|
|
def test_the_rule_denominator_is_every_rule_surface_a_ranker_chose():
|
|
rule_arms = {arm.source for arm in rp.RULE_ARMS}
|
|
assert rule_arms <= set(RANKED_SOURCES)
|
|
assert set(RANKED_SOURCES) == (
|
|
rule_arms | {rp.PREFERENCE_SLOT_SOURCE, rp.VIA_LESSON_SOURCE,
|
|
rp.MOMENT_RULE_SOURCE}
|
|
)
|
|
# And a notes arm is not a RULE surface: its lines are not rules, so a
|
|
# rule pull cannot confirm them.
|
|
for arm in rp.NOTE_ARMS:
|
|
assert is_ambient(arm.source)
|
|
|
|
|
|
def test_an_arm_added_without_tuning_would_be_caught():
|
|
"""The first test has to be able to bite. SURFACES skips an arm
|
|
with no tuning rather than raising, so an arm added without one would
|
|
silently be untunable — and the order-equality assertion is what notices,
|
|
as this replays with one such arm appended."""
|
|
bare = rp.RuleArm("x_rule", band=False, compact_tail=False,
|
|
checkpoint=False, preference_slot=False)
|
|
arms = (*rp.TUNED_ARMS, bare)
|
|
derived = {a.tuning.name: a.tuning for a in arms if a.tuning is not None}
|
|
assert [a.source for a in arms] != list(derived)
|