Skip to content

Fix/spaces primitive atoms - #217

Open
NatnaelTigistu wants to merge 3 commits into
trueagi-io:mainfrom
NatnaelTigistu:fix/spaces-primitive-atoms
Open

NatnaelTigistu wants to merge 3 commits into
trueagi-io:mainfrom
NatnaelTigistu:fix/spaces-primitive-atoms

Conversation

@NatnaelTigistu

@NatnaelTigistu NatnaelTigistu commented Aug 16, 2026

Copy link
Copy Markdown

What this PR does

  1. Fixes add-atom dropping primitive values. Previously, spaces.pl strictly expected incoming atoms to be S-Expression lists ([Rel|Args]). Adding a scalar primitive (like 42 or "Hello") would silently fail unification and be dropped. This PR wraps non-list atoms using an internal #primitive marker when asserting them to the Prolog database, and unwraps them during get-atoms and match operations.
  2. Cleans up .gitignore. Replaced the specific __pycache__ directory rules with a global __pycache__/ rule, and ignored the dynamically generated repos/ folder to keep untracked files clean.

Changes

  • src/spaces.pl: Added list-checking in add_sexp, remove_sexp, and match, ensuring primitives are safely stored and queried.
  • .gitignore: Globalized __pycache__ and added repos/.
  • Added examples/test_add_primitive.metta to the automated test suite to prevent regressions.

Testing

  • Primitives (42, "Hello", true) are now successfully added and returned from !(match &space $x $x).
  • Verified that all existing tests in sh test.sh continue to pass without regressions.

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.

1 participant