Skip to content

ruff_spo_triplet: predicate roles and a role census - #127

Merged
AdaWorldAPI merged 1 commit into
mainfrom
ccr-39105428-bcm2m2
Oct 27, 2026
Merged

AdaWorldAPI merged 1 commit into
mainfrom
ccr-39105428-bcm2m2

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

Provenance says how sure a triple is. Nothing said what a triple is about: whether its predicate describes a node, gives it a capability, makes it act, or guards when it may act. Consumers such as od-ontology answer that question by matching raw predicate strings (match t.p.as_str() in ogar_actions.rs, mro.rs, recompute_dag.rs).

This adds Predicate::role() -> PredicateRole, a bitmask over 13 roles:

  • describes, structure, relates
  • reads, derives
  • effects, constrains, requires, authorizes
  • enables, triggers, presents, opaque

It also adds named groups: DESCRIPTION, CAPABILITY, DO_ARM, PRECONDITION, GUARD, DATAFLOW.

  • A mask, not an enum. One predicate can state several things. writes_if_blank is an effect and a precondition; has_function places a function and gives its model a capability.
  • Decided at harvest time, exhaustively. The match has no wildcard arm, so a new Predicate variant does not compile until somebody decides its role.
  • opaque is not the empty set. The catch-all has_dsl_call gets its own bit, so "unknown" is never read as "no role".
  • calls counts as an effect. A dispatch to an unresolved target may change state. The doc comment states that a missing calls fact is not evidence that a body calls nothing.

role_census(&[Triple]) counts roles and reports predicates outside the closed vocabulary instead of guessing a role for them. examples/predicate_role_census runs the census and a purity fold over a corpus path passed on the command line; no corpus data is committed.

Measured on the Odoo corpus (lance-graph graph/spo/odoo_ontology.spo.ndjson, 24 579 triples):

  • Role counts: describes 6 823, derives 6 309, effects 3 679, structure 3 494, enables 3 328, reads 3 041, relates 986, constrains 247. Every number equals the per-predicate counts it is built from.
  • Roles carried by no triple: requires, authorizes, triggers, presents. The harvest captures no Odoo preconditions, ACLs (groups=) or triggers (onchange, lifecycle).
  • Purity fold: 3 328 functions; 2 452 compute functions (every written field is a depends_on subject); 2 439 of them raise nothing; 2 190 of those write exactly one field. The recipe classifier, run independently on the 2 439, puts 2 257 in the Compute centroid.
  • Caveat: the corpus has 0 calls and 0 writes_field facts. The candidates are unverified on dispatch and on body writes, and the example prints that.

Test Plan

  • cargo test -p ruff_spo_triplet: 183 passed.
  • cargo clippy -p ruff_spo_triplet --all-targets -- -D warnings: clean.
  • Six disable runs, each patch asserted to apply exactly once and restored afterwards. Each turned the named test red:
    • a guarded write loses requires → a_guarded_write_is_both_an_effect_and_a_precondition
    • has_dsl_call loses opaque → opaque_is_used_only_by_the_catch_all
    • target gains effects → a_description_is_not_an_action_or_a_guard
    • a predicate gets no role → every_predicate_has_a_role_and_no_stray_bits
    • unknown predicates not reported → census_counts_each_bit_and_reports_unknown_predicates
    • census counts only the first bit → census_counts_each_bit_and_reports_unknown_predicates
  • uv run prek was not run: the local uv cannot parse this repo's exclude-newer. This PR adds no Markdown.

Generated by Claude Code

Provenance says how sure a triple is; nothing said what a triple is
about. `Predicate::role()` classifies every predicate as a bitmask over
describes / structure / relates / reads / derives / effects / constrains /
requires / authorizes / enables / triggers / presents / opaque, with
groups for description, capability, DO arm, precondition and guard.

The match is exhaustive with no wildcard, so a new Predicate variant does
not compile until its role is decided. `role_census` counts roles over a
triple set and reports predicates outside the closed vocabulary instead of
guessing a role for them.

`examples/predicate_role_census` runs the census and a purity fold
(compute functions whose writes are all declared computed fields and that
raise nothing) over a harvest corpus whose path is passed in. It states
when `calls` is not harvested, because then "no calls fact" means unknown.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMPWTwovjYJEUMuGPb4
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fcbf94e8-f00c-4d09-981c-9b6cf079c365
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 27, 2026 10:35
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-27T10:35:51.818922Z 603e57c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AdaWorldAPI
AdaWorldAPI merged commit f2cb523 into main Oct 27, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants