filament_id v4.2a: dissolve the QD_* island in the tooling (plan v4 SS3)

- is_island_declaration: only BBL remains an island; Qidi QD_* declarations
  now enter the triple bookkeeping (checks 3 and 8, --remint's domain).
- reserved_space_owner: QD_* stays reserved but ownerless -- no vendor may
  declare it, --update-snapshot refuses new QD_* ids outright, and vanished
  QD_* ids take the retired-with-successor path instead of the island
  release-with-hint path. New reserved_space_desc() names the space in
  check 6 / sanction-gate messages.
- Check 1 drops the vendor-Qidi QD_* format exemption; --add-hint now
  refuses QD_* keys (island space is GF* only); docstrings updated.
- Snapshot regenerated: the 204 QD_* declarer triples are now recorded
  (declared triples 1113 -> 1317); ids/claims unchanged.
- Tests updated for the flip; new (skipped until v4.2b) lockstep test
  asserting the QidiPrinterAgent fallback QD_* literals stay retired
  ledger keys chaining to live ids.

Tree state is untouched: presets still declare their QD_* ids, all
grandfathered by the snapshot. --check exit 0; 117 script tests OK.
This commit is contained in:
SoftFever
2026-08-21 18:34:20 +08:00
parent 1c405f8a2c
commit 8d83414d09
3 changed files with 1488 additions and 21 deletions

View File

@@ -8,6 +8,7 @@ import contextlib
import io
import json
import os
import re
import shutil
import sys
import tempfile
@@ -400,7 +401,8 @@ class TestTripleResolution(unittest.TestCase):
class TestReservedSpaces(unittest.TestCase):
def test_owners(self):
self.assertEqual(afi.reserved_space_owner("GFL99"), (True, "BBL"))
self.assertEqual(afi.reserved_space_owner("QD_X4_PLA"), (True, "Qidi"))
# dissolved island (plan v4): reserved, but no vendor may declare it
self.assertEqual(afi.reserved_space_owner("QD_X4_PLA"), (True, None))
self.assertEqual(afi.reserved_space_owner("P1234abc"), (True, None))
self.assertEqual(afi.reserved_space_owner("pAbCdEf1"), (True, None)) # case-insensitive
self.assertEqual(afi.reserved_space_owner("null"), (True, None))
@@ -410,7 +412,8 @@ class TestReservedSpaces(unittest.TestCase):
def test_island_declarations(self):
self.assertTrue(afi.is_island_declaration("BBL", "GFL99"))
self.assertTrue(afi.is_island_declaration("BBL", "OF5CgdDq"))
self.assertTrue(afi.is_island_declaration("Qidi", "QD_X4_PLA"))
# dissolved island (plan v4): Qidi declarations mint like any other
self.assertFalse(afi.is_island_declaration("Qidi", "QD_X4_PLA"))
self.assertFalse(afi.is_island_declaration("Qidi", "OF5CgdDq"))
self.assertFalse(afi.is_island_declaration("VendorA", "GFL99"))
@@ -567,7 +570,7 @@ class TestChecks(SyntheticTreeCase):
def test_check6_reserved_namespace_claims(self):
for fid, marker in [("GFX99", "owned by BBL"),
("QD_X_PLA", "owned by Qidi"),
("QD_X_PLA", "dissolved island"),
("P1a2b3c4", "user-custom"),
("null", "user-custom")]:
with self.subTest(fid=fid):
@@ -1478,6 +1481,31 @@ class TestRealTree(unittest.TestCase):
self.assertEqual(analysis["missing_effective"], [])
self.assertEqual(analysis["read_errors"], [])
# Code<->ledger lockstep for the Qidi box (plan v4 SS2): the QD_* literals
# QidiPrinterAgent::map_filament_type_to_setting_id returns must stay
# retired ledger keys whose chains end at a live preset id, because the
# agent resolves them through resolve_filament_id_succession() at runtime.
@unittest.skip("enable with plan v4.2: QD_* ids are not retired yet")
def test_qidi_agent_fallback_ids_resolve_through_ledger(self):
cpp = os.path.join(REPO_ROOT, "src", "slic3r", "Utils", "QidiPrinterAgent.cpp")
with open(cpp, encoding="utf-8") as f:
src = f.read()
m = re.search(
r"map_filament_type_to_setting_id\(const std::string& filament_type\)"
r"\s*\{(.*?)\n\}", src, re.DOTALL)
self.assertIsNotNone(m, "map_filament_type_to_setting_id not found in QidiPrinterAgent.cpp")
qd_ids = re.findall(r'return "(QD_[0-9_]+)";', m.group(1))
self.assertTrue(qd_ids, "no QD_* literals parsed from map_filament_type_to_setting_id")
ledger = afi.load_ledger(afi.RETIRED_PATH)
live = set(afi.analyze_tree(REAL_PROFILES)["ids"])
for fid in qd_ids:
self.assertIn(fid, ledger["retired"], f'"{fid}" must be a retired ledger key')
status, node = afi.follow_succession(
fid, set(), ledger["retired"], ledger["hints"], live)
self.assertEqual(
status, "live",
f'"{fid}" succession must end at a live id (got {status} at "{node}")')
# ---------------------------------------------------------------------------
# review-fix regressions