docs(agents): tooling-improvement and architecture-upkeep rules; add tool tests

Researched the sibling project's tooling discipline (tools/README inventory,
tools/tests with stdlib unittest, check_docs gate, clean-worktree rule, paid-API
tools human-triggered) and encoded it for this repository:

AGENTS.md gains two sections.
- 'Python and shell tooling': fix the tool not the artefact; improve over fork;
  one script one job; fail loudly; result files for Unreal commandlets; absolute
  paths into sandboxes; clean worktree for generators (.blend/.umap are
  read-only on checkout); network/paid tools human-triggered with 429 back-off;
  measure don't assert; document every tool in the README inventory; test the
  pure parts.
- 'Architecture documentation': Docs/Architecture is arc42 in Markdown; a table
  mapping each kind of change to the section that must be updated; describe what
  exists, ADRs append-only, keep architecture.md in sync, prettier --check.

Made the referenced scaffolding real rather than aspirational:
- Tools/tests/ (README + __init__) with 12 passing unittest tests covering
  input_emulation's ioctl/key-code encoding and block_height_report's height
  classification.
- requirements-tools.txt (requests).
- Extracted classify_height() out of block_height_report.main() so the roof/
  shelter rule is testable — the rule itself came from the v0.1.2 finding.
- Tools/README: tests section, input-injection rows, and the removed TEMP-QA row
  replaced by the real cvar/self-test description.
- Docs/Architecture 05 + architecture.md: tools table extended (input injection,
  tests) and a link to the tool rules; kept in sync per the new rule.
This commit is contained in:
zwitschi committed 2026-11-08 16:25:26 +01:00
1 parent 420f863999
commit 5be6c84b37
10 files changed
+233 -17

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
"""Tests for Geo/tools/block_height_report.py::classify_height.
The Geo tools live outside `Tools/`, so the test adds `Geo/tools` to `sys.path`
before importing the module by name.
"""
import os
import sys
import unittest
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.insert(0, os.path.join(ROOT, "Geo", "tools"))
import block_height_report as bhr # noqa: E402
class ClassifyHeightTest(unittest.TestCase):
def test_height_tag_wins(self):
height, source = bhr.classify_height({"building": "yes", "height": "18.1"})
self.assertEqual(height, 18.1)
self.assertEqual(source, "height tag")
def test_height_tag_beats_levels(self):
height, _ = bhr.classify_height(
{"building": "yes", "height": "12.5", "building:levels": "4"})
self.assertEqual(height, 12.5)
def test_levels_derive_height(self):
height, source = bhr.classify_height(
{"building": "yes", "building:levels": "4"}, level_height=3.2)
self.assertEqual(height, 12.8)
self.assertIn("levels x", source)
def test_roof_is_not_a_building_volume(self):
# building=roof at layer=1 is an elevated canopy, not a two-storey block.
height, source = bhr.classify_height({"building": "roof", "layer": "1"})
self.assertEqual(height, 0.0)
self.assertIn("not a building volume (roof)", source)
def test_transit_shelter_is_not_a_building_volume(self):
height, source = bhr.classify_height(
{"building": "yes", "amenity": "shelter", "shelter_type": "public_transport"})
self.assertEqual(height, 0.0)
self.assertIn("not a building volume (shelter)", source)
def test_missing_data_falls_back_to_a_flagged_guess(self):
height, source = bhr.classify_height({"building": "yes"})
self.assertEqual(height, 2 * bhr.LEVEL_HEIGHT)
self.assertTrue(source.startswith("GUESS"))
if __name__ == "__main__":
unittest.main()