misbar 1.0.0__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 (46) hide show
  1. misbar-1.0.0/.github/workflows/ci.yml +34 -0
  2. misbar-1.0.0/.github/workflows/mirror-codeberg.yml +27 -0
  3. misbar-1.0.0/.github/workflows/publish.yml +32 -0
  4. misbar-1.0.0/.gitignore +22 -0
  5. misbar-1.0.0/CITATION.cff +20 -0
  6. misbar-1.0.0/LICENSE +176 -0
  7. misbar-1.0.0/NOTICE +6 -0
  8. misbar-1.0.0/PKG-INFO +71 -0
  9. misbar-1.0.0/README.md +41 -0
  10. misbar-1.0.0/pyproject.toml +58 -0
  11. misbar-1.0.0/skill/SKILL.md +81 -0
  12. misbar-1.0.0/skill/recipes/micro_ui/README.md +14 -0
  13. misbar-1.0.0/skill/recipes/micro_ui/review_app.py +59 -0
  14. misbar-1.0.0/skill/recipes/micro_ui/ui/custom_app.js +355 -0
  15. misbar-1.0.0/skill/recipes/micro_ui/ui/index.html +14 -0
  16. misbar-1.0.0/skill/recipes/react_workspace/README.md +12 -0
  17. misbar-1.0.0/skill/recipes/react_workspace/index.html +14 -0
  18. misbar-1.0.0/skill/recipes/react_workspace/package.json +22 -0
  19. misbar-1.0.0/skill/recipes/react_workspace/src/App.tsx +71 -0
  20. misbar-1.0.0/skill/recipes/react_workspace/src/Lex.tsx +58 -0
  21. misbar-1.0.0/skill/recipes/react_workspace/src/hooks.ts +67 -0
  22. misbar-1.0.0/skill/recipes/react_workspace/src/main.tsx +10 -0
  23. misbar-1.0.0/skill/recipes/react_workspace/tsconfig.json +16 -0
  24. misbar-1.0.0/skill/recipes/react_workspace/vite.config.ts +14 -0
  25. misbar-1.0.0/skill/recipes/remote_capture_demo/README.md +19 -0
  26. misbar-1.0.0/skill/recipes/remote_capture_demo/remote_worker_example.py +35 -0
  27. misbar-1.0.0/skill/references/data-model-and-reruns.md +85 -0
  28. misbar-1.0.0/skill/references/rtl-and-blind-ui.md +50 -0
  29. misbar-1.0.0/skill/references/tracing-adapters.md +82 -0
  30. misbar-1.0.0/src/misbar/__init__.py +38 -0
  31. misbar-1.0.0/src/misbar/api.py +629 -0
  32. misbar-1.0.0/src/misbar/capture.py +273 -0
  33. misbar-1.0.0/src/misbar/cli.py +105 -0
  34. misbar-1.0.0/src/misbar/db.py +879 -0
  35. misbar-1.0.0/src/misbar/lineage.py +131 -0
  36. misbar-1.0.0/src/misbar/runner.py +476 -0
  37. misbar-1.0.0/src/misbar/schema.sql +146 -0
  38. misbar-1.0.0/src/misbar/tracing.py +451 -0
  39. misbar-1.0.0/src/misbar/ui_assets/app.js +349 -0
  40. misbar-1.0.0/src/misbar/ui_assets/index.html +14 -0
  41. misbar-1.0.0/src/misbar/ui_assets/primitives.js +185 -0
  42. misbar-1.0.0/src/misbar/ui_assets/rtl.css +357 -0
  43. misbar-1.0.0/tests/test_blind_api_and_exports.py +228 -0
  44. misbar-1.0.0/tests/test_revisions_and_rerun.py +183 -0
  45. misbar-1.0.0/tests/test_store_and_lineage.py +141 -0
  46. misbar-1.0.0/tests/test_tracing_and_ingest.py +175 -0
@@ -0,0 +1,34 @@
1
+ name: CI (misbar)
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ pull_request:
7
+ branches: ["main"]
8
+
9
+ env:
10
+ TARKIB_OPENITI_ONLY: "1"
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v5
21
+
22
+ - name: Set up Python 3.12
23
+ run: uv python install 3.12
24
+
25
+ - name: Install package and test dependencies
26
+ run: |
27
+ uv venv --python 3.12 .ci-venv
28
+ uv pip install --python .ci-venv/bin/python -e . pytest httpx
29
+
30
+ - name: Run pytest suite
31
+ run: .ci-venv/bin/pytest -q
32
+
33
+ - name: Build wheel and sdist
34
+ run: uv build
@@ -0,0 +1,27 @@
1
+ name: Sovereign Mirror to Codeberg (misbar)
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ tags: ["v*"]
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ mirror:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout full git history
14
+ uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+
18
+ - name: Push mirror to Codeberg (maqayis/misbar)
19
+ env:
20
+ CODEBERG_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
21
+ run: |
22
+ if [ -z "$CODEBERG_TOKEN" ]; then
23
+ echo "CODEBERG_TOKEN secret is not set; skipping mirror push."
24
+ exit 0
25
+ fi
26
+ git remote add codeberg "https://maqayis:${CODEBERG_TOKEN}@codeberg.org/maqayis/misbar.git" || true
27
+ git push --mirror codeberg
@@ -0,0 +1,32 @@
1
+ name: Publish to PyPI (misbar)
2
+
3
+ on:
4
+ release:
5
+ types: ["published"]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ id-token: write
11
+
12
+ env:
13
+ TARKIB_OPENITI_ONLY: "1"
14
+
15
+ jobs:
16
+ publish:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - name: Checkout repository
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Install uv
23
+ uses: astral-sh/setup-uv@v5
24
+
25
+ - name: Set up Python 3.12
26
+ run: uv python install 3.12
27
+
28
+ - name: Build wheel and sdist
29
+ run: uv build
30
+
31
+ - name: Publish package distributions to PyPI via OIDC Trusted Publisher
32
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,22 @@
1
+ # Byte-compiled / caches
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ .mypy_cache/
8
+
9
+ # Virtual environments & build staging (note: `dist/` wheels/sdists are tracked for release)
10
+ .venv/
11
+ venv/
12
+ build/
13
+ *.egg-info/
14
+
15
+ # Ephemeral runtime caches
16
+ *sdk_zero_llm_v2*
17
+ *diachronic_zero_llm_v1*
18
+
19
+ # Local environment files
20
+ .env
21
+ .env.*
22
+ !.env.example
@@ -0,0 +1,20 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use misbar in your research or software, please cite it using the metadata below."
3
+ title: "Misbar: Foundational Workflow Spine, Trace Adapters, and Blind/RTL Review Toolkit"
4
+ version: "1.0.0"
5
+ date-released: "2026-11-07"
6
+ license: "Apache-2.0"
7
+ url: "https://maqayis.org"
8
+ repository-code: "https://github.com/maqayis/misbar"
9
+ authors:
10
+ - family-names: "Abdo"
11
+ given-names: "Salah"
12
+ email: "Salah.Abdo.Tech@gmail.com"
13
+ abstract: >-
14
+ SQLite-backed workflow lineage store, zero-dependency JSONL trace capture, and blind RTL/LTR human calibration & rerun queues for research and engineering pipelines.
15
+ keywords:
16
+ - "Arabic computational linguistics"
17
+ - "computational philology"
18
+ - "Zero-LLM"
19
+ - "Maqayis"
20
+ - "misbar"
misbar-1.0.0/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the Work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
misbar-1.0.0/NOTICE ADDED
@@ -0,0 +1,6 @@
1
+ Misbār (مِسبار) v1.0.0 — Maqāyīs (مَقاييس) Open-Source Ecosystem
2
+ Copyright 2026 Salah Abdo and successor entity
3
+
4
+ Software & Source Code License:
5
+ Licensed under the Apache License, Version 2.0 (Apache-2.0).
6
+ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
misbar-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.5
2
+ Name: misbar
3
+ Version: 1.0.0
4
+ Summary: Misbar (مسبار): Foundational workflow spine, trace adapters, and blind/RTL human review queues (Maqayis)
5
+ Project-URL: Homepage, https://maqayis.org
6
+ Project-URL: Repository, https://github.com/maqayis/misbar
7
+ Project-URL: Mirror, https://codeberg.org/maqayis/misbar
8
+ Author-email: Salah Abdo <Salah.Abdo.Tech@gmail.com>
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: arabic,evaluation,human-in-the-loop,maqayis,misbar,observability,rtl,tracing
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: fastapi>=0.115.0
23
+ Requires-Dist: pydantic>=2.9.0
24
+ Requires-Dist: uvicorn>=0.32.0
25
+ Provides-Extra: dspy
26
+ Requires-Dist: dspy>=3.4.0; extra == 'dspy'
27
+ Provides-Extra: mlflow
28
+ Requires-Dist: mlflow>=3.10.0; extra == 'mlflow'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Misbār (`مِسبار`) v1.0.0 — العمود الفقري للتتبّع والمراجعة العمياء
32
+
33
+ <div align="center">
34
+
35
+ **Deterministic Workflow Spine, Zero-Dependency Trace Capture, & Blind RTL/LTR Human Review Queues**
36
+ Part of the **Maqāyīs (`مَقاييس`)** Open-Source Ecosystem · [maqayis.org](https://maqayis.org) · [github.com/maqayis/misbar](https://github.com/maqayis/misbar)
37
+
38
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
39
+ [![Python 3.11+](https://img.shields.io/badge/Python-3.11%2B-3776AB.svg)](pyproject.toml)
40
+
41
+ </div>
42
+
43
+ ---
44
+
45
+ ## نظرة عامّة | Overview
46
+
47
+ **`misbar` (`مِسبار` v1.0.0)** هو العمود الفقري المفتوح المصدر لتتبّع الأنابيب البحثية والهندسية، وحساب البصمات السببية (`SHA-256 Lineage Digests`)، وإدارة طوابير المراجعة البشرية العمياء الثنائية الاتجاه (`RTL/LTR Blind Calibration & Audit Queues`) مع إعادة التشغيل الانتقائي للمراحل اللاحقة (`Selective Downstream Reruns`) في منظومة **مَقاييس (`Maqāyīs`)** من تطوير **صلاح عبده (`Salah Abdo`)**.
48
+
49
+ **`misbar` (`v1.0.0`)** provides a SQLite-backed workflow lineage store (`MisbarStore`), deterministic partitioned step runner (`Pipeline`), zero-dependency remote/GPU JSONL span recorder (`misbar.capture.JsonlRecorder`), FastAPI review API, and reusable blind `RTL/LTR` human annotation & calibration recipes.
50
+
51
+ ---
52
+
53
+ ## التثبيت السريع | Installation & Quickstart
54
+
55
+ ```bash
56
+ pip install misbar
57
+ ```
58
+
59
+ ```python
60
+ from misbar import MisbarStore, Pipeline, SqliteSink
61
+
62
+ store = MisbarStore("runs.db")
63
+ pipeline = Pipeline(store=store, sink=SqliteSink(store))
64
+ ```
65
+
66
+ ---
67
+
68
+ ## الترخيص | License
69
+
70
+ - **License:** [Apache-2.0](LICENSE) · [`NOTICE`](NOTICE) · [`CITATION.cff`](CITATION.cff)
71
+ - **Copyright:** `Copyright 2026 Salah Abdo and successor entity`
misbar-1.0.0/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Misbār (`مِسبار`) v1.0.0 — العمود الفقري للتتبّع والمراجعة العمياء
2
+
3
+ <div align="center">
4
+
5
+ **Deterministic Workflow Spine, Zero-Dependency Trace Capture, & Blind RTL/LTR Human Review Queues**
6
+ Part of the **Maqāyīs (`مَقاييس`)** Open-Source Ecosystem · [maqayis.org](https://maqayis.org) · [github.com/maqayis/misbar](https://github.com/maqayis/misbar)
7
+
8
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
9
+ [![Python 3.11+](https://img.shields.io/badge/Python-3.11%2B-3776AB.svg)](pyproject.toml)
10
+
11
+ </div>
12
+
13
+ ---
14
+
15
+ ## نظرة عامّة | Overview
16
+
17
+ **`misbar` (`مِسبار` v1.0.0)** هو العمود الفقري المفتوح المصدر لتتبّع الأنابيب البحثية والهندسية، وحساب البصمات السببية (`SHA-256 Lineage Digests`)، وإدارة طوابير المراجعة البشرية العمياء الثنائية الاتجاه (`RTL/LTR Blind Calibration & Audit Queues`) مع إعادة التشغيل الانتقائي للمراحل اللاحقة (`Selective Downstream Reruns`) في منظومة **مَقاييس (`Maqāyīs`)** من تطوير **صلاح عبده (`Salah Abdo`)**.
18
+
19
+ **`misbar` (`v1.0.0`)** provides a SQLite-backed workflow lineage store (`MisbarStore`), deterministic partitioned step runner (`Pipeline`), zero-dependency remote/GPU JSONL span recorder (`misbar.capture.JsonlRecorder`), FastAPI review API, and reusable blind `RTL/LTR` human annotation & calibration recipes.
20
+
21
+ ---
22
+
23
+ ## التثبيت السريع | Installation & Quickstart
24
+
25
+ ```bash
26
+ pip install misbar
27
+ ```
28
+
29
+ ```python
30
+ from misbar import MisbarStore, Pipeline, SqliteSink
31
+
32
+ store = MisbarStore("runs.db")
33
+ pipeline = Pipeline(store=store, sink=SqliteSink(store))
34
+ ```
35
+
36
+ ---
37
+
38
+ ## الترخيص | License
39
+
40
+ - **License:** [Apache-2.0](LICENSE) · [`NOTICE`](NOTICE) · [`CITATION.cff`](CITATION.cff)
41
+ - **Copyright:** `Copyright 2026 Salah Abdo and successor entity`
@@ -0,0 +1,58 @@
1
+ [project]
2
+ name = "misbar"
3
+ version = "1.0.0"
4
+ description = "Misbar (مسبار): Foundational workflow spine, trace adapters, and blind/RTL human review queues (Maqayis)"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = { text = "Apache-2.0" }
8
+ authors = [
9
+ { name = "Salah Abdo", email = "Salah.Abdo.Tech@gmail.com" }
10
+ ]
11
+ keywords = ["observability", "tracing", "human-in-the-loop", "rtl", "arabic", "evaluation", "maqayis", "misbar"]
12
+ classifiers = [
13
+ "Development Status :: 5 - Production/Stable",
14
+ "Intended Audience :: Science/Research",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: Apache Software License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ ]
22
+ dependencies = [
23
+ "fastapi>=0.115.0",
24
+ "pydantic>=2.9.0",
25
+ "uvicorn>=0.32.0",
26
+ ]
27
+
28
+ [project.optional-dependencies]
29
+ mlflow = [
30
+ "mlflow>=3.10.0",
31
+ ]
32
+ dspy = [
33
+ "dspy>=3.4.0",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://maqayis.org"
38
+ Repository = "https://github.com/maqayis/misbar"
39
+ Mirror = "https://codeberg.org/maqayis/misbar"
40
+
41
+ [project.scripts]
42
+ misbar = "misbar.cli:main"
43
+
44
+ [dependency-groups]
45
+ dev = [
46
+ "httpx>=0.27.0",
47
+ "pytest>=8.3.0",
48
+ ]
49
+
50
+ [build-system]
51
+ requires = ["hatchling"]
52
+ build-backend = "hatchling.build"
53
+
54
+ [tool.hatch.build.targets.wheel]
55
+ packages = ["src/misbar"]
56
+
57
+ [tool.pytest.ini_options]
58
+ testpaths = ["tests"]
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: misbar
3
+ description: Build end-to-end traced pipelines and bespoke human review/annotation/rerun workspaces on top of the `misbar` spine (`MisbarStore`, `Pipeline`, `TraceSink`, stdlib `capture.py`, blind/RTL reviewer UIs). Use whenever asked to add observability, human grading/audit queues, blind calibration review, error triage, or human-in-the-loop artifact revision & selective downstream reruns to an experiment or pipeline.
4
+ ---
5
+
6
+ # `misbar` (مسبار) — Traced Pipelines & Glass-Box Review Workspaces
7
+
8
+ Canonical repo: `https://github.com/maqayis/misbar`
9
+
10
+ ## Two Core Architectural Laws
11
+
12
+ ### Law 1 — Own the Workflow Data Model & Separate Feedback from Execution
13
+ Store workflow lineage in SQLite WAL (`MisbarStore`), never inside trace records alone, and strictly separate **Mode A** from **Mode B**:
14
+
15
+ 1. **Mode A — Save Grade / Evaluation (`POST /api/annotations`)**:
16
+ - Appends a human judgment keyed by `(task_key, item_key, input_digest)`.
17
+ - **Never** mutates `artifact_versions` and **never** triggers a pipeline run.
18
+ - Because `input_digest` hashes only the *question* (e.g. `(concept_card, passage)`), human gold carries forward automatically across future model/rubric runs whenever the underlying question is unchanged.
19
+ 2. **Mode B — Apply Revision & Rerun Downstream (`POST /api/revisions`)**:
20
+ - Mints an immutable `artifact_version = v+1` (`origin='human_revision'`) without mutating `v`.
21
+ - When `trigger_rerun=true`, spawns a child `run` (`parent_run_id`) that reuses clean upstream steps/partitions and re-executes **only** dirty downstream work.
22
+
23
+ ### Law 2 — Glass-Box UI: Compile Code Assumptions & Trace Logic onto the Screen
24
+ The entire point of an on-demand coding agent building the UI (rather than using a generic SaaS viewer) is that **you have read the pipeline's actual source code, prompts, scoring scripts, and experiment notes**. Never ship a generic CRUD form with `JSON.stringify(output)` or `JSON.stringify(spans)`. Every custom UI **must** visually externalize:
25
+
26
+ 1. **Task & Rubric Assumptions on the Input Surface** *(without breaking blindness)*:
27
+ - Parse inputs into structured domain sections and surface the pipeline's decision rules (e.g. Part-of-Speech locks, positive vs. negative fences, unit-granularity shifts like `satisfies` vs `contains`) so the human grades against the *exact* hypothesis the code is testing.
28
+ - Label verdict buttons with their real scoring semantics in the codebase (e.g. how each choice maps to binary training labels or κ evaluation).
29
+ 2. **Pipeline Decision & Sampling Mechanics** *(on reveal or in unblinded triage)*:
30
+ - Explain *why* votes/candidates exist (perturbation strategy, consensus survival vs. drop-on-split, control arms, sampling stratum meaning) and highlight model-extracted spans directly inside the passage (`renderHighlightedLex`).
31
+ 3. **How to Read the Trace (Causal Walkthrough, Not Raw JSON)**:
32
+ - Reconstruct the runner's control flow per item: batch size & exact item position (`Text k of N`, book vs. shuffled order), recursive split/retry chains and why a call failed, cache-key (`prompt_sha`) transitions, and **measured model traps** (e.g. leaked `reasoning_tokens` despite `thinking: disabled`, long-context drift).
33
+ 4. **Mode B Hypothesis & Rerun Economics**:
34
+ - Show *why* editing this upstream artifact is the right lever and display the exact partition/quota math (`dirty_items` vs. `reused_items`, estimated API calls) before triggering a rerun.
35
+
36
+ Every reviewer UI **must work 100% offline** from `workflow.sqlite3` (`trace_spans` mirror), with optional one-click deep links to local MLflow 3.x when configured.
37
+
38
+ ---
39
+
40
+ ## 5-Step Build Playbook for Agents
41
+
42
+ ### Step 1: Extract Pipeline Assumptions & Scope the Task Shape (Before Writing Code)
43
+ Read the target project's runner, prompts/rubrics, scoring script, and README/audit notes first, then decide:
44
+ - **Assumptions & Trace Story to Surface:** list the rubric boundary rules, consensus/voting logic, retry/split rules, and known model traps that the UI cards will explain.
45
+ - **Action Depth:**
46
+ - *Single-stage evaluation / dataset audit* (e.g. `system1-lab/experiments/*`): enable **Mode A** (`[Save Grade]`), plus Mode B if input cards/prompts are edited in-place.
47
+ - *Multi-stage pipeline* (e.g. `translation_pipeline`, `awn4-live-sample`): enable **Mode A** (`[Save Evaluation Note]`) **and** **Mode B** (`[Apply Revision & Rerun Downstream]`) as visually distinct controls.
48
+ - **UI Tier:**
49
+ - **Tier 1 (`recipes/micro_ui/`)** *(Default)*: zero-build FastAPI + ES modules (`uv run python review_app.py`). Zero `npm` or `node_modules` inside Python research directories.
50
+ - **Tier 2 (`recipes/react_workspace/`)**: Vite + React + TypeScript starter for multi-pane / graph-heavy workspaces.
51
+ - **Blindness Mode (`QueueSpec.blind_mode` & `base_filter`):**
52
+ - `reveal_after_submit` *(Default for unbiased gold & calibration)*: strips `output` + `secret_meta_keys` (`silver`, `gold`, scores) on the server until `POST /api/annotations` commits.
53
+ - `full_blind`: never reveals model outputs even after submit.
54
+ - `ab_randomized`: shuffles two candidate runs/votes into `slot_1` / `slot_2` deterministically per `(reviewer_id, item_key)` and records the server-side permutation (use `base_filter` to restrict A/B queues to actual candidate disagreements!).
55
+ - `unblinded`: shows model outputs, disagreements, FP/FN presets, and trace walkthroughs upfront (use as a separate triage queue!).
56
+ - **Data & Licensing Boundary:**
57
+ - Store `misbar.sqlite3` inside the project's gitignored `data/` folder whenever items contain restricted/licensed corpus text (e.g. Lisan al-Arab dumps, copyrighted books, LDC treebanks). Commit only code and text-free aggregate reports unless project rules state otherwise.
58
+
59
+ ### Step 2: Define Stable `input_digest` Keys
60
+ Read [`references/data-model-and-reruns.md`](references/data-model-and-reruns.md).
61
+ - Always pass `input_keys=[...]` when minting item artifacts so run-specific metadata never invalidates prior human gold.
62
+ - Set `partition_key` (e.g. `concept_id` or `chapter_id`) whenever revising one upstream card/glossary entry should rerun only that partition's batches instead of spending LLM quota on the entire dataset.
63
+
64
+ ### Step 3: Wire Runtime & Rich Span Attributes
65
+ Read [`references/tracing-adapters.md`](references/tracing-adapters.md).
66
+ - Add editable dependency using a workspace-relative path (so `pyproject.toml` stays portable across machines):
67
+ ```sh
68
+ uv add --editable ../misbar # or ../../../misbar from system1-lab/experiments/<exp>
69
+ ```
70
+ - **Local Python (`DSPy`, `RoutedLM`, batch scripts):** wrap calls in `StepContext.span(...)` or ingest existing call receipts (`calls.jsonl`, `votes.jsonl`) into `MisbarStore` + optional `MlflowSink`. Record `item_keys` plus batch order/retry attributes on each span so `get_item_spans(item_key)` returns only the calls that touched that item and the UI can explain its exact position & retry path.
71
+ - **Remote GPU (`Colab`, `Kaggle`):** copy standalone stdlib `misbar/capture.py` (zero external dependencies) to emit `spans.jsonl` + `items.jsonl`, then import locally via `uv run misbar ingest ...`.
72
+
73
+ ### Step 4: Build the Glass-Box Domain UI
74
+ Read [`references/rtl-and-blind-ui.md`](references/rtl-and-blind-ui.md) and start from [`recipes/micro_ui/`](recipes/micro_ui/) (or [`recipes/react_workspace/`](recipes/react_workspace/)).
75
+ - Render all Arabic or mixed AR/EN strings through `renderLex` / `renderHighlightedLex` / `bdi` (`unicode-bidi: isolate`, `line-height: 2.15` so harakat/shadda never clip); never place un-isolated Arabic inside LTR monospace code strings.
76
+ - Keep passage containers independently scrollable (`.lex-scroll`) with item navigation in the card header and the right-hand grading/trace column `position: sticky` (`.sticky-col`) so book/chapter-length items never push controls off-screen.
77
+ - Sync textarea drafts on `input` and render via `preserveFocusRender(root, html)` so live diacritic-free `input` search (`stripArabicDiacritics`) and verdict clicks (`1–9`, `j`/`k`, `Ctrl/Cmd+Enter`) never lose focus or wipe unsaved notes.
78
+
79
+ ### Step 5: Run Offline & Visual Verification
80
+ 1. Write and run a fast offline test (`fastapi.testclient.TestClient` against a temporary `MisbarStore`) verifying server blindness (`403` on `/spans` before submit), idempotent Mode A gold + live `counts`, item insertion ordering, item-scoped batch spans, and Mode B `v+1` selective rerun scope.
81
+ 2. Visually inspect the rendered UI across short items, long (`book`/`chapter`) items, blind vs. revealed states, A/B disagreements, and trace walkthroughs to confirm zero BiDi scrambling, overflow, or raw JSON dumps.
@@ -0,0 +1,14 @@
1
+ # Tier 1 Recipe: Zero-Build `micro_ui` (`uv run` only)
2
+
3
+ Copy `review_app.py` and `ui/` into your experiment directory when you want a fast, tailored reviewer/annotator interface with **zero Node/npm dependencies**.
4
+
5
+ ## How It Works
6
+ - `review_app.py` defines your project's `QueueSpec`s (e.g. a blind gold queue + an unblinded audit triage queue) and passes `custom_ui_dir="ui"` to `create_misbar_app(...)`.
7
+ - `/assets/rtl.css` and `/assets/primitives.js` (`renderLex`, `stripArabicDiacritics`, `getVerbatimSelection`, `bindShortcuts`, `newMutationId`) are served automatically from `misbar`.
8
+ - `ui/custom_app.js` renders your domain-specific card and keeps **Mode A (`Save Grade`)** visually separate from **Mode B (`Apply Revision & Rerun`)**.
9
+
10
+ ## Run
11
+ ```sh
12
+ uv run python review_app.py
13
+ ```
14
+
@@ -0,0 +1,59 @@
1
+ """Copy-and-own Tier 1 zero-build FastAPI reviewer starter."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from pathlib import Path
7
+
8
+ import uvicorn
9
+
10
+ from misbar.api import QueueSpec, create_misbar_app
11
+ from misbar.db import MisbarStore
12
+ from misbar.tracing import MlflowSink
13
+
14
+ HERE = Path(__file__).resolve().parent
15
+ DB_PATH = Path(os.environ.get("MISBAR_DB", HERE / "data" / "misbar.sqlite3"))
16
+
17
+
18
+ def build_app() -> object:
19
+ store = MisbarStore(DB_PATH)
20
+ mlflow_uri = os.environ.get("MLFLOW_TRACKING_URI")
21
+ mlflow_sink = MlflowSink(tracking_uri=mlflow_uri) if mlflow_uri else None
22
+
23
+ queues = [
24
+ QueueSpec(
25
+ queue_key="blind-gold",
26
+ title="Blind Gold Grading",
27
+ task_key="domain_eval",
28
+ artifact_key="predictions",
29
+ blind_mode="reveal_after_submit",
30
+ allow_mode_override=False,
31
+ verdict_options=("yes", "no"),
32
+ allow_revisions=False,
33
+ ),
34
+ QueueSpec(
35
+ queue_key="audit-triage",
36
+ title="Unblinded Error Triage & Revisions",
37
+ task_key="domain_eval",
38
+ artifact_key="predictions",
39
+ blind_mode="unblinded",
40
+ verdict_options=("yes", "no"),
41
+ allow_revisions=True,
42
+ filter_presets={
43
+ "disagree": lambda r: r["output"].get("vote_A") != r["output"].get("vote_B"),
44
+ },
45
+ ),
46
+ ]
47
+
48
+ return create_misbar_app(
49
+ store,
50
+ title="Domain Reviewer Workbench",
51
+ queues=queues,
52
+ mlflow_sink=mlflow_sink,
53
+ custom_ui_dir=HERE / "ui",
54
+ )
55
+
56
+
57
+ if __name__ == "__main__":
58
+ uvicorn.run(build_app(), host="127.0.0.1", port=int(os.environ.get("PORT", "8765")))
59
+