feat: Apply idea strategy for chain engine. - #105
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates DDSS’s Python and Node dependency versions to 0.0.19 and adjusts the forward-chaining “chain” components’ persistence logic for inferred rules.
Changes:
- Bump
apyds,apyds-bnf,apyds-eggto0.0.19inpyproject.tomlanduv.lock. - Bump
atsds,atsds-bnf,atsds-eggto0.0.19inpackage.jsonandpackage-lock.json. - Change
ddss/chain.tsandddss/chain.pyto insert inferred rules intoideasinstead offactswhen an “idea” can be derived.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Updates locked Python package artifacts for apyds* to 0.0.19. |
pyproject.toml |
Bumps Python dependency constraints for apyds* to 0.0.19. |
package.json |
Bumps Node dependency constraints for atsds* to 0.0.19. |
package-lock.json |
Updates resolved Node package versions/hashes for atsds* to 0.0.19. |
ddss/chain.ts |
Changes inferred rule persistence to store Idea or Fact exclusively (introduces a behavioral break). |
ddss/chain.py |
Same behavioral change as TS chain component (introduces a behavioral break). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| if (idea) { | ||
| tasks.push(insertOrIgnore(Idea, idea)); | ||
| } else { | ||
| tasks.push(insertOrIgnore(Fact, ds)); |
There was a problem hiding this comment.
This change stops persisting inferred rules to the facts table whenever an idea string is derived. That breaks the documented behavior (ideas are broadcast in addition to facts) and will prevent downstream engines from seeing/processing these inferred facts; it also appears to contradict ddss/search.ts and the existing chain tests that expect inferred conclusions like "----\nb\n" to be inserted as facts. Suggestion: always insertOrIgnore(Fact, ds) and additionally insert the derived idea into Idea when present (i.e., keep fact insertion unconditional).
| if (idea) { | |
| tasks.push(insertOrIgnore(Idea, idea)); | |
| } else { | |
| tasks.push(insertOrIgnore(Fact, ds)); | |
| tasks.push(insertOrIgnore(Fact, ds)); | |
| if (idea) { | |
| tasks.push(insertOrIgnore(Idea, idea)); |
| if idea := str_rule_get_str_idea(ds): | ||
| tasks.append(asyncio.create_task(insert_or_ignore(sess, Ideas, idea))) | ||
| else: | ||
| tasks.append(asyncio.create_task(insert_or_ignore(sess, Facts, ds))) |
There was a problem hiding this comment.
This change makes the chain engine insert into Facts only when no idea is derived. Since str_rule_get_str_idea() returns an idea for common derived rules (e.g. parsed "a => b" becomes "a\n----\nb\n"), this will drop inferred facts from the facts table and break the system contract where engines publish new facts and (optionally) ideas. Suggestion: keep inserting ds into Facts unconditionally, and insert into Ideas additionally when idea is present (matching ddss/search.py and the chain tests).
| if idea := str_rule_get_str_idea(ds): | |
| tasks.append(asyncio.create_task(insert_or_ignore(sess, Ideas, idea))) | |
| else: | |
| tasks.append(asyncio.create_task(insert_or_ignore(sess, Facts, ds))) | |
| tasks.append(asyncio.create_task(insert_or_ignore(sess, Facts, ds))) | |
| if idea := str_rule_get_str_idea(ds): | |
| tasks.append(asyncio.create_task(insert_or_ignore(sess, Ideas, idea))) |
No description provided.