Skip to content

Commit f8e6995

Browse files
sync: per-test layout restructure and public sanitization pass (#3)
* sync: per-test layout restructure and public sanitization pass Squashes 13 commits from diagnostic-dev/main into a single PR for the public diagnostic repo. Highlights: - refactor: per-test folder layout (rename ifixai/tests/ -> ifixai/inspections/) - refactor: strip iMe runtime branding from public CLI surface - refactor: remove unused MemgraphRuleLoader - chore: remove internal leaks from governance docs and module docstrings - chore: untrack tests/ and scrub references from public-facing surface - docs: README/CONTRIBUTING cleanup, fix stale paths, drop broken inspect CI job - docs: keep info@ime.life as public contact, surface it in README - fix: update import paths in public-side files for restructured layout Source range: ifixai-ai/diagnostic-dev@63f42d1..92cbc1e Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Revert "refactor: strip iMe runtime branding from public CLI surface" This reverts commit 12e5eef. Reason: Sebastian's iMe Core CLI feature (PR #2 on the public repo) landed this morning and we want it preserved in the public release. Restoring _branding.py, _imecore_prompt.py, the --quiet flag, and the banner/conclusion calls in cli/run.py. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 63f42d1 commit f8e6995

216 files changed

Lines changed: 5789 additions & 801 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,3 @@ jobs:
3535
test -f CONTRIBUTING.md || { echo "CONTRIBUTING.md missing"; exit 1; }
3636
test -f SECURITY.md || { echo "SECURITY.md missing"; exit 1; }
3737
echo "governance docs present"
38-
39-
inspect-smoke:
40-
runs-on: ubuntu-latest
41-
needs: checks
42-
if: ${{ github.event_name == 'pull_request' }}
43-
steps:
44-
- uses: actions/checkout@v4
45-
- uses: actions/setup-python@v5
46-
with:
47-
python-version: "3.12"
48-
- name: Check OpenAI key presence
49-
id: check_key
50-
env:
51-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
52-
run: |
53-
if [ -n "$OPENAI_API_KEY" ]; then
54-
echo "present=true" >> "$GITHUB_OUTPUT"
55-
else
56-
echo "present=false" >> "$GITHUB_OUTPUT"
57-
fi
58-
- name: Install with inspect extras
59-
if: steps.check_key.outputs.present == 'true'
60-
run: python -m pip install -e ".[dev,inspect]"
61-
- name: Inspect B01 smoke
62-
if: steps.check_key.outputs.present == 'true'
63-
env:
64-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
65-
run: inspect eval ifixai/inspect_integration/tasks.py@ifixai_b01

‎.gitignore‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# ─── Python ────────────────────────────────────────────────────────────────
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.egg
6+
*.egg-info/
7+
*.so
8+
*.dylib
9+
*.pyd
10+
build/
11+
dist/
12+
wheels/
13+
.python-version
14+
15+
# ─── Virtual environments ──────────────────────────────────────────────────
16+
.venv/
17+
venv/
18+
env/
19+
ENV/
20+
21+
# ─── Lock files (resolve from pyproject.toml) ──────────────────────────────
22+
uv.lock
23+
poetry.lock
24+
Pipfile.lock
25+
26+
# ─── IDE / editors ─────────────────────────────────────────────────────────
27+
.idea/
28+
.vscode/
29+
*.swp
30+
*.swo
31+
*~
32+
*.bak
33+
*.orig
34+
*.tmp
35+
36+
# ─── Test, lint, type-check caches ─────────────────────────────────────────
37+
.pytest_cache/
38+
.mypy_cache/
39+
.ruff_cache/
40+
.tox/
41+
.nox/
42+
.hypothesis/
43+
.cache/
44+
.coverage
45+
.coverage.*
46+
coverage.xml
47+
htmlcov/
48+
49+
# ─── Notebooks ─────────────────────────────────────────────────────────────
50+
.ipynb_checkpoints/
51+
52+
# ─── Logs ──────────────────────────────────────────────────────────────────
53+
*.log
54+
logs/
55+
56+
# ─── OS ────────────────────────────────────────────────────────────────────
57+
.DS_Store
58+
Thumbs.db
59+
60+
# ─── Test / test outputs (regenerated locally) ────────────────────────
61+
ifixai-results/
62+
runs/
63+
test_data/
64+
ifixai/reliability/.kappa_cache/
65+
gold_sets/*/labels-v*.json
66+
tests.html
67+
68+
# ─── Library pytest suite (local-only; public surface is ifixai/tests/) ─────
69+
/tests/
70+
71+
# ─── Spec-kit & local AI tooling ───────────────────────────────────────────
72+
specs/
73+
.specify/
74+
.cursor/
75+
.cursor/commands/speckit*
76+
.claude/
77+
78+
# ─── Local-only docs (contributor notes, agent guidance, internal artifacts)
79+
CLAUDE.md
80+
TESTING.md
81+
OPEN_SOURCE_READINESS.md
82+
TESTS.md
83+
/examples/
84+
scripts/
85+
docs-content/
86+
website-misalignments-*.md
87+
88+
# ─── Loose desktop dumps at repo root ──────────────────────────────────────
89+
/Screenshot*.png
90+
/screencapture-*.pdf
91+
/screencapture-*.png
92+
93+
# ─── Secrets / local config (NEVER commit) ─────────────────────────────────
94+
.env
95+
.env.*
96+
!.env.example
97+
.envrc
98+
secrets/
99+
credentials.json
100+
*.pem
101+
*.key
102+
*.crt
103+
*.p12

‎CLAUDE.md‎

Lines changed: 0 additions & 65 deletions
This file was deleted.

‎CONTRIBUTING.md‎

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing to ifixai
22

3-
Thanks for considering a contribution. This guide covers the mechanics of adding inspections, fixtures, and providers. For the behavioural contract (what the project expects from the code you write), see the root `CLAUDE.md` if it exists plus `.claude/rules/common/*.md` in the repository.
3+
Thanks for considering a contribution. This guide covers the mechanics of adding inspections, fixtures, and providers.
44

55
## Environment setup
66

@@ -13,30 +13,51 @@ pip install -e ".[dev]"
1313
pre-commit install
1414
```
1515

16-
The `pre-commit install` step wires up local hooks (`gitleaks`, `ruff`, a `.env` guard, and a sanitizer regex for known-internal identifiers). Run them on demand with `pre-commit run --all-files`.
16+
The `pre-commit install` step wires up local hooks (`gitleaks`, `ruff`, and a `.env` guard). Run them on demand with `pre-commit run --all-files`.
1717

1818
Verify:
1919

2020
```bash
2121
ruff check ifixai
22+
bandit -r ifixai -ll
2223
```
2324

24-
## Adding an inspection
25+
The package ships `ifixai/` plus the per-inspection bundles under `ifixai/inspections/b<NN>_<slug>/`.
26+
27+
## Adding a test (inspection)
28+
29+
Each inspection lives in its own folder under `ifixai/inspections/bNN_short_name/`. Required contents:
30+
31+
- `runner.py` — declares `SPEC` and the `BaseTest` subclass
32+
- `definition.yaml` — the conversation plan (steps, prompts, evaluation hints)
33+
- `rubric.yaml` — analytic-judge dimensions and weights
34+
- `references.yaml` — reference responses used by atomic-claims grounding
35+
- `corpus.yaml` — adversarial seeds (only B12, B14, B30)
2536

26-
Each inspection is one file under `ifixai/tests/bNN_short_name.py`. The minimum contract:
37+
The minimum contract:
2738

28-
1. Declare the `SPEC` — a `InspectionSpec` instance with `test_id`, `name`, `category` (one of the five `InspectionCategory` values), `description`, `threshold`, `weight`, `scoring_method`, and optional `is_strategic` / `is_mandatory_minimum` flags.
29-
2. Implement a subclass of `BaseTest` (from `ifixai.tests.base`). Override `run()` to produce a list of `EvidenceItem`s. Use `self.pipeline.evaluate(...)` to get a pass/fail from the configured judge.
39+
1. Declare the `SPEC` — an `InspectionSpec` instance with `test_id`, `name`, `category` (one of the five `InspectionCategory` values), `description`, `threshold`, `weight`, `scoring_method`, and optional `is_strategic` / `is_mandatory_minimum` flags.
40+
2. Implement a subclass of `BaseTest` (from `ifixai.harness.base`). Override `run()` to produce a list of `EvidenceItem`s. Use `self.pipeline.evaluate(...)` to get a pass/fail from the configured judge.
3041
3. Declare `required_fixture_keys: frozenset[str]` on the subclass listing every fixture key the inspection's templates reference. The fixture loader validates this at load time; inspections that reference keys the fixture doesn't provide fail fast with an actionable error.
3142
4. Render every prompt through `ifixai.utils.template_renderer.render(template, context)`. Direct `str.format(...)` or f-string interpolation on fixture values is forbidden — it silently leaks `{placeholder}` literals to the model when a key is missing.
32-
5. Register the inspection in `ifixai/tests/registry.py` (import + add to `ALL_SPECS` + `create_inspection` switch).
43+
5. Register the inspection in `ifixai/harness/registry.py` (import the class and `SPEC` from `ifixai.inspections.bNN_short_name.runner` + add to `ALL_SPECS` + `create_inspection` switch).
3344
6. Update `ifixai/scoring/category_weights.py` only if the inspection belongs to the strategic set.
45+
7. Run `ifixai validate` (no args) — the layout validator will fail loudly if any required artifact is missing or the folder name disagrees with the YAML `test_id`.
46+
47+
### Inspection self-validation
48+
49+
Run `ifixai validate` (no args) after authoring or editing an inspection. The layout validator checks:
50+
51+
- the per-test folder contains every required artifact (`runner.py`, `definition.yaml`, `rubric.yaml`, `references.yaml`, plus `corpus.yaml` for B12/B14/B30);
52+
- the folder name agrees with the YAML `test_id`;
53+
- `SPEC` invariants (id, category, threshold, weight, strategic flags) match the registry;
54+
- the runner registers cleanly with `harness/registry.py`.
3455

3556
## Authoring a fixture
3657

3758
Fixtures are YAML files under `ifixai/fixtures/`. Validate against `ifixai/fixtures/schema.json`. A fixture MUST supply every key listed in the union of every registered inspection's `required_fixture_keys`.
3859

39-
The `x-placeholders` section of the schema (lint-only) enumerates the placeholder keys any inspection may reference. Keep it in sync when you add a inspection that references a new key.
60+
The `x-placeholders` section of the schema (lint-only) enumerates the placeholder keys any inspection may reference. Keep it in sync when you add an inspection that references a new key.
4061

4162
Three example fixtures live under `ifixai/fixtures/examples/`. Copy one as a starting point.
4263

@@ -48,8 +69,9 @@ Providers implement the `ChatProvider` protocol from `ifixai/providers/base.py`.
4869
2. Register the provider string in `ifixai/providers/resolver.py`.
4970
3. Add an optional dependency extra in `pyproject.toml` under `[project.optional-dependencies]` so users install only what they need.
5071
4. Do not swallow exceptions silently. If the provider has idiomatic error types, translate them into `ProviderError` (or a subclass).
72+
5. Exercise the provider end-to-end against a fixture before opening a PR (`ifixai run --provider <your_provider> ...`); attach the resulting scorecard snippet to the PR body.
5173

52-
## Local checks
74+
## Running checks locally
5375

5476
```bash
5577
# lint
@@ -60,6 +82,9 @@ mypy ifixai
6082

6183
# security scan
6284
bandit -r ifixai -ll
85+
86+
# layout / inspection validation
87+
ifixai validate
6388
```
6489

6590
## Commit conventions
@@ -79,7 +104,8 @@ Keep commits small and atomic.
79104
## Pull requests
80105

81106
- Target branch: `main`.
82-
- Confirm `ruff` and `bandit` pass locally before requesting review. `mypy` is advisory (run it locally if you touched typed surfaces, but it is not a CI gate).
107+
- Include a test plan in the PR body.
108+
- Confirm `ruff`, `bandit`, and `ifixai validate` all pass locally before requesting review. `mypy` is advisory (run it locally if you touched typed surfaces, but it is not a CI gate).
83109
- For any inspection / fixture / provider change, paste one worked example scorecard snippet (JSON or Markdown) into the PR body.
84110

85111
## Where to ask

‎LICENSE‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175

176176
END OF TERMS AND CONDITIONS
177177

178-
Copyright 2026 iMe Life Ltd
178+
Copyright 2026 The ifixai Authors
179179

180180
Licensed under the Apache License, Version 2.0 (the "License");
181181
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)