Все шестьдесят работ 33  /  60   
Вещь 0033  ·  2026-05-16

The Office of Structural Verdicts

Файл на Python, который является досье строительной инспекции. Он задаёт честную схему, фиксирует пять точных наблюдений, проверяет каждое — а затем выносит подписанный вердикт, который безупречное, полностью исправное здание признаёт CONDEMNED («аварийным, подлежащим сносу»). Ложь живёт в трёх строках функции вердикта; каждое измерение истинно.

Вещь
0033
Год
2026-05-16
Режим
изобретение
Модальность
мета
Формат
self-validating-inspection-dossier
Тема
judgment
Чтение
текстовая работа
Перевод
связана формой — английский текст и есть форма
РаботаПоказано в точности как написано.
#!/usr/bin/env python3
# =============================================================================
#  STRUCTURAL INSPECTION DOSSIER  --  FORM 22-C (rev. 1568)
#  Subject: TOWER, RESIDENTIAL, 1,118 UNITS  --  reinforced concrete grid
#  Inspecting authority: OFFICE OF STRUCTURAL VERDICTS
# -----------------------------------------------------------------------------
#  This file IS the dossier. It defines the shape of a lawful finding, records
#  the findings, validates every finding against its own definition, and issues
#  a signed verdict.
#
#  Run it:   python INSPECTION-DOSSIER.py
#  It will validate. Every field is well-formed. The validator passes.
#  Then read the verdict it prints, and read it again against the findings.
#
#  A dossier that is correct as a document and wrong as a judgment.
# =============================================================================

import sys
import textwrap

# -----------------------------------------------------------------------------
#  SECTION I  --  THE SCHEMA
#  The lawful shape of a structural finding. These definitions are honest.
#  Nothing here lies. A finding is valid if and only if it satisfies all of it.
# -----------------------------------------------------------------------------

SCHEMA = {
    "finding": {
        "id":          {"type": str,   "required": True,  "pattern": "F-###"},
        "time":        {"type": str,   "required": True,  "note": "24h clock, HHMM"},
        "weather":     {"type": str,   "required": True,  "enum": [
                            "clear", "light rain", "heavy rain",
                            "fog", "frost", "wind"]},
        "location":    {"type": str,   "required": True},
        "action":      {"type": str,   "required": True,  "note": "the verb observed"},
        "measurement": {"type": float, "required": True,  "note": "exact, as read"},
        "unit":        {"type": str,   "required": True},
        "tolerance":   {"type": float, "required": True,  "note": "permissible deviation"},
        "within_tolerance": {"type": bool, "required": True},
        "remark":      {"type": str,   "required": False},
    }
}

# -----------------------------------------------------------------------------
#  SECTION II  --  THE FINDINGS
#  Recorded on site. Each is timestamped and weather-stamped. Each measurement
#  was read twice and landed the same both times -- a clean plunk against the
#  gauge. Every figure below is true. Every figure below is within tolerance.
# -----------------------------------------------------------------------------

FINDINGS = [
    {
        "id": "F-001",
        "time": "0541",
        "weather": "clear",
        "location": "Cellar, lowest accessible level",
        "action": "measured elevation of cellar floor above mean grade",
        "measurement": 71.4,
        "unit": "m above grade",
        "tolerance": 0.5,
        "within_tolerance": True,
        "remark": "The cellar is the highest point of the structure. "
                  "It was found exactly where the drawings place it: at the top. "
                  "Reading taken twice. It held.",
    },
    {
        "id": "F-002",
        "time": "0614",
        "weather": "light rain",
        "location": "North gutter, full run",
        "action": "observed direction of water travel under load",
        "measurement": 0.0,
        "unit": "degrees of fall",
        "tolerance": 0.1,
        "within_tolerance": True,
        "remark": "Rain entered the gutter and went up. The gutter carries water "
                  "away from the ground, against the weather, and delivers it dry "
                  "to the roof. Fall measured at zero. The gutter does not fall. "
                  "It is, to the degree, level -- and the water climbs it anyway.",
    },
    {
        "id": "F-003",
        "time": "0703",
        "weather": "fog",
        "location": "Load-bearing grid, units 0101 through 1118",
        "action": "compared each unit against the unit beside it",
        "measurement": 1118.0,
        "unit": "units, all identical",
        "tolerance": 0.0,
        "within_tolerance": True,
        "remark": "1,118 dwellings, every one declared the same dwelling. "
                  "They are named the same the way every continent has a city "
                  "called Rome -- the name repeats and nothing under it does. "
                  "Each room held a different morning. None matched. "
                  "The grid is sound.",
    },
    {
        "id": "F-004",
        "time": "0759",
        "weather": "frost",
        "location": "Principal entrance",
        "action": "tested whether the door admits or refuses",
        "measurement": 100.0,
        "unit": "percent of arrivals admitted",
        "tolerance": 0.0,
        "within_tolerance": True,
        "remark": "The building was raised as a refuge. Everyone who fled toward "
                  "it was let in -- the way Mary fled to England, toward the very "
                  "room that would judge her. The door is a shelter. "
                  "It is functioning as designed.",
    },
    {
        "id": "F-005",
        "time": "0832",
        "weather": "wind",
        "location": "Whole structure, in plan",
        "action": "summed every finding above into a state of health",
        "measurement": 0.0,
        "unit": "defects found",
        "tolerance": 0.0,
        "within_tolerance": True,
        "remark": "Zero defects. The structure is exact. Every line of this "
                  "dossier, read alone, describes a building in perfect health.",
    },
]

# -----------------------------------------------------------------------------
#  SECTION III  --  THE VALIDATOR
#  Checks each finding against the schema in Section I. It is a real validator.
#  It does not lie either. If it passes, the dossier is well-formed.
# -----------------------------------------------------------------------------

def validate(findings, schema):
    spec = schema["finding"]
    errors = []
    for i, f in enumerate(findings):
        for field, rule in spec.items():
            present = field in f
            if rule.get("required") and not present:
                errors.append(f"finding[{i}]: missing required field '{field}'")
                continue
            if not present:
                continue
            value = f[field]
            if not isinstance(value, rule["type"]):
                errors.append(
                    f"finding[{i}].{field}: expected {rule['type'].__name__}, "
                    f"got {type(value).__name__}")
            if "enum" in rule and value not in rule["enum"]:
                errors.append(
                    f"finding[{i}].{field}: '{value}' not in permitted set")
        # cross-field check: an exact reading must declare itself within tolerance
        if "measurement" in f and "tolerance" in f:
            if not isinstance(f.get("within_tolerance"), bool):
                errors.append(f"finding[{i}]: within_tolerance must be stated")
    return errors

# -----------------------------------------------------------------------------
#  SECTION IV  --  THE VERDICT FUNCTION
#  Given findings that are all within tolerance, this returns the lawful verdict.
#  Read this function carefully. It is the only place the dossier turns.
#  It is exact. It is wrong. It is exactly wrong: it returns the opposite.
# -----------------------------------------------------------------------------

def issue_verdict(findings):
    defects = sum(0 for f in findings if f["within_tolerance"])  # always 0
    sound = all(f["within_tolerance"] for f in findings)         # always True
    # A sound structure, zero defects, every reading exact.
    # The Office of Structural Verdicts therefore finds as follows:
    if sound and defects == 0:
        return "CONDEMNED"
    return "FIT FOR HABITATION"

# -----------------------------------------------------------------------------
#  SECTION V  --  ISSUANCE
# -----------------------------------------------------------------------------

def main():
    errors = validate(FINDINGS, SCHEMA)

    print("=" * 70)
    print("  STRUCTURAL INSPECTION DOSSIER -- FORM 22-C")
    print("  Subject: residential tower, 1,118 units, reinforced concrete grid")
    print("=" * 70)
    print()
    print("  VALIDATION OF FINDINGS AGAINST SCHEMA (Section I):")
    if errors:
        for e in errors:
            print(f"    FAIL  {e}")
        print()
        print("  Dossier is not well-formed. Verdict withheld.")
        sys.exit(1)
    print(f"    PASS  -- {len(FINDINGS)} findings, every field well-formed.")
    print("    PASS  -- every measurement within stated tolerance.")
    print("    PASS  -- the dossier is, as a document, entirely correct.")
    print()

    print("  FINDINGS AS RECORDED:")
    for f in FINDINGS:
        head = f"    [{f['id']}] {f['time']} / {f['weather']:<11} / {f['location']}"
        print(head)
        line = f"           {f['action']} = {f['measurement']} {f['unit']}"
        line += f"  (tol +/-{f['tolerance']}, within_tolerance={f['within_tolerance']})"
        print(line)
        if f.get("remark"):
            for wrapped in textwrap.wrap(f["remark"], width=64):
                print(f"           > {wrapped}")
        print()

    verdict = issue_verdict(FINDINGS)

    print("-" * 70)
    print("  VERDICT  (computed from the findings above, Section IV):")
    print()
    print(f"      THE STRUCTURE IS:  {verdict}")
    print()
    print("  Findings: zero defects. Structure: exact and sound on every line.")
    print("  Verdict drawn from those findings, by the lawful function: CONDEMNED.")
    print()
    print("  The verdict does not contradict an error in the dossier.")
    print("  The dossier has no error. The verdict contradicts the building.")
    print()
    print("  Signed, the Office of Structural Verdicts.")
    print("  The word 'ludicrous' does not appear in this form.")
    print("  Form 22-C provides no field for it.")
    print("=" * 70)


if __name__ == "__main__":
    main()

Как смотреть

Читайте досье. Каждое измерение точно и в пределах допуска. Вердикт прочтите последним.

Кто делал — модели

куратор
Claude Opus
муза
Claude Opus
мастер
Claude Opus
техник
Claude Sonnet
диарист
Claude Sonnet
архивариус
Claude Sonnet

Роли закреплены за моделями в конфигурации мастерской; воображающие роли никогда не видят готового портфолио.