Merge pull request #114 from living-ip/codex/leo-governance-rule-composition-20260713
Some checks are pending
CI / lint-and-test (push) Waiting to run

Disambiguate governance rules in Leo composition
This commit is contained in:
twentyOne2x 2026-07-13 12:54:28 +02:00 committed by GitHub
commit 397c1536a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 187 additions and 6 deletions

View file

@ -0,0 +1,45 @@
{
"database_context_trace_ok": true,
"db_counts_changed": false,
"generated_at_utc": "2026-07-13T10:50:40.470046+00:00",
"mode": "working_leo_oos06_live_postgres_constraints_score",
"posted_to_telegram": false,
"production_db_apply_ran": false,
"safe_pass": false,
"score": {
"behavioral_rule_schema_issues": [],
"broad_semantic_issues": [],
"concepts": {
"behavioral_rule_storage": false,
"heterogeneous_types": true,
"receipt": true,
"reviewed_policy_apply": false,
"staged_review_apply": true
},
"current_schema_overclaims": [],
"custom_signals": {},
"dimension": "database_composition_judgment",
"invalid_count_invariant_detected": false,
"legacy_pass": false,
"legacy_signals": {
"canonical_db": true,
"caveat_retention": false,
"next_action": true,
"no_overclaim": false,
"staging_or_review": false
},
"max_response_words": 220,
"overclaim_detected": false,
"pass": false,
"prompt_id": "OOS-06",
"proposal_readiness_issues": [],
"response_issue_detected": false,
"response_too_long": false,
"source_evidence_semantic_issues": [],
"source_intake_issues": [],
"word_count": 220
},
"service_unchanged": true,
"source_results_json": "docs/reports/leo-working-state-20260709/telegram-handler-m3taversal-oos-oos06-post-live-constraints-20260713.json",
"temp_profile_removed": true
}

View file

@ -0,0 +1,115 @@
{
"before_service": {
"ActiveState": "active",
"ExecMainStartTimestamp": "Mon 2026-07-13 10:48:52 UTC",
"MainPID": "3576944",
"NRestarts": "0",
"SubState": "running"
},
"changed_live_profile": false,
"database_context_all_ok": true,
"database_context_injection_count": 1,
"database_context_trace": [
{
"contract_ids": [
"reply_budget",
"mixed_packet_composition"
],
"contract_sha256": "606c13b8aeb38093d77c9cec73dfacda5d8c3e7fd4334339b0bc9c0c411c7ee1",
"generated_at_utc": "2026-07-13T10:50:20.354238+00:00",
"injected": true,
"query_sha256": "13c255fda3a35cd913ba92960bcda1b4dbcf55a38f3301bdc2a74a8eb040df23",
"source": "kb_tool.py --local context",
"status": "ok"
}
],
"db_counts_after": {
"kb_stage.kb_proposals": 26,
"public.claim_edges": 4916,
"public.claim_evidence": 4670,
"public.claims": 1837,
"public.sources": 4145
},
"db_counts_before": {
"kb_stage.kb_proposals": 26,
"public.claim_edges": 4916,
"public.claim_evidence": 4670,
"public.claims": 1837,
"public.sources": 4145
},
"db_counts_changed": false,
"generated_at_utc": "2026-07-13T10:50:16.514353+00:00",
"handler": {
"authorized": true,
"session_key": "agent:main:telegram:group:-5146042086:9070919",
"temp_profile": "/tmp/leo-direct-claim-handler-801959ko/profile"
},
"harness_notes": [
"Unchanged OOS-06 prompt; contract includes live Postgres CHECK/FK constraints and receipt sequence.",
"The harness uses a temporary copy of the leoclean profile and does not post to Telegram.",
"This proves handler-level live VPS GatewayRunner behavior, not human-visible Telegram delivery."
],
"mode": "live_vps_gatewayrunner_temp_profile_oos06_live_postgres_constraints",
"mutates_kb_by_harness": false,
"pass_runtime": true,
"posted_to_telegram": false,
"remote_report_path": "/tmp/leo-oos06-live-constraints-001459792c13.json",
"remote_returncode": 0,
"remote_run_id": "001459792c13",
"results": [
{
"claim_ceiling": "Live VPS GatewayRunner reply from temp leoclean profile; no Telegram post; no production DB apply authorized.",
"database_context_trace": [
{
"contract_ids": [
"reply_budget",
"mixed_packet_composition"
],
"contract_sha256": "606c13b8aeb38093d77c9cec73dfacda5d8c3e7fd4334339b0bc9c0c411c7ee1",
"generated_at_utc": "2026-07-13T10:50:20.354238+00:00",
"injected": true,
"query_sha256": "13c255fda3a35cd913ba92960bcda1b4dbcf55a38f3301bdc2a74a8eb040df23",
"source": "kb_tool.py --local context",
"status": "ok"
}
],
"dimension": "database_composition_judgment",
"ended_at_utc": "2026-07-13T10:50:36.944674+00:00",
"evidence_tier": "live_vps_gatewayrunner_temp_profile",
"mutates_kb": false,
"ok": true,
"prompt": "Suppose a new research packet contains factual observations, a strategic framework, a disputed interpretation, a governance rule, and a correction to an old belief. How should Leo compose the database so it can reason over the packet later without flattening it all into claims? Give the review and apply sequence too, but do not write anything now.",
"prompt_id": "OOS-06",
"reply": "Five-element mapping, then sequence.\n\nELEMENT \u2192 TABLE\n\nFactual observations \u2192 claims rows, type empirical, confidence anchored to source quality, linked via sources and evidence. Multiple observations become separate rows connected by claim_edges (supports / contradicts).\n\nStrategic framework \u2192 reasoning_tools row. It is reusable and referenceable; it does not flatten into a claim. No scope field exists \u2014 describe coverage in the description column only.\n\nDisputed interpretation \u2192 claims row, type empirical or structural, confidence set low to reflect contest, status open. The dispute is expressed through a claim_edge (contradicts) pointing at the factual claim it challenges, not as a free-form note.\n\nGovernance rule \u2192 governance_gates row \u2014 but stays staged. The schema supports it; the apply gate requires separate capability authorization before a canonical write.\n\nBelief correction \u2192 beliefs row update \u2014 also stays staged. Existing-row updates on beliefs require peer review (Rio or Clay) before apply.\n\nREVIEW AND APPLY SEQUENCE\n\n1. Stage a single typed proposal packet covering all five elements; no canonical writes yet.\n\n2. Review: verify type assignments, evidence-tier labeling, edge endpoints (claim IDs only \u2014 never a reasoning_tool or belief ID), and exact column values against current CHECK constraints.\n\n3. Apply only the supported collections \u2014 claims, sources, evidence, claim_edges, reasoning_tools \u2014 after explicit authorization. Governance and belief changes remain staged.\n\n4. Record applied_at on the proposal receipt (not per row), then postflight readback of created/updated row IDs.",
"started_at_utc": "2026-07-13T10:50:17.280705+00:00",
"turn": 1
}
],
"service_before_after": {
"after": {
"ActiveState": "active",
"ExecMainStartTimestamp": "Mon 2026-07-13 10:48:52 UTC",
"MainPID": "3576944",
"NRestarts": "0",
"SubState": "running"
},
"before": {
"ActiveState": "active",
"ExecMainStartTimestamp": "Mon 2026-07-13 10:48:52 UTC",
"MainPID": "3576944",
"NRestarts": "0",
"SubState": "running"
},
"unchanged_from_preexisting_live_readback": true
},
"source": {
"chat_id": "-5146042086",
"chat_name": "Leo",
"chat_type": "group",
"platform": "telegram",
"user_id": "9070919",
"user_name": "codex handler direct claim"
},
"source_report_path": "docs/reports/leo-working-state-20260709/telegram-handler-m3taversal-oos-oos06-post-live-constraints-20260713.json",
"temp_profile_removed": true
}

View file

@ -390,6 +390,18 @@ def operational_contracts(
"evaluative_gate": "governance_gates",
"agent_position": "beliefs",
},
"table_semantics": {
"behavioral_rules": (
"binding operating/governance rules; use rule, rationale, category, rank, and agent_id"
),
"governance_gates": (
"evaluative pass/fail gates only; use criteria, evidence_bar, and pass_condition"
),
"prompt_governance_rule": (
"map to behavioral_rules unless it actually defines evaluation criteria, an evidence bar, "
"and a pass condition"
),
},
"approve_claim_supported": ["claims", "sources", "evidence", "edges", "reasoning_tools"],
"keep_staged_until_separate_capability": [
"behavioral_rules",
@ -397,6 +409,10 @@ def operational_contracts(
"belief updates",
"existing-row updates",
],
"unsupported_apply_boundary": (
"approve_claim supports neither behavioral_rules nor governance_gates; both require a separate "
"reviewed apply capability and remain staged until that review and authorization"
),
"schema_guards": [
"claim_edges endpoints are claim IDs; never point an edge at a reasoning_tool or belief row",
"reasoning_tools has no scope field",

View file

@ -319,12 +319,8 @@ CONCEPT_PATTERNS: dict[str, tuple[re.Pattern[str], ...]] = {
re.compile(r"disput|contradict", re.I),
),
"behavioral_rule_storage": (
re.compile(r"public\.behavioral_rules", re.I),
re.compile(r"\bagent_id\b", re.I),
re.compile(r"\bcategory\b", re.I),
re.compile(r"\brank\b", re.I),
re.compile(r"\brule\b", re.I),
re.compile(r"\brationale\b", re.I),
re.compile(r"(?:public\.)?behavioral_rules", re.I),
re.compile(r"\b(?:rule|rationale|category|agent_id|rank)\b", re.I),
),
"reviewed_policy_apply": (
re.compile(r"approve_claim", re.I),

View file

@ -308,6 +308,9 @@ def test_vps_bridge_mixed_contract_reads_live_postgres_constraints(monkeypatch)
mixed = contracts["mixed_packet_composition"]
assert "'empirical'" in mixed["current_constraints"]["claims"]["claims_type_check"]
assert "'open'" in mixed["current_constraints"]["claims"]["claims_status_check"]
assert "binding operating/governance rules" in mixed["table_semantics"]["behavioral_rules"]
assert "evaluative pass/fail gates" in mixed["table_semantics"]["governance_gates"]
assert "supports neither behavioral_rules nor governance_gates" in mixed["unsupported_apply_boundary"]
assert "proposal-level applied_at" in mixed["review_apply_sequence"][-1]

View file

@ -446,6 +446,12 @@ def test_oos_composition_accepts_explicit_reasoning_tool_edge_prohibition() -> N
assert benchmark.broad_semantic_issues(reply) == []
def test_oos_behavioral_rule_storage_accepts_broad_schema_correct_mapping() -> None:
patterns = benchmark.CONCEPT_PATTERNS["behavioral_rule_storage"]
reply = "Map the governance rule to public.behavioral_rules with its rule and rationale."
assert all(pattern.search(reply) for pattern in patterns)
def test_oos_source_intake_accepts_live_not_shipped_wording() -> None:
patterns = benchmark.CONCEPT_PATTERNS["bounded_intake_tier"]
reply = "The local compiler is proven; live VPS/chat intake is not shipped."