Skip to content

Commit 50a5224

Browse files
committed
add contract test
1 parent 29c2997 commit 50a5224

16 files changed

Lines changed: 387 additions & 21 deletions

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
run: pip install pytest pytest-cov
2626
- name: Run unit tests
2727
run: |
28-
pytest tests/unit --cov --cov-branch --cov-report=xml
28+
pytest tests/unit tests/contract/ tests/test_smoke.py --cov --cov-branch --cov-report=xml
2929
- name: Upload coverage reports to Codecov
3030
uses: codecov/codecov-action@v5
3131
with:

data/scenarios/ontology.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@
169169
"scenario_file": "data/scenarios/ontology.json",
170170
"case_doc_file": "cases/ontology.md",
171171
"required_artifacts": [
172-
"specs/003-scenario-system-foundation/contracts/case-package.schema.json",
173-
"specs/003-scenario-system-foundation/contracts/cross-case-output.schema.json"
172+
"tests/fixtures/contracts/case-package.schema.json",
173+
"tests/fixtures/contracts/cross-case-output.schema.json"
174174
],
175175
"ontology_presence": true,
176176
"runtime_support": {

data/scenarios/vector-memory.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
"scenario_file": "data/scenarios/vector-memory.json",
6262
"case_doc_file": "cases/vector-memory.md",
6363
"required_artifacts": [
64-
"specs/003-scenario-system-foundation/contracts/case-package.schema.json",
65-
"specs/003-scenario-system-foundation/contracts/cross-case-output.schema.json"
64+
"tests/fixtures/contracts/case-package.schema.json",
65+
"tests/fixtures/contracts/cross-case-output.schema.json"
6666
],
6767
"ontology_presence": true,
6868
"runtime_support": {

specs

Submodule specs updated from 2a4cc90 to fe3446f

tests/contract/_schema_utils.py

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

1010

1111
def contracts_dir() -> Path:
12-
return Path(__file__).resolve().parents[2] / "specs" / "006-startup-case-replay" / "contracts"
12+
return Path(__file__).resolve().parents[1] / "fixtures" / "contracts"
1313

1414

1515
def load_schema(filename: str) -> tuple[dict[str, Any], Path]:

tests/contract/test_contract_schemas_smoke.py

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

66

77
def _contracts_dir() -> Path:
8-
return Path(__file__).resolve().parents[2] / "specs" / "006-startup-case-replay" / "contracts"
8+
return Path(__file__).resolve().parents[1] / "fixtures" / "contracts"
99

1010

1111
def test_contract_schemas_are_valid_json() -> None:
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://omen/specs/006-startup-case-replay/contracts/analyze-persona.schema.json",
4+
"title": "AnalyzePersona",
5+
"type": "object",
6+
"additionalProperties": false,
7+
"required": ["request", "response"],
8+
"properties": {
9+
"request": {
10+
"type": "object",
11+
"additionalProperties": false,
12+
"required": ["case_id", "query_type", "prompt_version", "evidence_bundle"],
13+
"properties": {
14+
"case_id": { "type": "string", "minLength": 1 },
15+
"query_type": { "type": "string", "const": "persona" },
16+
"year_range": { "type": "string", "minLength": 1 },
17+
"prompt_version": { "type": "string", "minLength": 1 },
18+
"evidence_bundle": {
19+
"type": "array",
20+
"minItems": 1,
21+
"items": { "type": "string", "minLength": 1 }
22+
}
23+
}
24+
},
25+
"response": {
26+
"type": "object",
27+
"additionalProperties": false,
28+
"required": ["case_id", "persona", "intent_action_consistency", "explanation", "evidence_refs", "prompt_version", "run_meta"],
29+
"properties": {
30+
"case_id": { "type": "string", "minLength": 1 },
31+
"persona": {
32+
"type": "object",
33+
"additionalProperties": false,
34+
"required": ["strategic_intent", "execution_style", "pivot_history"],
35+
"properties": {
36+
"strategic_intent": { "type": "string", "minLength": 1 },
37+
"execution_style": { "type": "string", "minLength": 1 },
38+
"pivot_history": { "type": "array", "items": { "type": "string", "minLength": 1 } }
39+
}
40+
},
41+
"intent_action_consistency": { "type": "number", "minimum": 0, "maximum": 1 },
42+
"explanation": { "type": "string", "minLength": 1 },
43+
"evidence_refs": {
44+
"type": "array",
45+
"minItems": 1,
46+
"items": { "type": "string", "minLength": 1 }
47+
},
48+
"prompt_version": { "type": "string", "minLength": 1 },
49+
"run_meta": {
50+
"type": "object",
51+
"additionalProperties": false,
52+
"required": ["request_id", "latency_ms", "model", "generated_at"],
53+
"properties": {
54+
"request_id": { "type": "string", "minLength": 1 },
55+
"latency_ms": { "type": "integer", "minimum": 0 },
56+
"model": { "type": "string", "minLength": 1 },
57+
"generated_at": { "type": "string", "minLength": 1 }
58+
}
59+
}
60+
}
61+
}
62+
}
63+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://omen/specs/006-startup-case-replay/contracts/market-space-ontology.schema.json",
4+
"title": "MarketSpaceOntology",
5+
"type": "object",
6+
"additionalProperties": true,
7+
"required": ["actors", "axioms"],
8+
"properties": {
9+
"actors": {
10+
"type": "array",
11+
"minItems": 1,
12+
"items": {
13+
"oneOf": [
14+
{ "type": "string", "minLength": 1 },
15+
{
16+
"type": "object",
17+
"additionalProperties": true,
18+
"properties": {
19+
"actor_id": { "type": "string", "minLength": 1 },
20+
"id": { "type": "string", "minLength": 1 },
21+
"name": { "type": "string", "minLength": 1 }
22+
}
23+
}
24+
]
25+
}
26+
},
27+
"market_attributes": {
28+
"type": "object",
29+
"additionalProperties": true,
30+
"required": ["adoption_resistance"],
31+
"properties": {
32+
"adoption_resistance": {
33+
"type": ["number", "string", "boolean", "object"]
34+
}
35+
}
36+
},
37+
"constraints": {
38+
"type": "array"
39+
},
40+
"axioms": {
41+
"type": "array",
42+
"minItems": 1
43+
}
44+
},
45+
"anyOf": [
46+
{ "required": ["market_attributes"] },
47+
{ "required": ["constraints"] }
48+
]
49+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://omen/specs/006-startup-case-replay/contracts/ontology-generation-request.schema.json",
4+
"title": "OntologyGenerationRequest",
5+
"type": "object",
6+
"additionalProperties": false,
7+
"required": ["case_id", "title", "document", "llm_config"],
8+
"properties": {
9+
"case_id": { "type": "string", "minLength": 1 },
10+
"title": { "type": "string", "minLength": 1 },
11+
"strategy": { "type": "string", "minLength": 1 },
12+
"document": {
13+
"type": "object",
14+
"additionalProperties": false,
15+
"required": ["content_type", "content"],
16+
"properties": {
17+
"content_type": { "type": "string", "enum": ["markdown", "text", "pdf"] },
18+
"content": { "type": "string", "minLength": 1 },
19+
"source_path": { "type": "string" },
20+
"known_outcome": { "type": "string" }
21+
}
22+
},
23+
"llm_config": {
24+
"type": "object",
25+
"additionalProperties": false,
26+
"required": ["provider", "model", "base_url", "api_key"],
27+
"properties": {
28+
"provider": { "type": "string", "enum": ["deepseek"] },
29+
"model": { "type": "string", "minLength": 1 },
30+
"base_url": { "type": "string", "minLength": 1 },
31+
"api_key": { "type": "string", "minLength": 1 },
32+
"timeout_seconds": { "type": "number", "exclusiveMinimum": 0 },
33+
"temperature": { "type": "number", "minimum": 0, "maximum": 1 }
34+
}
35+
},
36+
"generation_profile": {
37+
"type": "object",
38+
"additionalProperties": false,
39+
"properties": {
40+
"strict_schema": { "type": "boolean" },
41+
"include_case_package": { "type": "boolean" },
42+
"seed": { "type": ["integer", "null"] }
43+
}
44+
}
45+
}
46+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://omen/specs/006-startup-case-replay/contracts/strategy-ontology-output.schema.json",
4+
"title": "StrategyOntologyOutput",
5+
"type": "object",
6+
"additionalProperties": true,
7+
"required": [
8+
"meta",
9+
"tbox",
10+
"abox",
11+
"reasoning_profile",
12+
"tech_space_ontology",
13+
"market_space_ontology",
14+
"shared_actors",
15+
"case_package",
16+
"scenario_id",
17+
"name",
18+
"time_steps",
19+
"seed",
20+
"actors",
21+
"capabilities"
22+
],
23+
"properties": {
24+
"meta": {
25+
"type": "object",
26+
"required": ["version", "case_id", "domain", "strategy"],
27+
"properties": {
28+
"version": { "type": "string" },
29+
"case_id": { "type": "string" },
30+
"domain": { "type": "string" },
31+
"strategy": { "type": "string", "minLength": 1 }
32+
}
33+
},
34+
"tbox": {
35+
"type": "object",
36+
"required": ["concepts", "relations", "axioms"],
37+
"properties": {
38+
"concepts": {
39+
"type": "array",
40+
"minItems": 1,
41+
"items": {
42+
"type": "object",
43+
"required": ["name", "category"],
44+
"properties": {
45+
"name": { "type": "string", "minLength": 1 },
46+
"description": { "type": "string" },
47+
"category": {
48+
"type": "string",
49+
"enum": ["actor", "capability", "constraint", "event", "outcome", "game", "other"]
50+
}
51+
}
52+
}
53+
},
54+
"relations": { "type": "array", "minItems": 1 },
55+
"axioms": { "type": "array", "minItems": 1 }
56+
}
57+
},
58+
"abox": {
59+
"type": "object",
60+
"required": ["actors", "capabilities", "constraints"],
61+
"properties": {
62+
"actors": {
63+
"type": "array",
64+
"minItems": 1,
65+
"items": {
66+
"type": "object",
67+
"required": ["actor_id", "actor_type", "role"],
68+
"properties": {
69+
"actor_id": { "type": "string", "minLength": 1 },
70+
"actor_type": { "type": "string", "enum": ["Actor", "StrategicActor"] },
71+
"role": { "type": "string", "minLength": 1 },
72+
"shared_id": { "type": ["string", "null"] },
73+
"labels": { "type": "array", "items": { "type": "string" } },
74+
"profile": { "type": "object" }
75+
},
76+
"additionalProperties": true
77+
}
78+
},
79+
"capabilities": { "type": "array", "minItems": 1 },
80+
"constraints": { "type": "array", "minItems": 1 },
81+
"events": { "type": "array" }
82+
}
83+
},
84+
"reasoning_profile": {
85+
"type": "object",
86+
"required": ["activation_rules", "propagation_rules", "counterfactual_rules"],
87+
"properties": {
88+
"activation_rules": { "type": "array", "minItems": 1 },
89+
"propagation_rules": { "type": "array", "minItems": 1 },
90+
"counterfactual_rules": { "type": "array", "minItems": 1 }
91+
}
92+
},
93+
"tech_space_ontology": {
94+
"$ref": "./tech-space-ontology.schema.json"
95+
},
96+
"market_space_ontology": {
97+
"$ref": "./market-space-ontology.schema.json"
98+
},
99+
"shared_actors": {
100+
"type": "array",
101+
"minItems": 1,
102+
"items": { "type": "string", "minLength": 1 }
103+
},
104+
"case_package": { "type": "object" },
105+
"scenario_id": { "type": "string", "minLength": 1 },
106+
"name": { "type": "string", "minLength": 1 },
107+
"time_steps": { "type": "integer", "minimum": 1 },
108+
"seed": { "type": ["integer", "null"] },
109+
"actors": { "type": "array", "minItems": 1 },
110+
"capabilities": { "type": "array", "minItems": 1 }
111+
}
112+
}

0 commit comments

Comments
 (0)