Summary
The KE client (src/knowledge_mapper/ke/client.py) implements most of the Knowledge Engine REST API, but three operations from the OpenAPI spec are missing. Additionally, the KnowledgeBaseInfo model is missing fields that the spec defines.
Current state
Implemented:
GET /sc — get one or all Knowledge Bases ✅
POST /sc — register a Knowledge Base ✅
DELETE /sc — unregister a Knowledge Base ✅
GET /sc/ki — get all Knowledge Interactions ✅
POST /sc/ki — register a Knowledge Interaction ✅
GET /sc/handle — poll for incoming KI calls ✅
POST /sc/handle — respond to a KI call ✅
POST /sc/ask — execute an ASK interaction ✅
POST /sc/post — execute a POST interaction ✅
GET /version — get KE runtime version ✅
Missing:
DELETE /sc/ki — unregister a single Knowledge Interaction
PUT /sc/lease/renew — renew a Smart Connector lease
POST /sc/knowledge — load domain knowledge (Jena rules/facts) into a Smart Connector
Scope
1. Update Pydantic models (ke/models.py)
Add missing optional fields to KnowledgeBaseInfo:
leaseRenewalTime: int | None (min 30, max 3600) — enables automatic SC cleanup
reasonerLevel: int | None (1-5) — controls reasoning level for the SC
Add a SmartConnectorLease model for the lease renewal response.
2. Implement missing client methods
unregister_ki(kb_id, ki_id) — DELETE /sc/ki
- Headers:
Knowledge-Base-Id, Knowledge-Interaction-Id
- 200: success
- 400/404: error
renew_lease(kb_id) — PUT /sc/lease/renew
- Header:
Knowledge-Base-Id
- 200: returns
SmartConnectorLease
- 400/404: error
load_domain_knowledge(kb_id, knowledge: str) — POST /sc/knowledge
- Header:
Knowledge-Base-Id
- Body: plain text (Jena rules syntax)
- Content-Type:
text/plain; charset=UTF-8
- 200: success
- 400/404: error
3. Update all three layers
ClientProtocol: add method signatures with docstrings
Client: implement the HTTP calls
TestClient (ke/testing/fake_client.py): add fake/in-memory implementations
4. Integrate into KnowledgeBase
Wire the new client methods into the high-level KnowledgeBase class:
kb.renew_lease() — renew the SC lease
kb.load_domain_knowledge(knowledge: str) — load domain knowledge
kb.unregister_ki(ki_name: str) — unregister a specific KI by name (resolves to KI ID internally)
5. Tests
Add tests for the three new operations in tests/test_client.py (or a new test file), using the existing TestClient infrastructure.
Acceptance Criteria
Summary
The KE client (
src/knowledge_mapper/ke/client.py) implements most of the Knowledge Engine REST API, but three operations from the OpenAPI spec are missing. Additionally, theKnowledgeBaseInfomodel is missing fields that the spec defines.Current state
Implemented:
GET /sc— get one or all Knowledge Bases ✅POST /sc— register a Knowledge Base ✅DELETE /sc— unregister a Knowledge Base ✅GET /sc/ki— get all Knowledge Interactions ✅POST /sc/ki— register a Knowledge Interaction ✅GET /sc/handle— poll for incoming KI calls ✅POST /sc/handle— respond to a KI call ✅POST /sc/ask— execute an ASK interaction ✅POST /sc/post— execute a POST interaction ✅GET /version— get KE runtime version ✅Missing:
DELETE /sc/ki— unregister a single Knowledge InteractionPUT /sc/lease/renew— renew a Smart Connector leasePOST /sc/knowledge— load domain knowledge (Jena rules/facts) into a Smart ConnectorScope
1. Update Pydantic models (
ke/models.py)Add missing optional fields to
KnowledgeBaseInfo:leaseRenewalTime: int | None(min 30, max 3600) — enables automatic SC cleanupreasonerLevel: int | None(1-5) — controls reasoning level for the SCAdd a
SmartConnectorLeasemodel for the lease renewal response.2. Implement missing client methods
unregister_ki(kb_id, ki_id)—DELETE /sc/kiKnowledge-Base-Id,Knowledge-Interaction-Idrenew_lease(kb_id)—PUT /sc/lease/renewKnowledge-Base-IdSmartConnectorLeaseload_domain_knowledge(kb_id, knowledge: str)—POST /sc/knowledgeKnowledge-Base-Idtext/plain; charset=UTF-83. Update all three layers
ClientProtocol: add method signatures with docstringsClient: implement the HTTP callsTestClient(ke/testing/fake_client.py): add fake/in-memory implementations4. Integrate into
KnowledgeBaseWire the new client methods into the high-level
KnowledgeBaseclass:kb.renew_lease()— renew the SC leasekb.load_domain_knowledge(knowledge: str)— load domain knowledgekb.unregister_ki(ki_name: str)— unregister a specific KI by name (resolves to KI ID internally)5. Tests
Add tests for the three new operations in
tests/test_client.py(or a new test file), using the existingTestClientinfrastructure.Acceptance Criteria
unregister_kiis implemented inClientProtocol,Client, andTestClientrenew_leaseis implemented inClientProtocol,Client, andTestClientload_domain_knowledgeis implemented inClientProtocol,Client, andTestClientKnowledgeBaseInfomodel includesleaseRenewalTimeandreasonerLevelfieldsKnowledgeBaseexposesrenew_lease(),load_domain_knowledge(), andunregister_ki()ruff check)