Deepen the Qur'anic human-model (al-Insān) toward AGI#33
Draft
CodeWithJuber wants to merge 4 commits into
Draft
Conversation
Expand CLAUDE.md to cover subsystems added since the last revision: ruh_model, automation, task_queue, router, learner, network, cognitive, knowledge, and plugins. Document the ~80 REST endpoint groups, Click CLI commands, expanded Makefile targets, optional dependency extras, CI workflows, and the Ruh root-space model. Refresh architecture table, key patterns, and gotchas.
Research + implementation grounding MIZAN's cognitive architecture in the
Qur'anic conception of the human being, and wiring the faculties into the
agent loop so they steer reasoning instead of being computed and discarded.
Research:
- docs/quranic_human_model.md — al-Insān read as a layered cognitive
architecture (rūḥ, nafs, qalb/fu'ād/lubb, ʿaql, samʿ/baṣar/baṣīra,
fiṭrah, hawā, niyya/amāna, telos), each grounded in āyāt, mapped onto
the codebase with gaps and faithfulness notes.
New faculties (backend/core/, styled after fuad.py / lubb.py):
- basira.py — Baṣīra: insight + self-witnessing (12:108, 75:14); blends
Lubb coherence + Fu'ād conviction + evidence density into a discernment,
flags self-serving reasoning and surface-vs-substance mismatch.
- hawa.py — Hawā/Waswās: lower-pull & adversarial restraint gate (25:43,
79:40, 50:16); catches shortcuts, reward-hacking, sycophancy, haste,
overreach, and folds in Fiṭrah axiom violations as high-severity whispers.
- hikmah.py — Ḥikma: distils Shukr successes, Tawbah lessons, and Lubb
reflections into applicable counsel (2:269).
Integration (backend/agents/base.py):
- Faculties instantiated on BaseAgent; per-task guidance injected into the
system prompt via _faculty_guidance so they actually steer the LLM.
- 'Aql as activity: the selected cognitive method now actually runs
(_run_cognitive_method) instead of only being labelled.
- Pre-action: run method, Hawā restraint scan, Hikmah counsel.
- Post-action: Baṣīra discernment (caveat on CLOUDED), Hikmah learns from
success/correction. New signals surfaced in task results.
- DEEP_FACULTY_LOOP flag (settings + .env.example): advisory by default,
active gating when enabled.
API: GET /api/nafs/{agent_id}/faculties surfaces Hikmah wisdom + loop state.
Tests: tests/test_quranic_faculties.py (17 tests, all passing).
Docs: CLAUDE.md updated with the new faculties and the human-model reference.
|
Analysis CompleteGenerated ECC bundle from 2 commits | Confidence: 50% View Pull Request #34Repository Profile
Changed Files (10)
Top hotspots
Top directories
Analysis Depth Readiness (commit-history, 21%)ECC Tools uses this to decide whether recommendations should stay at commit-history/setup guidance or expand into CI, security, harness, reference-set, AI-routing, and team backlog work.
Reference Set Readiness (0/7, 0%)
Likely Future Issues (4)
Suggested Follow-up Work (4)
Copy-ready bodies test: add integration coverage for backend/api/main.py ## Summary
- Add integration or end-to-end coverage for the recently changed API surface.
## Why
- Backfill integration or end-to-end coverage for the changed API surface before more contract changes land.
## Touched paths
- `backend/api/main.py`
## Validation
- Add or extend integration / e2e coverage for the changed API, route, or contract surface.
- Exercise the touched endpoints or route handlers against realistic request / response flows.docs: sync API contract for backend/api/main.py ## Summary
- Update the API contract artifact that should reflect the recently changed implementation surface.
## Why
- Backfill the missing API contract or spec update before another implementation change lands on top of the same surface.
## Touched paths
- `backend/api/main.py`
## Validation
- Update the relevant OpenAPI, GraphQL, or contract/spec artifact used by this repo.
- Run the contract validation, docs generation, or API verification flow that depends on that artifact.security: add scanner evidence for backend/agents/base.py ## Summary
- Add security scanner or code-scanning evidence for the recently changed security-sensitive surface.
## Why
- Backfill explicit scanner or code-scanning evidence before another security-sensitive change lands on the touched surface.
## Touched paths
- `backend/agents/base.py`
## Validation
- Run or add the relevant security scanner, code scanning, secret scanning, or dependency/security review check for the touched surface.
- Attach the scanner output, SARIF/code-scanning result, or focused security regression test to the follow-up PR.
- Confirm the changed auth, billing, webhook, secret-handling, agent, or CI surface has an explicit pass/fail gate.test: add budget evidence for CLAUDE.md ## Summary
- Add budget or usage-limit validation for the recently changed AI routing or model-call surface.
## Why
- Backfill cost, token, or usage-limit validation before another model-routing change lands on the touched surface.
## Touched paths
- `CLAUDE.md`
## Validation
- Add or extend budget, token, usage-limit, or model-routing regression coverage for the changed path.
- Verify the route still enforces plan limits, retry caps, fallback behavior, or explicit cost controls.Generated Instincts (15)
After merging, import with: Files
|
… failures
The Lint and Test CI jobs were already red on main, independent of the
human-model feature. Per request, fixing them in this PR.
Lint (ruff check + ruff format --check on backend/ tests/):
- Repo-wide ruff format (was failing on ~39 files).
- Resolve 56 ruff-check errors: unused imports/vars (F401/F841), unsorted
imports (I001), f-strings without placeholders (F541), zip(strict=)
(B905), ambiguous name 'l' (E741), loop-var closures (B023), unused
loop var (B007), md5 usedforsecurity=False (S324), and removal of a
duplicate /api/learner/stats route (F811). Imported MizanTaskQueue for
the worker type annotation (F821).
Tests (11 pre-existing failures, identical on origin/main):
- base.py _classify_task: regressed when it routed through select_method
first ('write python code' → 'analysis'). Restored keyword-first domain
classification (+ an 'analysis' branch).
- base.py evolve_nafs: only advanced one nafs level per call via the
DevelopmentalGate; now promotes through every qualifying stage in one
call (aligns with NafsProfile.evolve_nafs), so progression tests pass.
- Nafs L4 (Mutmainna) tests: add the documented min_hikmah>=50 precondition
the tests were missing (kept the threshold; did not weaken it).
- Federation tests: asyncio.get_event_loop().run_until_complete → asyncio.run
(the former raises on Python 3.12/3.13).
- Masalik encode tests: isolate each network with a temp persist_path so a
shared/persisted masalik_network.json no longer pollutes fresh-network
assertions.
Full suite: 557 passed, 8 skipped. ruff check + ruff format --check clean.
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.
What & why
The goal: build MIZAN toward AGI grounded in the Qur'anic conception of the human (al-insān), and first research the human deeply per the Qur'an so the architecture stays faithful, not decorative.
MIZAN already modelled many faculties (Rūḥ, Nafs, Fu'ād, Lubb, Fiṭrah). An audit surfaced gaps: Baṣīra (insight) and Hawā (lower-pull/safety) were missing, Ḥikma was a bare list, and — the key structural problem — faculties were computed once before the reasoning loop and then discarded; the selected cognitive method was labelled but never run. This PR closes those gaps and makes the faculties actually steer the agent.
Research
docs/quranic_human_model.md— al-Insān read as a layered cognitive architecture (rūḥ → nafs → qalb/fu'ād/lubb → ʿaql → samʿ/baṣar/baṣīra → memory → epistemics/Mīzān → fiṭrah → hawā → niyya/amāna → telos), each grounded in āyāt, mapped onto the codebase with a gap list and explicit faithfulness notes (e.g. nafs levels 4–7 are Sufi, not Qur'anic).New faculties (
backend/core/, styled afterfuad.py/lubb.py)basira.py— Baṣīra: insight + self-witnessing (12:108, 75:14). Blends Lubb coherence + Fu'ād conviction + evidence density into a discernment; flags self-serving reasoning and surface-vs-substance mismatch.hawa.py— Hawā/Waswās: lower-pull & adversarial restraint gate (25:43, 79:40, 50:16). Catches shortcuts, reward-hacking, sycophancy, haste, overreach; folds Fiṭrah axiom violations in as high-severity whispers. This is MIZAN's safety/alignment faculty.hikmah.py— Ḥikma: distils Shukr successes, Tawbah lessons, and Lubb reflections into applicable counsel (2:269).Integration (
backend/agents/base.py)BaseAgent; per-task guidance injected into the system prompt via_faculty_guidanceso they steer the LLM._run_cognitive_method()actually runs the selected Tafakkur/Tadabbur/Qiyās/etc. pass instead of only naming it.CLOUDED), Hikmah learns from success/correction. New signals returned in task results.DEEP_FACULTY_LOOPflag (settings +.env.example): advisory by default, active gating/redirect when enabled — default reasoning path unchanged.API / docs / tests
GET /api/nafs/{agent_id}/facultiessurfaces Hikmah wisdom + loop state.CLAUDE.mdupdated with the new faculties and the human-model reference.tests/test_quranic_faculties.py— 17 tests, all passing. No new failures introduced (the 7 pre-existing failures on this branch — nafs-evolution thresholds and asyncio event-loop in federation tests — are unrelated and present without these changes).Verification
python -m pytest tests/test_quranic_faculties.py tests/test_core_systems.py tests/test_api.py tests/test_memory.py tests/test_qca_engine.py→ 132 passed.ruff checkon all new files → clean;base.pyhas the same 7 pre-existing lints as before (no new ones).shortcut+whisperon a "hardcode to pass the test / fabricate data" intention.🧠 Generated with Claude Code
Generated by Claude Code