cks-core 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. cks_core-1.1.1/LICENSE +21 -0
  2. cks_core-1.1.1/PKG-INFO +384 -0
  3. cks_core-1.1.1/README.md +361 -0
  4. cks_core-1.1.1/pyproject.toml +44 -0
  5. cks_core-1.1.1/setup.cfg +4 -0
  6. cks_core-1.1.1/src/cks/__init__.py +124 -0
  7. cks_core-1.1.1/src/cks/adapters/cks_to_jsonld.py +62 -0
  8. cks_core-1.1.1/src/cks/adapters/cks_to_rdf.py +69 -0
  9. cks_core-1.1.1/src/cks/adapters/jsonld_to_cks.py +121 -0
  10. cks_core-1.1.1/src/cks/adapters/rdf_to_cks.py +88 -0
  11. cks_core-1.1.1/src/cks/cli/__init__.py +75 -0
  12. cks_core-1.1.1/src/cks/cli/commands/__init__.py +0 -0
  13. cks_core-1.1.1/src/cks/cli/commands/convert.py +54 -0
  14. cks_core-1.1.1/src/cks/cli/commands/evolve.py +97 -0
  15. cks_core-1.1.1/src/cks/cli/commands/export.py +60 -0
  16. cks_core-1.1.1/src/cks/cli/commands/inspect.py +58 -0
  17. cks_core-1.1.1/src/cks/cli/commands/parse.py +29 -0
  18. cks_core-1.1.1/src/cks/cli/commands/plugin.py +22 -0
  19. cks_core-1.1.1/src/cks/cli/commands/schema.py +36 -0
  20. cks_core-1.1.1/src/cks/cli/commands/validate.py +81 -0
  21. cks_core-1.1.1/src/cks/cli/formatters.py +108 -0
  22. cks_core-1.1.1/src/cks/constraints/__init__.py +10 -0
  23. cks_core-1.1.1/src/cks/constraints/base.py +33 -0
  24. cks_core-1.1.1/src/cks/constraints/builtin.py +30 -0
  25. cks_core-1.1.1/src/cks/constraints/registry.py +155 -0
  26. cks_core-1.1.1/src/cks/constraints/semantic.py +141 -0
  27. cks_core-1.1.1/src/cks/constraints/structural.py +146 -0
  28. cks_core-1.1.1/src/cks/core.py +400 -0
  29. cks_core-1.1.1/src/cks/diagnostics.py +414 -0
  30. cks_core-1.1.1/src/cks/engine.py +251 -0
  31. cks_core-1.1.1/src/cks/evolution.py +222 -0
  32. cks_core-1.1.1/src/cks/interface.py +200 -0
  33. cks_core-1.1.1/src/cks/plugin.py +114 -0
  34. cks_core-1.1.1/src/cks/result.py +243 -0
  35. cks_core-1.1.1/src/cks/schema.py +50 -0
  36. cks_core-1.1.1/src/cks/serialization.py +507 -0
  37. cks_core-1.1.1/src/cks/validation.py +47 -0
  38. cks_core-1.1.1/src/cks/validator.py +170 -0
  39. cks_core-1.1.1/src/cks_core.egg-info/PKG-INFO +384 -0
  40. cks_core-1.1.1/src/cks_core.egg-info/SOURCES.txt +53 -0
  41. cks_core-1.1.1/src/cks_core.egg-info/dependency_links.txt +1 -0
  42. cks_core-1.1.1/src/cks_core.egg-info/entry_points.txt +2 -0
  43. cks_core-1.1.1/src/cks_core.egg-info/requires.txt +5 -0
  44. cks_core-1.1.1/src/cks_core.egg-info/top_level.txt +1 -0
  45. cks_core-1.1.1/tests/test_adapters.py +87 -0
  46. cks_core-1.1.1/tests/test_cli.py +152 -0
  47. cks_core-1.1.1/tests/test_core.py +302 -0
  48. cks_core-1.1.1/tests/test_diagnostics.py +81 -0
  49. cks_core-1.1.1/tests/test_engine.py +278 -0
  50. cks_core-1.1.1/tests/test_evolution.py +173 -0
  51. cks_core-1.1.1/tests/test_interface.py +247 -0
  52. cks_core-1.1.1/tests/test_plugin.py +109 -0
  53. cks_core-1.1.1/tests/test_result.py +116 -0
  54. cks_core-1.1.1/tests/test_serialization.py +302 -0
  55. cks_core-1.1.1/tests/test_validator.py +222 -0
cks_core-1.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vladyslav Hruznov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,384 @@
1
+ Metadata-Version: 2.4
2
+ Name: cks-core
3
+ Version: 1.1.1
4
+ Summary: Canonical Knowledge Structure — Reference Implementation
5
+ Author: Vladyslav Hruznov
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Deus-corp/CKS
8
+ Project-URL: Documentation, https://github.com/Deus-corp/CKS
9
+ Keywords: canonical-knowledge-structure,knowledge-representation,validation,semantics
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Requires-Python: >=3.12
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: jsonschema>=4.0
19
+ Requires-Dist: rdflib>=7.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: mypy>=1.0; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ # Canonical Knowledge Structure (CKS)
25
+
26
+ > A universal, representation-independent foundation for knowledge.
27
+
28
+ ![Python](https://img.shields.io/badge/python-3.11%2B-blue)
29
+ ![License](https://img.shields.io/badge/license-MIT-green)
30
+ ![Tests](https://img.shields.io/badge/tests-119%20passing-brightgreen)
31
+ [![PyPI](https://img.shields.io/pypi/v/cks-core)](https://pypi.org/project/cks-core/)
32
+
33
+ CKS is an open specification that defines how knowledge can be represented,
34
+ validated, exchanged, and evolved independently of programming languages,
35
+ document formats, databases, or AI systems.
36
+
37
+ Rather than introducing yet another serialization format or programming
38
+ language, CKS defines a **canonical semantic layer** shared by humans,
39
+ software, and artificial intelligence.
40
+
41
+ ---
42
+
43
+ # Why CKS?
44
+
45
+ Today the same knowledge exists simultaneously in many incompatible forms:
46
+
47
+ - documents
48
+ - databases
49
+ - JSON
50
+ - XML
51
+ - source code
52
+ - knowledge graphs
53
+ - ontologies
54
+ - AI prompts
55
+ - APIs
56
+
57
+ Each representation describes the same underlying knowledge differently.
58
+
59
+ CKS separates **knowledge itself** from every concrete representation.
60
+
61
+ ```
62
+ Knowledge
63
+
64
+
65
+ Canonical Knowledge Structure (CKS)
66
+
67
+ ┌────┼───────────────┐
68
+ ▼ ▼ ▼
69
+ JSON Python Database Natural Language
70
+ ```
71
+
72
+ Representations may change.
73
+
74
+ Canonical knowledge remains the same.
75
+
76
+ ---
77
+
78
+ # Core Principles
79
+
80
+ CKS is founded on four simple principles.
81
+
82
+ ### Knowledge exists independently of its representation.
83
+
84
+ Knowledge is not JSON.
85
+
86
+ Knowledge is not a PDF.
87
+
88
+ Knowledge is not source code.
89
+
90
+ Representations are temporary.
91
+
92
+ Knowledge is not.
93
+
94
+ ---
95
+
96
+ ### Structure preserves meaning.
97
+
98
+ Meaning is preserved by canonical structure rather than by syntax.
99
+
100
+ ---
101
+
102
+ ### Representation preserves structure.
103
+
104
+ Different representations may express the same canonical structure.
105
+
106
+ ---
107
+
108
+ ### Canonical operations belong to knowledge itself.
109
+
110
+ Validation.
111
+
112
+ Serialization.
113
+
114
+ Comparison.
115
+
116
+ Evolution.
117
+
118
+ Inspection.
119
+
120
+ These are operations on knowledge—not on files, databases, or programming
121
+ languages.
122
+
123
+ ---
124
+
125
+ # Architecture
126
+
127
+ The CKS ecosystem consists of implementation-independent specifications.
128
+
129
+ | Specification | Purpose |
130
+ |--------------|---------|
131
+ | CKS-000 | Foundations and terminology |
132
+ | CKS-001 | Canonical semantic model |
133
+ | CKS-002 | Knowledge construction |
134
+ | CKS-003 | Canonical serialization |
135
+ | CKS-004 | Structure evolution |
136
+ | CKS-005 | Validation |
137
+ | CKS-006 | Reference Engine |
138
+ | CKS-007 | Canonical Knowledge Interface |
139
+ | CKS-008 | Conformance |
140
+ | CKS-009 | Reference Knowledge Corpus |
141
+ | CKS-B001 | Python Reference Implementation |
142
+
143
+ ---
144
+
145
+ # Features
146
+
147
+ The current Python reference implementation provides:
148
+
149
+ - Immutable Canonical Knowledge Objects
150
+ - Canonical Relations
151
+ - Immutable Knowledge Structures
152
+ - Canonical JSON Serialization
153
+ - Deterministic Validation Pipeline
154
+ - Diagnostic System
155
+ - Reference Engine
156
+ - Canonical Public API
157
+ - Structural Comparison
158
+ - Projection
159
+ - Extraction
160
+ - Inspection
161
+ - Conformance Test Suite
162
+ - Command-Line Interface (validate, parse, inspect, evolve, schema, plugin)
163
+ - Structural Evolution (Genesis/Decay operators)
164
+ - Configurable Severity Thresholds
165
+ - HTML and Markdown Report Formatters
166
+ - Batch Validation (multiple files)
167
+ - JSON‑LD, Turtle, RDF/XML Import (via `cks convert`)
168
+ - JSON‑LD, Turtle, RDF/XML Export (via `cks export`)
169
+ - Strict Plugin Validation (`--strict`)
170
+ - Static Type Checking (mypy)
171
+
172
+ ---
173
+
174
+ # Design Goals
175
+
176
+ CKS is designed to be:
177
+
178
+ - deterministic
179
+ - immutable
180
+ - observationally pure
181
+ - representation-independent
182
+ - implementation-independent
183
+ - language-independent
184
+ - suitable for formal verification
185
+
186
+ ---
187
+
188
+ # Current Repository
189
+
190
+ This repository contains the official Python Reference Implementation of
191
+ the Canonical Knowledge Structure specifications.
192
+
193
+ Currently implemented:
194
+
195
+ - ✅ Canonical Knowledge Objects
196
+ - ✅ Canonical Relations
197
+ - ✅ Canonical Knowledge Structures
198
+ - ✅ Canonical Serialization
199
+ - ✅ Validation Pipeline
200
+ - ✅ Diagnostic System
201
+ - ✅ Reference Engine
202
+ - ✅ Canonical Public Interface
203
+ - ✅ Command-Line Interface
204
+ - ✅ Structural Evolution (CKS‑004)
205
+ - ✅ Reference Knowledge Corpus
206
+ - ✅ Conformance Test Suite (114 tests)
207
+ - ✅ PyPI Publication
208
+ - ✅ Import/Export Adapters (JSON‑LD, Turtle, RDF/XML)
209
+ - ✅ Modular CLI (commands refactored into separate handlers)
210
+ - ✅ Contract Documentation (`docs/contracts.md`)
211
+ - ✅ Static Type Checking (mypy)
212
+
213
+ Planned:
214
+
215
+ - Constraint Libraries (additional built‑in constraints)
216
+ - Additional language implementations (Rust, TypeScript)
217
+
218
+ ---
219
+
220
+ # Installation
221
+
222
+ From PyPI:
223
+
224
+ ```bash
225
+ pip install cks-core
226
+ ```
227
+
228
+ Or from source:
229
+
230
+ ```bash
231
+ git clone https://github.com/Deus-corp/CKS.git
232
+ cd CKS
233
+ pip install -e .
234
+ ```
235
+
236
+ ---
237
+
238
+ # Quick Example
239
+
240
+ ```python
241
+ from cks import (
242
+ construct,
243
+ validate,
244
+ serialize,
245
+ )
246
+
247
+ from cks.core import (
248
+ KnowledgeObject,
249
+ ObjectIdentity,
250
+ )
251
+
252
+ obj = KnowledgeObject(
253
+ identity=ObjectIdentity(
254
+ id="obj-1",
255
+ type="Definition",
256
+ name="Knowledge",
257
+ )
258
+ )
259
+
260
+ structure = construct([obj])
261
+
262
+ result = validate(structure)
263
+
264
+ print(result.is_valid)
265
+
266
+ print(serialize(structure))
267
+ ```
268
+
269
+ Or use the command line:
270
+
271
+ ```bash
272
+ # Validate a knowledge structure
273
+ cks validate examples/corpus/valid_theory_example.json
274
+
275
+ # Evolve a structure by adding an object
276
+ cks evolve examples/corpus/valid_theory_example.json examples/corpus/evolve_add.json
277
+ ```
278
+
279
+ Or convert between formats:
280
+
281
+ ```bash
282
+ # Convert JSON‑LD to CKS
283
+ cks convert examples/corpus/person.jsonld --format json-ld --output person.cks.json
284
+
285
+ # Export CKS to Turtle
286
+ cks export examples/corpus/valid_theory_example.json --format turtle --output theory.ttl
287
+ ```
288
+
289
+ ---
290
+
291
+ # Testing
292
+
293
+ Run the complete conformance suite:
294
+
295
+ ```bash
296
+ python -m pytest -v
297
+ ```
298
+
299
+ Current status:
300
+
301
+ - 114 tests
302
+ - all passing
303
+
304
+ The test suite verifies:
305
+
306
+ - deterministic behaviour
307
+ - immutability
308
+ - observational purity
309
+ - canonical serialization
310
+ - validation correctness
311
+ - public API conformance
312
+ - structural equivalence
313
+
314
+ ---
315
+
316
+ # Documentation
317
+
318
+ The complete specification is published separately.
319
+
320
+ Core specifications:
321
+
322
+ - CKS-000 — Foundations
323
+ - CKS-001 — Core Specification
324
+ - CKS-002 — Construction
325
+ - CKS-003 — Serialization
326
+ - CKS-004 — Evolution
327
+ - CKS-005 — Validator
328
+ - CKS-006 — Reference Engine
329
+ - CKS-007 — Canonical Knowledge Interface
330
+ - CKS-008 — Conformance
331
+
332
+ DOI:
333
+
334
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.21332624.svg)](https://doi.org/10.5281/zenodo.21332624)
335
+
336
+ ---
337
+
338
+ # Project Status
339
+
340
+ Current implementation status:
341
+
342
+ | Component | Status |
343
+ |----------|--------|
344
+ | Core Model | ✅ Complete |
345
+ | Serialization | ✅ Complete |
346
+ | Validation | ✅ Complete |
347
+ | Reference Engine | ✅ Complete |
348
+ | Public API | ✅ Complete |
349
+ | Test Suite | ✅ Passing |
350
+ | CLI | ✅ Complete |
351
+ | Structural Evolution | ✅ Complete |
352
+ | Advanced Validation | ✅ Complete |
353
+ | Import/Export Adapters | ✅ Complete |
354
+ | Modular CLI | ✅ Complete |
355
+ | Contract Documentation | ✅ Complete |
356
+ | Static Type Checking | ✅ Complete |
357
+
358
+ The current implementation serves as the reference implementation of the
359
+ existing CKS specifications.
360
+
361
+ Future work focuses primarily on expanding the specification rather than
362
+ redesigning the implemented components.
363
+
364
+ ---
365
+
366
+ # Vision
367
+
368
+ CKS aims to establish a universal semantic foundation for knowledge
369
+ exchange between:
370
+
371
+ - humans
372
+ - software
373
+ - databases
374
+ - distributed systems
375
+ - artificial intelligence
376
+
377
+ through a single canonical representation of knowledge that is independent
378
+ of every concrete implementation.
379
+
380
+ ---
381
+
382
+ # License
383
+
384
+ MIT