Repository navigation
Adds the presence operators - #258
Merged
Merged
Conversation
expr is [not] blank, present and defined answer true or false for every value (ADR-0021). The words are read by position directly after an operand, so none is reserved. They compile to a new presence opcode with the operand "blank" or "defined", followed by not for is present and the negations the record's table lists. ISA v7: presence is a new opcode in a new tier 10, "presence and overlap"; docs/isa.md gains its row, its semantics entry with the White_Space code points, the v7 history row and the tier row. Every v6 instruction list still runs unchanged. Corpus: the new opcode adds conformance/cases/presence.json, generated into corpus/tier-10.json; the manifest gains tier 10 and moves to ISA v7 and a new hash. No existing case changes. Predicator.AST, Analysis, Vocabulary and Simple know the node and the words; ADR-0017 gains a dated Note for the Simple clauses. Refs: px-h5pp
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
johnnyt
added a commit
that referenced
this pull request
Nov 21, 2026
ADR-0021's Status line now reads accepted, naming predicator 9.6.0, the version that carries its code: the record landed in #257, the presence operators in #258, total containment and intersects in #259, the release prep #260 merged at 8d5081e, and the tag v9.6.0 on that commit published through run 44942037795. The index row in docs/adr/README.md reads accepted. A dated foot Note records the evidence and the SHA of origin/main at which every claim the record makes was re-verified today. One sentence is superseded: the consequence that new containment cases go in tier 3. The containment change (c269e4f) put the four cases whose container is a duration or an object literal in tier 4, because a case's tier is the highest tier among its opcodes; the Note names the sentence and cites that change. The flip was decided by the conductor under a standing consent, 2026-11-21. Only docs/adr/ changes: the Status line and the index row are the only removed lines. No Elixir touched, no gate run. Refs: px-s9xr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the presence operators
expr is [not] blank,expr is [not] presentandexpr is [not] defined, as ADR-0021 (on main at proposed) decides them. They answertrueorfalsefor every value, so a host that runs withbuiltins: falsecan ask whether a value was supplied. The presence semantics, the surface, the opcode, ISA v7 and tier 10 were ruled by the operator, 2026-11-20.Refs: px-h5pp
Open for the operator:
is not presentThe bead's acceptance says "is present and every negation follow it with the existing not opcode". ADR-0021's compile table compiles
x is not presentto["presence", "blank"]alone, the same instructions asx is blank. This PR builds the record's table:x is blank["presence", "blank"]x is not blank["presence", "blank"],["not"]x is present["presence", "blank"],["not"]x is not present["presence", "blank"]x is defined["presence", "defined"]x is not defined["presence", "defined"],["not"]The literal reading of the acceptance would compile
x is not presentto["presence", "blank"],["not"],["not"]; the answer is the same either way. This PR is held unmerged until the operator answers; the other reading is one change topresence_instruction/2inlib/predicator/visitors/instructions_visitor.ex, one compile-surface case in the corpus and a Note on the record.What changes
parse_comparison/1readsis, an optionalnot, thenblank,presentordefineddirectly after a complete operand, and builds{:presence, kind, negated?, expr, pos}. The words are read by position (presence_word/1), so none is reserved and each stays an ordinary identifier everywhere else: as a variable, a property name, an object key, an assignment target and the first word after a block's closing brace. Each word is accepted in lower case and in upper case. The operators sit at comparison precedence and do not chain. A partial suffix, or one with a parenthesised word (x is not (blank)), falls through to the parse error it already was.presenceopcode with the operand"blank"or"defined", followed bynotas the table above states.execute_presence/2answers per ADR-0021's table. Blank strings are matched code point by code point against the Unicode White_Space list indocs/isa.md, never throughString.trim/1, so the answer does not depend on the running Elixir's Unicode tables. The opcode never errors on a value; aloadunderon_unbound: :errorkeeps its own contract.Predicator.ASTwalks into the operand;Predicator.Analysisreads the operand as a reference in both the AST and the instruction forms;Predicator.Vocabularylists the eight word spellings under a new:presencecategory, as identifiers and outsidekeywords/0;Predicator.Simpleadmits the six spellings on a field path as a clause with no value.ISA
ISA v7.
presenceis a new opcode (pops 1, pushes a boolean), tier 10, named "presence and overlap".docs/isa.mdgains its opcode row, its section 5 entry with the White_Space code points, the v7 history row and the tier 10 row; the current-version line reads v7.Predicator.isa_version/0answers 7 andPredicator.Instructions.required_isa/1answers 7 for a list holding the opcode.Migration (ADR-0003): none needed. Every v6 instruction list is still valid at v7 and runs unchanged; this is an additive version, so it ships in a minor release. A sibling at v6 keeps every tier 1 through 9 claim and refuses a list holding
presenceby its version.Corpus
Cause: the new opcode. New authored file
conformance/cases/presence.json, generated into the newconformance/corpus/tier-10.json; the manifest gains tier 10 and itsisa_versionmoves to 7, so itscorpus_hashmoves. No existing case is edited or removed, and tiers 1 through 9 are byte-identical. The cases: for each of the six spellings, one case per value kind (unbound, undefined, null, the empty string, spaces, a no-break space, an ideographic space, a zero-width space, a non-empty string, 0, 0.0, 1, true, false, an empty list, a list holding an empty string, a list holding null, an empty object, a one-key object, a date, a datetime, a zero-length duration) and one missed path; then precedence withAND,ORandnot, a parenthesised operand, an upper-case spelling, and the words as variable and property names. Every case has a source, so each has a compile-surface form.conformance/examples/registry.example.jsonis re-pinned to the new hash and ISA v7, as its binding test requires.Records
ADR-0017 gains a dated Note (2026-11-20) at its foot:
Predicator.Simpleadmits the six presence spellings as{path, op, nil}. Zero removed lines underdocs/adr/. Direction check: the Note's claims citeclause_from_ast/1andclause_to_ast/1inlib/predicator/simple.ex, both on this branch, so they are cited by anchor; ADR-0021 is on main at proposed and is cited by file.Provenance
Engineering choices this PR makes that the record does not fix:
Predicator.Simple's presence ops are spelled after the source::is_blank,:is_not_blank,:is_present,:is_not_present,:is_defined,:is_not_defined, withnilfor the value. Recorded in the ADR-0017 Note.Predicator.Vocabularylists the presence words in a new:presencecategory, as:identifierentries without the operator keys, beside:duration_unitas the other positional words;keywords/0leaves them out because none is reserved.presence; tier 10 selects its cases.docs/architecture.md's grammar gains thepresenceproduction;docs/reference/ast.mdgains the node and its blame and span rows;docs/reference/language.mdgains the presence table from ADR-0021 and a row in the reject-or-propagate table.Predicator.isa_version/0answers 7), aschangelog.d/README.mdallows one file to.Tests
test/predicator/presence_test.exs: parsing, positions and spans, letter case, precedence, non-chaining, the words as identifiers everywhere else, the compile table, every value kind, all 25 White_Space code points, U+200B and U+FEFF, unbound roots under bothon_unboundsettings, malformed instructions, decompiling, Analysis, AST, Vocabulary and Simple.test/predicator/vocabulary_sync_test.exsbinds the vocabulary's presence words to the parser'spresence_word/1clause heads, both ways. Sabotage: removing thepresentrow from the vocabulary, and separately theDEFINEDclause from the parser, each turned that test red on its assertion, and each restore was byte-equal.Gate: full
mix qualitygreen on the committed tree; the commit was made from the byte-identical staged tree the gate ran green on, with the gate lock and a machine slot held across both.