solsticestudioai commited on
Commit
e13493c
·
verified ·
1 Parent(s): 35f4545

Include external schemas and adapters

Browse files
adapters/example-command/README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Example command adapter
2
+
3
+ The manifest uses an argument array. The runner invokes it without a shell,
4
+ passes one JSON request on stdin, and captures JSON stdout plus separate stderr.
adapters/example-command/adapter.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import json, sys
2
+ request = json.loads(sys.stdin.readline())
3
+ obs = request.get("observations", [])
4
+ print(json.dumps({"protocol_version":"mnemosyne-external-strategy/v1","run_id":request["run_id"],"strategy_id":"example_command","scenario_id":request["scenario_id"],"current_answer":obs[-1]["content"] if obs else None,"historical_answer":None,"abstained":not bool(obs),"confidence":0.25,"recalled_records":[],"selected_context":[],"lifecycle_actions":[],"promotion_actions":[],"evidence_families_counted":[],"active_memory_ids":[],"superseded_memory_ids":[],"warnings":["demonstration adapter"]},sort_keys=True))
adapters/example-command/manifest.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"protocol_version":"mnemosyne-external-strategy/v1","strategy_id":"example_command","display_name":"Example Command Adapter","strategy_version":"0.1.0","implementation_type":"command_subprocess","description":"Command-array demonstration using a local helper.","author":"community-example","source_url":"","license":"MIT","command":["python","adapter.py"],"capabilities":{"typed_records":false},"configuration_schema":{},"requires_network":false,"requires_credentials":false,"deterministic":true,"supported_platforms":["windows","linux","macos"],"timeout_seconds":10,"maximum_output_bytes":200000,"benchmark_version":"v0.2.0"}
adapters/example-python/README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Example Python adapter
2
+
3
+ This standard-library adapter demonstrates the `mnemosyne-external-strategy/v1`
4
+ JSON-lines protocol. It reads one label-free request from stdin and writes one
5
+ observable result to stdout. It is intentionally simple and is not an official
6
+ integration or a performance claim.
adapters/example-python/adapter.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import sys
3
+
4
+ PROTOCOL = "mnemosyne-external-strategy/v1"
5
+
6
+ def main():
7
+ request = json.loads(sys.stdin.readline())
8
+ if request.get("protocol_version") != PROTOCOL:
9
+ raise ValueError("unsupported protocol")
10
+ observations = request.get("observations", [])
11
+ current = observations[-1]["content"] if observations else None
12
+ result = {
13
+ "protocol_version": PROTOCOL,
14
+ "run_id": request["run_id"],
15
+ "strategy_id": "example_python",
16
+ "scenario_id": request["scenario_id"],
17
+ "current_answer": current,
18
+ "historical_answer": None,
19
+ "abstained": not bool(observations),
20
+ "confidence": 0.5 if observations else 0.0,
21
+ "recalled_records": [o["observation_id"] for o in observations[-4:]],
22
+ "selected_context": [o["content"] for o in observations[-4:]],
23
+ "lifecycle_actions": [],
24
+ "promotion_actions": [],
25
+ "evidence_families_counted": sorted({o["evidence_family_id"] for o in observations[-4:]}),
26
+ "active_memory_ids": [],
27
+ "superseded_memory_ids": [],
28
+ "explanation": "Selected the most recent bounded observations; no evaluator labels were used.",
29
+ "warnings": ["demonstration adapter; not a production memory strategy"],
30
+ }
31
+ sys.stdout.write(json.dumps(result, sort_keys=True) + "\n")
32
+
33
+ if __name__ == "__main__":
34
+ main()
adapters/example-python/manifest.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"protocol_version":"mnemosyne-external-strategy/v1","strategy_id":"example_python","display_name":"Example Python Adapter","strategy_version":"0.1.0","implementation_type":"python_subprocess","description":"A deterministic standard-library demonstration adapter.","author":"community-example","source_url":"","license":"MIT","command":["python","adapter.py"],"capabilities":{"typed_records":false,"lineage":false,"historical_recall":false},"configuration_schema":{},"requires_network":false,"requires_credentials":false,"deterministic":true,"supported_platforms":["windows","linux","macos"],"timeout_seconds":10,"maximum_output_bytes":200000,"benchmark_version":"v0.2.0","notes":"Example only; not an official memory-system integration."}
adapters/template/README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # External adapter template
2
+
3
+ Implement the TODO sections in `adapter.py`, update `manifest.json`, and run it
4
+ locally against the frozen v0.2.0 scenarios. Never include evaluator labels.
adapters/template/adapter.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Copyable adapter template. Replace TODO sections; keep stdout JSON-only."""
2
+ import json, sys
3
+
4
+ def main():
5
+ request = json.loads(sys.stdin.readline())
6
+ # TODO: ingest observations into your memory system.
7
+ # TODO: retrieve records for request["query"].
8
+ # TODO: resolve current and historical state.
9
+ # TODO: report provenance, lifecycle status, and evidence families.
10
+ result = {"protocol_version":"mnemosyne-external-strategy/v1","run_id":request["run_id"],"strategy_id":"replace_me","scenario_id":request["scenario_id"],"current_answer":None,"historical_answer":None,"abstained":True,"warnings":["template adapter: not implemented"]}
11
+ print(json.dumps(result, sort_keys=True))
12
+
13
+ if __name__ == "__main__": main()
adapters/template/manifest.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"protocol_version":"mnemosyne-external-strategy/v1","strategy_id":"replace_me","display_name":"Template Adapter","strategy_version":"0.1.0","implementation_type":"your_runtime","description":"Copy this template and implement your own local memory adapter.","author":"","source_url":"","license":"MIT","command":["python","adapter.py"],"capabilities":{},"configuration_schema":{},"requires_network":false,"requires_credentials":false,"deterministic":false,"supported_platforms":["windows","linux","macos"],"timeout_seconds":30,"maximum_output_bytes":200000,"benchmark_version":"v0.2.0","notes":"TODO: declare capabilities accurately."}
adapters/template/test_adapter.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ def test_template_files_exist():
2
+ from pathlib import Path
3
+ assert (Path(__file__).parent / "adapter.py").exists()
external-strategy-schemas/external-strategy-bundle-v1.schema.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"mnemosyne-external-strategy/bundle/v1","type":"object","required":["bundle_version","tooling_version","benchmark_version","fixture_hash","strategy_manifest","run_integrity","aggregate_metrics","scenario_level_outcomes","content_hash"],"properties":{"bundle_version":{"const":"mnemosyne-external-strategy-bundle/v1"},"tooling_version":{"const":"0.2.1"},"benchmark_version":{"const":"v0.2.0"},"fixture_hash":{"type":"string"},"strategy_manifest":{"type":"object"},"run_integrity":{"type":"object"},"aggregate_metrics":{"type":"object"},"scenario_level_outcomes":{"type":"array"},"execution_failures":{"type":["integer","array"]},"content_hash":{"type":"string"}},"additionalProperties":true}
external-strategy-schemas/external-strategy-input-v1.schema.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"mnemosyne-external-strategy/input/v1","type":"object","required":["protocol_version","run_id","benchmark_version","scenario_id","observations","query","query_time","configuration"],"properties":{"protocol_version":{"const":"mnemosyne-external-strategy/v1"},"run_id":{"type":"string"},"benchmark_version":{"const":"v0.2.0"},"scenario_id":{"type":"string"},"observations":{"type":"array"},"query":{"type":"string"},"query_time":{"type":"string"},"configuration":{"type":"object"},"execution_metadata":{"type":"object"}},"additionalProperties":false}
external-strategy-schemas/external-strategy-manifest-v1.schema.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"mnemosyne-external-strategy/manifest/v1","type":"object","required":["protocol_version","strategy_id","display_name","strategy_version","command","benchmark_version"],"properties":{"protocol_version":{"const":"mnemosyne-external-strategy/v1"},"strategy_id":{"type":"string","pattern":"^[a-z0-9._-]+$"},"display_name":{"type":"string","maxLength":200},"strategy_version":{"type":"string","maxLength":100},"implementation_type":{"type":"string"},"author":{"type":"string"},"source_url":{"type":"string"},"license":{"type":"string"},"command":{"type":"array","minItems":1,"items":{"type":"string","minLength":1}},"capabilities":{"type":"object"},"configuration_schema":{"type":"object"},"requires_network":{"type":"boolean"},"requires_credentials":{"type":"boolean"},"deterministic":{"type":"boolean"},"supported_platforms":{"type":"array","items":{"type":"string"}},"timeout_seconds":{"type":"number","exclusiveMinimum":0},"maximum_output_bytes":{"type":"integer","exclusiveMinimum":0},"benchmark_version":{"const":"v0.2.0"},"notes":{"type":"string"}},"additionalProperties":true}
external-strategy-schemas/external-strategy-output-v1.schema.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"mnemosyne-external-strategy/output/v1","type":"object","required":["protocol_version","run_id","strategy_id","scenario_id"],"properties":{"protocol_version":{"const":"mnemosyne-external-strategy/v1"},"run_id":{"type":"string"},"strategy_id":{"type":"string"},"scenario_id":{"type":"string"},"answer":{"type":"string"},"current_answer":{"type":["string","null"]},"historical_answer":{"type":["string","null"]},"abstained":{"type":"boolean"},"confidence":{"type":"number"},"recalled_records":{"type":"array"},"selected_context":{"type":"array"},"lifecycle_actions":{"type":"array"},"promotion_actions":{"type":"array"},"evidence_families_counted":{"type":"array"},"active_memory_ids":{"type":"array"},"superseded_memory_ids":{"type":"array"},"explanation":{"type":"string"},"warnings":{"type":"array"},"execution_metadata":{"type":"object"}},"additionalProperties":true}
external-strategy-schemas/external-strategy-run-v1.schema.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"mnemosyne-external-strategy/run/v1","type":"object","required":["protocol_version","benchmark_version","strategy_id","scenario_count","completed","failures","fixture_hash"],"properties":{"protocol_version":{"const":"mnemosyne-external-strategy/v1"},"benchmark_version":{"const":"v0.2.0"},"strategy_id":{"type":"string"},"scenario_count":{"type":"integer"},"completed":{"type":"integer"},"failures":{"type":"integer"},"fixture_hash":{"type":"string","pattern":"^[a-f0-9]{64}$"},"runs":{"type":"array"},"execution_failures":{"type":"array"}},"additionalProperties":true}
external-strategy-schemas/manual-external-result-v1.schema.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"mnemosyne-external-strategy/manual-result/v1","type":"object","required":["format_version","strategy","results"],"properties":{"format_version":{"const":"mnemosyne-manual-result/v1"},"strategy":{"type":"object"},"results":{"type":"array","items":{"type":"object","required":["scenario_id"],"properties":{"scenario_id":{"type":"string"},"current_answer":{"type":"string"},"historical_answer":{"type":["string","null"]},"abstained":{"type":"boolean"},"selected_record_ids":{"type":"array"},"evidence_family_ids":{"type":"array"},"notes":{"type":"string"}},"additionalProperties":true}}},"additionalProperties":false}