Skip to content

feat(python): add neutrosophic phase 1 core#504

Open
SeCuReDmE-main-dev wants to merge 3 commits into
2FastLabs:mainfrom
SeCuReDmE-main-dev:phase_1
Open

feat(python): add neutrosophic phase 1 core#504
SeCuReDmE-main-dev wants to merge 3 commits into
2FastLabs:mainfrom
SeCuReDmE-main-dev:phase_1

Conversation

@SeCuReDmE-main-dev
Copy link
Copy Markdown

Summary

This opens the RFC's Phase 1 as a standalone upstream PR.

Scope in this PR is intentionally limited to a dependency-free Python neutrosophic core:

  • Triplet(T, I, F) value object with validation
  • formal operators: N-norm, N-conorm, negation
  • consensus helpers
  • deterministic text scorer
  • threshold-based decision helper
  • focused unit tests for the core package

Why this scope

Issue #484 proposes a staged path. This PR only covers the smallest reviewable primitive before any classifier, supervisor, orchestrator, or TypeScript integration work.

That keeps the review surface narrow and makes it easier to answer the first maintainer question:

Is a small opt-in uncertainty core worth having in the project at all?

Included

  • python/src/agent_squad/neutrosophic/*
  • python/src/tests/neutrosophic/*

Explicitly not included

  • NeutrosophicSupervisor
  • classifier result extensions
  • route_request(..., use_neutrosophic=True) integration
  • TypeScript parity
  • benchmark/proof-oriented integration tests
  • docs/cookbook additions

Validation

Run locally from python/:

python -m pytest src/tests/neutrosophic -q
python -m ruff check src/agent_squad/neutrosophic src/tests/neutrosophic --config ruff.toml
python -m ruff format --check src/agent_squad/neutrosophic src/tests/neutrosophic

Current result:

  • 33 passed
  • ruff check: passed
  • ruff format --check: passed

Notes

I also backported two core-only hardening fixes before opening this PR:

  • non-finite classifier confidence now raises ValueError
  • scorer pattern matching no longer treats substrings as full error/hedging matches

Related RFC: #484

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e3c7e4598

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if not math.isfinite(confidence_value):
raise ValueError("confidence must be finite")

confidence_value = _clamp(confidence_value)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject out-of-range classifier confidence

When a classifier returns a malformed confidence outside the documented 0–1 range, this clamp silently turns it into an extreme certainty instead of surfacing the bad value; for example, score_classifier_confidence(2, selected=True) becomes Triplet(T=1, I=0, F=0). Since the downstream decision helper treats high truth/low indeterminacy as confident, an invalid model output can be promoted to the strongest possible route rather than being handled as bad/uncertain input.

Useful? React with 👍 / 👎.

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