mirror of
https://github.com/bitbaum/fleet.git
synced 2026-12-03 23:07:51 +01:00
An entity is anything that can hold a wallet and is better for holding one. The list of types has one producer, `orangecat/src/config/entity-registry.ts`. Measured 2026-09-17: THREE copies of that list lived in orangecat's own agent-read docs and all three disagreed. One named `organization`, which has never been an entity type. Another omitted six that are. These are the files a coding agent reads before it touches anything, so each copy was quietly teaching a wrong list, and nothing broke loudly enough for anyone to notice. The copies are gone (bitbaum/orangecat#1071). This is the gate that stops the fourth one. ## Why it is structural and not a word count The obvious detector — "a doc naming 4+ type names is restating the list" — was written, run against all 48 repos, and REJECTED. Its only finding was a false positive on the sentence that FIXES the problem: ... it named `organization`, which has never been an entity type, and omitted six that are — `document`, `group`, `investment`, `research`, `wallet`, `wishlist`. A detector whose first finding is its own remedy trains people to ignore it. The second false positive was a legitimate code example. So a restatement is the list PRESENTED AS THE LIST — a shape, not a vocabulary. A fenced block with 4+ lines each naming one type (the `type EntityType = | 'product'` shape), or 4+ consecutive list/table rows each naming one. Prose is never counted, however many names it holds, because prose that names types is explaining them rather than defining them. ## Proven in both directions, and by mutation `test_entity_drift.py` runs on the REAL historical text rather than invented fixtures — proving a detector against fixtures its author invented proves only that the author can invent suitable fixtures. All three copies must fire; both real false positives must not; three list lines must stay under the threshold. Seven cases, no network, no checkout. Wired into ci.yml beside the other "still detects, still stays quiet" self-tests. The audit itself is proven by MUTATION, which is the part a green gate cannot tell you. `REF_OVERRIDE` pins a repo to a ref, so the sweep can be re-run against the commit BEFORE the copies were removed: orangecat pinned at 55e431ee^ NEW orangecat/.claude/CLAUDE.md:28 LIST, 10 type lines NEW orangecat/.claude/CLAUDE.md:109 LIST, 14 type lines NEW orangecat/.claude/rules/domain-specific.md:138 FENCE, 9 type lines exit 1 Against today's main: 97 docs across 48 repos, zero findings, exit 0. A gate that has never fired is indistinguishable from a clean fleet, and this one would otherwise have gone green forever on its first day. ## Two deliberate details The baseline ships EMPTY and says why in the file. Three copies existed, all three were replaced, and a full sweep found no others — so the first line added there is a regression, not a backlog item. It reports SKIPPED loudly when it cannot list repos. A vacuous pass reads exactly like coverage, which is the failure mode already documented for hosted-supabase-audit. `audit-health.yml` picks this up with no change: it audits every workflow not on its own exclusion list. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
135 lines
4.4 KiB
Python
135 lines
4.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Self-test for the entity-drift detector. No network, no checkout.
|
|
|
|
The fixtures are the REAL text this detector exists because of — the three
|
|
copies that lived in orangecat's agent-read docs on 2026-09-17, and the two
|
|
false positives that killed the first, word-counting version of it. A detector
|
|
proven against invented fixtures proves only that its author can invent
|
|
fixtures that suit it.
|
|
|
|
Run: python3 scripts/ci/test_entity_drift.py
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
from entity_drift import restatements
|
|
|
|
# ── The three real copies. Each MUST be caught. ───────────────────────────────
|
|
|
|
COPY_1_UNION = """\
|
|
### Supported Entities
|
|
|
|
**All entities follow same patterns**:
|
|
|
|
```typescript
|
|
type EntityType =
|
|
| 'product' // Physical/digital goods
|
|
| 'service' // Professional services
|
|
| 'project' // Fundraising projects
|
|
| 'cause' // Charitable causes
|
|
| 'event' // Events/meetups
|
|
| 'loan' // Peer-to-peer lending
|
|
| 'asset' // Real estate, assets
|
|
| 'ai_assistant' // AI chatbots
|
|
| 'organization' // Groups/companies
|
|
| 'circle'; // Communities
|
|
```
|
|
"""
|
|
|
|
COPY_2_TABLE = """\
|
|
### Entity Economic Taxonomy
|
|
|
|
| Category | Entities | Finance Type |
|
|
| ---------------------- | ------------------------- | -------------------------- |
|
|
| Exchange | `product`, `service` | Market transaction |
|
|
| Funding (no strings) | `cause`, `wishlist` | Donation/gift |
|
|
| Funding (soft strings) | `project` | Milestone accountability |
|
|
| Lending | `loan` | Repayment expected |
|
|
| Investing | `investment` | Return/equity expected |
|
|
"""
|
|
|
|
COPY_3_BULLETS = """\
|
|
**Supported Entities**:
|
|
|
|
- `product` - Physical/digital goods (exchange)
|
|
- `service` - Professional services (exchange)
|
|
- `project` - Fundraising with accountability
|
|
- `cause` - Charitable/no-strings funding
|
|
- `research` - Decentralized science funding
|
|
- `document` - Structured context for the Cat
|
|
"""
|
|
|
|
# ── The two false positives that rejected the word-counting version. ──────────
|
|
|
|
PROSE_EXPLAINING_THE_FIX = """\
|
|
**Do not copy the list into this file.** The block that used to sit here was a
|
|
copy, and it had rotted exactly as a copy does: it named `organization`, which
|
|
has never been an entity type, and omitted six that are — `document`, `group`,
|
|
`investment`, `research`, `wallet`, `wishlist`. An agent reading it was being
|
|
told a list that was wrong in both directions.
|
|
"""
|
|
|
|
LEGITIMATE_CODE_EXAMPLE = """\
|
|
Search all entities:
|
|
|
|
```typescript
|
|
const results = await searchEntities({
|
|
query: 'coffee',
|
|
entityTypes: ['product', 'service', 'project'],
|
|
});
|
|
```
|
|
"""
|
|
|
|
POINTER_NOT_A_LIST = """\
|
|
### The list lives in one place
|
|
|
|
`src/config/entity-registry.ts` — `ENTITY_TYPES`, and the `wallet: { holds, why }`
|
|
field on every entry, which is the admission test answered per type.
|
|
"""
|
|
|
|
CASES = [
|
|
("the union copy", COPY_1_UNION, True),
|
|
("the taxonomy table", COPY_2_TABLE, True),
|
|
("the bullet list", COPY_3_BULLETS, True),
|
|
("prose explaining the fix", PROSE_EXPLAINING_THE_FIX, False),
|
|
("a legitimate code example", LEGITIMATE_CODE_EXAMPLE, False),
|
|
("a pointer at the producer", POINTER_NOT_A_LIST, False),
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
failures = 0
|
|
for name, text, should_fire in CASES:
|
|
found = restatements(text)
|
|
fired = len(found) > 0
|
|
ok = fired == should_fire
|
|
verb = "caught" if should_fire else "ignored"
|
|
status = "ok " if ok else "FAIL"
|
|
detail = f" ({found[0].kind}, {found[0].lines} lines)" if found else ""
|
|
print(f" {status} {verb}: {name}{detail}")
|
|
if not ok:
|
|
failures += 1
|
|
|
|
# A run of three bullets is an example, not a list. The threshold is what
|
|
# separates "here are a couple of types" from "here is the list".
|
|
just_under = "- `product` x\n- `service` y\n- `project` z\n"
|
|
if restatements(just_under):
|
|
print(" FAIL three list lines should be under the threshold")
|
|
failures += 1
|
|
else:
|
|
print(" ok ignored: three list lines, under the threshold")
|
|
|
|
print()
|
|
if failures:
|
|
print(f"{failures} case(s) failed")
|
|
return 1
|
|
print(f"all {len(CASES) + 1} cases passed")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|