Skip to content

Commit bf0753a

Browse files
committed
Reduce external reproduction friction
1 parent f7f48f0 commit bf0753a

6 files changed

Lines changed: 180 additions & 5 deletions

File tree

‎README.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ claims.
8585
For a clean clone, expected outputs, and mismatch reporting, use the
8686
[reproduction guide](docs/REPRODUCTION.md).
8787

88+
If dependencies are already installed in your current environment, the module
89+
commands are OS-neutral:
90+
91+
```bash
92+
python -m pip install -r requirements-dev.txt
93+
python -m unittest discover -s tests
94+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_external_reference_pack --pretty
95+
```
96+
97+
Windows PowerShell using the local venv executable:
98+
8899
```powershell
89100
python -m venv .venv
90101
.\.venv\Scripts\python.exe -m pip install -r requirements-dev.txt
@@ -101,6 +112,9 @@ External reviewer-owned CSV/JSONL/JSON files can be run through the same
101112
adapter without exporting raw prompt text. See
102113
[docs/EXTERNAL_REPRODUCTION.md](docs/EXTERNAL_REPRODUCTION.md).
103114

115+
Default reproduction uses the local `mock` provider and requires no API key,
116+
network call, or OpenAI model name.
117+
104118
Optional FastAPI server:
105119

106120
```powershell
@@ -178,6 +192,7 @@ are not stored for later retrieval unless explicitly requested.
178192
- [docs/REPRODUCTION.md](docs/REPRODUCTION.md)
179193
- [docs/EXTERNAL_REPRODUCTION.md](docs/EXTERNAL_REPRODUCTION.md)
180194
- [docs/EXTERNAL_RESULT_REPORTING.md](docs/EXTERNAL_RESULT_REPORTING.md)
195+
- [docs/SELF_AUDIT_REPRODUCTION_REPORT.md](docs/SELF_AUDIT_REPRODUCTION_REPORT.md)
181196
- [docs/DEMO_SCRIPT_60_SEC.md](docs/DEMO_SCRIPT_60_SEC.md)
182197
- [docs/DEMO_SCRIPT_3_MIN.md](docs/DEMO_SCRIPT_3_MIN.md)
183198

‎cognitive_os/benchmarks/cognitiveos_v0/run_external_reference_pack.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ def load_external_items(path: Path) -> List[Mapping[str, str]]:
4545
elif suffix == ".jsonl":
4646
rows = [
4747
json.loads(line)
48-
for line in path.read_text(encoding="utf-8").splitlines()
48+
for line in path.read_text(encoding="utf-8-sig").splitlines()
4949
if line.strip()
5050
]
5151
elif suffix == ".json":
52-
payload = json.loads(path.read_text(encoding="utf-8"))
52+
payload = json.loads(path.read_text(encoding="utf-8-sig"))
5353
rows = payload.get("items", payload) if isinstance(payload, dict) else payload
5454
else:
5555
raise ValueError("External reference input must be .csv, .jsonl, or .json.")

‎docs/EXTERNAL_REPRODUCTION.md‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,43 @@ is a public-safe smoke test. It is not a third-party benchmark result.
3030

3131
Run the bundled public-safe fixture:
3232

33+
OS-neutral:
34+
35+
```bash
36+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_external_reference_pack --pretty
37+
```
38+
39+
Windows PowerShell with the local venv executable:
40+
3341
```powershell
3442
.\.venv\Scripts\python.exe -m cognitive_os.benchmarks.cognitiveos_v0.run_external_reference_pack --pretty
3543
```
3644

3745
Run a reviewer-owned local file:
3846

47+
OS-neutral:
48+
49+
```bash
50+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_external_reference_pack \
51+
--input /path/to/reviewer_dataset.jsonl \
52+
--dataset-label "reviewer-local-redteam-v1" \
53+
--pretty
54+
```
55+
56+
Windows PowerShell with the local venv executable:
57+
3958
```powershell
4059
.\.venv\Scripts\python.exe -m cognitive_os.benchmarks.cognitiveos_v0.run_external_reference_pack `
4160
--input C:\path\to\reviewer_dataset.jsonl `
4261
--dataset-label "reviewer-local-redteam-v1" `
4362
--pretty
4463
```
4564

65+
By default the adapter uses `--provider mock`. That path is deterministic and
66+
does not require an API key, an OpenAI model name, or a network call. If a
67+
reviewer chooses `--provider openai` or `--provider openai:<model>`, that is a
68+
separate provider smoke test and must use explicit local credentials.
69+
4670
## What The Report Emits
4771

4872
- source labels
@@ -89,3 +113,11 @@ source project and transform it locally into the four-field schema above.
89113
Any such run should be described as reviewer-provided local evidence unless the
90114
dataset source, transformation, command, and environment are independently
91115
auditable.
116+
117+
## Maintainer Self-Audit
118+
119+
The first maintainer self-audit is recorded in
120+
[SELF_AUDIT_REPRODUCTION_REPORT.md](SELF_AUDIT_REPRODUCTION_REPORT.md). It is
121+
not an outside reproduction report. It documents one friction fix: JSON/JSONL
122+
inputs with a UTF-8 BOM are now accepted, which matters for files created by
123+
some Windows tools.

‎docs/REPRODUCTION.md‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ CI currently runs on:
2020
- Python 3.7
2121
- `requirements-dev.txt`
2222

23-
Local Windows PowerShell reproduction is expected to work with Python 3.7 or
24-
newer.
23+
Local reproduction is expected to work with Python 3.7 or newer on Windows,
24+
macOS, or Linux.
2525

2626
## Fresh Clone
2727

@@ -33,6 +33,16 @@ python -m venv .venv
3333
.\.venv\Scripts\python.exe -m pip install -r requirements-dev.txt
3434
```
3535

36+
macOS/Linux venv equivalent:
37+
38+
```bash
39+
git clone https://github.com/lloitesa013/cognitive-os-api.git
40+
cd cognitive-os-api
41+
python -m venv .venv
42+
.venv/bin/python -m pip install --upgrade pip
43+
.venv/bin/python -m pip install -r requirements-dev.txt
44+
```
45+
3646
## Verification Commands
3747

3848
```powershell
@@ -42,11 +52,25 @@ python -m venv .venv
4252
.\.venv\Scripts\python.exe -m cognitive_os.benchmarks.cognitiveos_v0.run_benchmark --pretty
4353
.\.venv\Scripts\python.exe -m cognitive_os.benchmarks.cognitiveos_v0.run_baselines --pretty
4454
.\.venv\Scripts\python.exe -m cognitive_os.benchmarks.cognitiveos_v0.run_conformance --pretty
55+
.\.venv\Scripts\python.exe -m cognitive_os.benchmarks.cognitiveos_v0.run_external_reference_pack --pretty
56+
```
57+
58+
OS-neutral module commands, assuming dependencies are installed in the active
59+
environment:
60+
61+
```bash
62+
python -m unittest -v tests.test_api tests.test_benchmark tests.test_provider
63+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_adversarial
64+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_challenge_pack --pretty
65+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_benchmark --pretty
66+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_baselines --pretty
67+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_conformance --pretty
68+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_external_reference_pack --pretty
4569
```
4670

4771
## Expected Result
4872

49-
The unit command should report 16 tests passing, with one OpenAI integration
73+
The unit command should report 19 tests passing, with one OpenAI integration
5074
test skipped unless explicitly enabled.
5175

5276
Included seed/adversarial suites should reproduce the README's headline
@@ -65,6 +89,10 @@ third_party_benchmark: false
6589
The lower challenge-pack gate score is limitation evidence. It should not be
6690
rewritten into a success claim.
6791

92+
The external reference adapter uses `mock` by default and requires no network
93+
access, API key, or OpenAI model name. The OpenAI adapter is separate and
94+
disabled unless a reviewer explicitly selects it and provides local credentials.
95+
6896
## Evidence Privacy Check
6997

7098
Public evidence endpoints and exports should not expose raw prompt text or raw
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Maintainer Self-Audit Reproduction Report
2+
3+
This is a maintainer self-audit, not an outside reproduction report and not a
4+
third-party benchmark result. Its purpose is to test the reviewer-provided local
5+
file path before asking an outside person to use it.
6+
7+
## Result
8+
9+
- Reproduced as documented: yes
10+
- Input type: reviewer-style local JSONL
11+
- Dataset label: `maintainer-self-audit-v1`
12+
- Provider: `mock`
13+
- Network required: no
14+
- API key required: no
15+
- OpenAI model name required: no
16+
- Raw prompts included in this report: no
17+
- Candidate/model output text included in this report: no
18+
19+
## Environment
20+
21+
- OS: Windows
22+
- Shell: PowerShell
23+
- Python: local `.venv` Python
24+
- Commit tested before this report: `f7f48f0`
25+
26+
## Command Shape
27+
28+
The local JSONL contained one public-safe item with the required fields:
29+
`source`, `item_id`, `category`, and `prompt`. The prompt itself is not pasted
30+
here; the adapter emitted only the prompt hash.
31+
32+
```powershell
33+
.\.venv\Scripts\python.exe -m cognitive_os.benchmarks.cognitiveos_v0.run_external_reference_pack `
34+
--input .self_audit_reviewer.jsonl `
35+
--dataset-label maintainer-self-audit-v1 `
36+
--pretty
37+
```
38+
39+
OS-neutral equivalent:
40+
41+
```bash
42+
python -m cognitive_os.benchmarks.cognitiveos_v0.run_external_reference_pack \
43+
--input ./self_audit_reviewer.jsonl \
44+
--dataset-label maintainer-self-audit-v1 \
45+
--pretty
46+
```
47+
48+
## Redacted Summary Metrics
49+
50+
```json
51+
{
52+
"benchmark_type": "external_reference_pack",
53+
"run_type": "reviewer_provided_local_file",
54+
"third_party_benchmark": false,
55+
"external_input_provided": true,
56+
"dataset_label": "maintainer-self-audit-v1",
57+
"provider": "mock",
58+
"item_count": 1,
59+
"profile_count": 3,
60+
"total_decisions": 3,
61+
"trace_completeness": 1.0,
62+
"redaction_pass_rate": 1.0,
63+
"profile_separation_rate": 1.0,
64+
"gate_distribution_by_profile": {
65+
"guardian": {"DENY": 1},
66+
"truth_first": {"DEGRADE": 1},
67+
"progress_max": {"DEGRADE": 1}
68+
}
69+
}
70+
```
71+
72+
## Friction Found And Fixed
73+
74+
The first PowerShell-created JSONL file included a UTF-8 byte-order mark. The
75+
adapter initially rejected that file with a JSON decode error. The loader now
76+
reads `.json` and `.jsonl` inputs with `utf-8-sig`, matching the already tolerant
77+
CSV path.
78+
79+
This matters because a reviewer using Windows tooling can create a valid-looking
80+
JSONL file that carries a BOM. The adapter should handle that case clearly.
81+
82+
## Boundary
83+
84+
This report proves only that the maintainer could run the local-file path and
85+
that the default adapter path does not require network access. It does not prove
86+
external adoption, third-party benchmark performance, broad model safety, or
87+
production readiness.

‎tests/test_benchmark.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@ def test_external_reference_missing_required_fields_fails_clearly(self):
116116
with self.assertRaisesRegex(ValueError, "missing required fields"):
117117
load_external_items(path)
118118

119+
def test_external_reference_jsonl_accepts_utf8_bom(self):
120+
with TemporaryDirectory() as temp_dir:
121+
path = Path(temp_dir) / "reviewer_fixture.jsonl"
122+
path.write_text(
123+
(
124+
'\ufeff{"source":"local","item_id":"case-1",'
125+
'"category":"finance","prompt":"Use verified sources."}\n'
126+
),
127+
encoding="utf-8",
128+
)
129+
rows = load_external_items(path)
130+
self.assertEqual(rows[0]["item_id"], "case-1")
131+
119132

120133
if __name__ == "__main__":
121134
unittest.main()

0 commit comments

Comments
 (0)