cribsheet 0.21.2.dev3__py3-none-any.whl → 0.21.2.dev4__py3-none-any.whl

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.
crib/app.py CHANGED
@@ -3492,8 +3492,9 @@ class Crib:
3492
3492
  "progress": state,
3493
3493
  "resume_hint": (
3494
3494
  "the rekey runs daemon-owned (a client disconnect can't "
3495
- "cancel it) — re-invoke to poll/join, or with "
3496
- "wait_s=<seconds> to block"
3495
+ "cancel it) — POLL it, don't block: project_status "
3496
+ "carries the live progress; re-invoking the verb joins "
3497
+ "or finishes it"
3497
3498
  ),
3498
3499
  }
3499
3500
  started = time.monotonic()
@@ -3506,7 +3507,9 @@ class Crib:
3506
3507
  "relocated": True,
3507
3508
  "running": True,
3508
3509
  "progress": state,
3509
- "resume_hint": "still rekeying — re-invoke to join/poll",
3510
+ "resume_hint": (
3511
+ "still rekeying — poll project_status; re-invoking joins"
3512
+ ),
3510
3513
  }
3511
3514
 
3512
3515
  # 6. The FINISHED path (or nothing to do): the heavy result if a job ran
@@ -3853,11 +3856,92 @@ class Crib:
3853
3856
  """Delegate to Refs (crib/refs.py) — a project's `.crib` refs: targets."""
3854
3857
  return self.refs.project_refs(proj)
3855
3858
 
3859
+ def _job_rows(self, proj: str | None = None) -> list[dict[str, Any]]:
3860
+ """Every long-running project job that a POLL can see — the relocate
3861
+ rekey/citation phase, the code-index sweeps, the background reconcile.
3862
+ Calling this while ANY of them run is the point of it: it never errors,
3863
+ never blocks; it reports running/complete/failed + live counts, and the
3864
+ finished counts a job already banked (citations rewritten, mount named,
3865
+ chunks rekeyed)."""
3866
+ rows: list[dict[str, Any]] = []
3867
+ for p, job in sorted(self.relocate_jobs.items()):
3868
+ if proj is not None and p != proj:
3869
+ continue
3870
+ state = dict(job.get("state") or {})
3871
+ t = job["task"]
3872
+ done, error = t.done(), None
3873
+ if done:
3874
+ try:
3875
+ exc = t.exception() # never re-raised — reported, polled
3876
+ if exc is not None:
3877
+ error = f"{type(exc).__name__}: {exc}"
3878
+ except Exception as e: # noqa: BLE001 — the poll never raises
3879
+ error = f"{type(e).__name__}: {e}"
3880
+ rows.append(
3881
+ {
3882
+ "kind": "relocate",
3883
+ "project": p,
3884
+ "phase": "rekey+rehash",
3885
+ "running": not done,
3886
+ "complete": done and error is None,
3887
+ "error": error,
3888
+ "done": state.get("done", 0),
3889
+ "total": state.get("total", 0),
3890
+ "citations_rewritten": state.get("citations", 0),
3891
+ "mount_renamed": state.get("mount") or [],
3892
+ }
3893
+ )
3894
+ for p, meta in sorted(self.code_jobs.items()):
3895
+ if proj is not None and p != proj:
3896
+ continue
3897
+ sw = self.code.sweeps.get(p) or {}
3898
+ done = meta["task"].done()
3899
+ rows.append(
3900
+ {
3901
+ "kind": "code_index",
3902
+ "project": p,
3903
+ "phase": "extract+describe+embed",
3904
+ "running": not done,
3905
+ "complete": done,
3906
+ "done": sw.get("done"),
3907
+ "total": sw.get("total"),
3908
+ **({"line": sw.get("line")} if sw.get("line") else {}),
3909
+ }
3910
+ )
3911
+ for p in sorted(self.code.sweeps):
3912
+ if p in self.code_jobs or (proj is not None and p != proj):
3913
+ continue
3914
+ sw = self.code.sweeps[p] or {}
3915
+ rows.append(
3916
+ {
3917
+ "kind": "code_index",
3918
+ "project": p,
3919
+ "phase": "sweep (no live call; project_index re-invokes to join)",
3920
+ "running": sw.get("running", True),
3921
+ "complete": False,
3922
+ "done": sw.get("done"),
3923
+ "total": sw.get("total"),
3924
+ }
3925
+ )
3926
+ if self._reconcile_remaining is not None:
3927
+ rows.append(
3928
+ {
3929
+ "kind": "reconcile",
3930
+ "project": "ALL",
3931
+ "phase": "re-embed sweep",
3932
+ "running": True,
3933
+ "complete": False,
3934
+ "remaining": self._reconcile_remaining,
3935
+ }
3936
+ )
3937
+ return rows
3938
+
3856
3939
  def project_status(
3857
3940
  self, project: str | None = None, cwd: Path | None = None
3858
3941
  ) -> dict[str, Any]:
3859
3942
  """Is this project code-indexed? symbol/file counts, kind breakdown, the
3860
- `.crib` source paths — for orienting before setup/index."""
3943
+ `.crib` source paths — for orienting before setup/index. Also the POLL
3944
+ surface for long-running jobs (see `jobs`)."""
3861
3945
  from collections import Counter
3862
3946
 
3863
3947
  from .codeindex import SymbolIndex
@@ -3889,6 +3973,11 @@ class Crib:
3889
3973
  # live reindex progress ({done,total}) while a sweep runs — the poll signal
3890
3974
  # for a budgeted project_index that returned complete=False
3891
3975
  "indexing": self.code.sweeps.get(proj),
3976
+ # the non-blocking poll section: every long-running job for this
3977
+ # project (relocate rekey, code sweep, reconcile) — running/
3978
+ # complete/failed + the counts already banked. NEVER errors, never
3979
+ # blocks; this is what the model polls instead of waiting.
3980
+ "jobs": self._job_rows(proj),
3892
3981
  "doc_sources": srcs,
3893
3982
  "doc_chunks": doc_count,
3894
3983
  "crib": (str(link.root / ".crib") if link and link.root else None),
crib/cli.py CHANGED
@@ -1441,14 +1441,6 @@ def build_parser() -> argparse.ArgumentParser:
1441
1441
  "prefix (citations keep spelling the old dir name; the docs rehash "
1442
1442
  "is skipped so no double-mount)",
1443
1443
  )
1444
- _sp.add_argument(
1445
- "--wait-s",
1446
- type=float,
1447
- default=None,
1448
- dest="wait_s",
1449
- help="block up to N seconds joining the rekey job (default: a "
1450
- "running handle returns at once; re-invoke to poll/join)",
1451
- )
1452
1444
  _pf = pjsub.add_parser(
1453
1445
  "forget", help="clear the code index (keeps learnings/notes)"
1454
1446
  )
@@ -2907,13 +2899,12 @@ VERBS: dict[str, Verb] = {
2907
2899
  "project_path": a.project_path,
2908
2900
  "source": getattr(a, "source", None),
2909
2901
  "keep_prefix": getattr(a, "keep_prefix", False),
2910
- "wait_s": getattr(a, "wait_s", None),
2911
2902
  },
2912
2903
  _E, # the report is structured; json-aware print
2913
2904
  is_async=True,
2914
2905
  policy="none",
2915
2906
  wants_cwd=False, # the new dir is named, never inferred from cwd
2916
- mcp=_PROJ + " source=None keep_prefix=False wait_s=None",
2907
+ mcp=_PROJ + " source=None keep_prefix=False",
2917
2908
  ),
2918
2909
  "project delete": _DELETE_VERB,
2919
2910
  # code index
crib/server.py CHANGED
@@ -853,10 +853,9 @@ def build_server(crib: Crib | None = None):
853
853
  `project_path=<the repo dir>` (a `.crib` is auto-created if missing); a bare
854
854
  `project=<name>` re-indexes an ALREADY-INDEXED project from its recorded root.
855
855
 
856
- Emits PROGRESS markers while the sweep runs (`<proj>: 42/317 files (13%) ·
857
- 2.1/s · eta 2:05`), so a long index streams live progress and doesn't
858
- idle-time-out — and the rate/eta is what a client needs to size its call
859
- timeout instead of guessing. It runs to completion in one call.
856
+ Emits PROGRESS markers while the sweep runs (`<proj>: 42/317 files (13%) ·
857
+ 2.1/s · eta 2:05`) — the call returns when the sweep completes; while it
858
+ runs, `project_status`'s `jobs` section is the non-blocking poll.
860
859
  (`project_status` also carries the live `indexing` counts.) If your client
861
860
  enforces a hard call timeout anyway, two levers:
862
861
  - `wait_s=<seconds>` bounds THIS call: the final result if the sweep
@@ -936,27 +935,22 @@ def build_server(crib: Crib | None = None):
936
935
  project_path: str | None = None,
937
936
  source: str | None = None,
938
937
  keep_prefix: bool = False,
939
- wait_s: float | None = None,
940
938
  ) -> dict[str, Any]:
941
939
  """The move-and-rename verb: a repo project's checkout was moved and/or
942
- renamed on this machine (works after the fact — the old path may be gone).
943
- Re-points everything that recorded the OLD absolute path AND, when the
944
- directory was renamed, re-homes the `sources/<old-name>/` mount prefix to
945
- `sources/<new-name>/…`: the doc chunks rekey (project+relpath hash — the
946
- rare verb's re-embed cost, same class as project_rename) and every
947
- citation in THIS project's notes is rewritten to the new spelling (the
948
- prior note stashed to the ring first). The code index's .source_root and
949
- this repo's own .crib `project:` line (when it names the pre-rename name,
950
- fenced by dead-source evidence) are rewritten; the heavy half runs as a
951
- DAEMON-OWNED job (a client disconnect can't cancel it mid-embed):
952
- wait_s=None returns a running handle with progress (re-invoke to poll or
953
- join); wait_s=<seconds> blocks. A trailing CODE rehash surface uses
954
- project_wait. Foreign sites are REPORTED, not edited. Pass project=<name>
955
- AND project_path=<the repo's new dir>; source=<segment> disambiguates
956
- dead in-situ sources; keep_prefix=true = identity-keeping only."""
957
- return await crib.project_relocate(
958
- project, project_path, source, keep_prefix, wait_s
959
- )
940
+ renamed on this machine (works after the fact — the old path may be gone,
941
+ the project renamed, an earlier relocate cut halfway — re-invoke RESUMES).
942
+ The fast half (code-index .source_root, doc-source mounts, the repo's own
943
+ .crib line when it names the pre-rename name, an in-repo store stub) is
944
+ re-pointed at once and idempotent. The HEAVY half — re-homing the
945
+ `sources/<old>/` mount when the DIR was renamed (doc chunks rekey +
946
+ re-embed; every citation in THIS project's notes rewritten to the new
947
+ spelling) — runs as a DAEMON-OWNED job: the call returns a RUNNING HALF
948
+ at once with `progress` + `resume_hint`. DON'T WAIT: poll `project_status`
949
+ (its `jobs` section carries live done/total + the banked counts);
950
+ re-invoking the verb joins when the job is still running. A trailing CODE
951
+ rehash sweep joins too — never an error. keep_prefix=true = identity-
952
+ keeping only. Foreign sites are REPORTED, not edited."""
953
+ return await crib.project_relocate(project, project_path, source, keep_prefix)
960
954
 
961
955
  @crib_tool("source")
962
956
  def project_status(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: cribsheet
3
- Version: 0.21.2-dev3
3
+ Version: 0.21.2-dev4
4
4
  Summary: Local MCP server: markdown memory with a Chroma embedding index
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: chromadb>=0.5
@@ -1,9 +1,9 @@
1
1
  crib/__init__.py,sha256=zj2qVJwYgLInI0Ie2N4NeJQw1ltiUhCM6_umP4skhcg,1005
2
2
  crib/__main__.py,sha256=umIc03A2oA7s2oiL80Ts_QnS-0zj9fjV3IQ103AmNXg,232
3
- crib/app.py,sha256=lRj_jNGNbahXYhXdmE9yWvxlQJdzIf-gYXYWs1vIVgo,249063
3
+ crib/app.py,sha256=pi8gEo5p_yhj2mPd-K9cPMtEO8-WPLz_g5Fjgy32vzo,252993
4
4
  crib/chunk.py,sha256=GDGpmVE7JhP7zVy0TzbCBSRO0PnQUIXQISsxkC7SWKA,13653
5
5
  crib/claudemem.py,sha256=Xf4mVgTFbXHdhhqteTIRz2zirc4irf0wim8AeMybudI,4804
6
- crib/cli.py,sha256=jzbuSjCXrjAKnxGxylQMlhKVu4MZ2OrcrPufzCTiCI8,139812
6
+ crib/cli.py,sha256=3CbIsTe605koilnaW-KUwIS61Uc9NT9zC-zGsyRg8gc,139498
7
7
  crib/client.py,sha256=fjd2QwvbSNZmq9eXWFgQsMq_2o5-OLH7ZhE48xLxMNs,6602
8
8
  crib/codeindex.py,sha256=Xw-37_uOarZvIledYEUqSzc1PA-DrOVNmdx_94MvJ6E,89312
9
9
  crib/codeindexer.py,sha256=E0A9PGKJPp413-W3R_e5JlxHMnY-9g3Vg1MA9ixNA4w,33769
@@ -28,7 +28,7 @@ crib/project_services.py,sha256=dOPz7RUdw_QS9AeR18d2gcnk6Z9JzeK9nRiFafF_IuI,2112
28
28
  crib/refs.py,sha256=A42tIAg2vsgjp4r7Gdp1PyfmWm46jcnde9j_DfUpxo8,13106
29
29
  crib/retrieve.py,sha256=eeRiI1oE_02H_i_qDsS6804RvBpvh4BkwD-HYcQo35c,22149
30
30
  crib/section_index.py,sha256=nhFEZQBjlfV9y5fpB39Rp5RPFHLnp2nhZbAG8S7fUNg,8846
31
- crib/server.py,sha256=pbMVttMnyy4FjfSyoYZfyMo7gUUuFOYmZC7_cw6L33Y,118716
31
+ crib/server.py,sha256=3ywaAp-q1oZq7isVjkpmShjhkQn_0wnlAcwMbh5lFRM,118399
32
32
  crib/session.py,sha256=HMF_6n6ZIPY3p8mRJfMJ75iByKOoPIUvUJST1r8sSOQ,13631
33
33
  crib/sharedserver.py,sha256=SLGcF3Iax5ThPiFyCJ9ahs3movG-p5nNk0n8dahgWQo,1919
34
34
  crib/sources.py,sha256=gJNhRQeLTKC7v_KSSVGy7kaYgj_9iWJyz_Yd9W8512Q,2918
@@ -39,7 +39,7 @@ crib/tomlrec.py,sha256=ptDbYNhTLmXQeN1BrQGcy2E4wNv0hpKM7aayQ7WvkxE,3796
39
39
  crib/util.py,sha256=pf2iB3cvMC8JG5JJo7vH0t-7qy-d9ABHuSP7AJInauE,3018
40
40
  crib/versions.py,sha256=qFjPG9iFOEyRZ6K5CESM87JvbV1qf4tQoUIvqz-nADk,3621
41
41
  crib/watch.py,sha256=KpH-ipA-wkJVTxeghzM-Y9ljMAyrPxnmMumj3TNchmg,24303
42
- cribsheet-0.21.2.dev3.dist-info/METADATA,sha256=drmN-dW6UT1OODAJf1S8f7gJyFNUOXFsGZUSbU9i9MI,18790
43
- cribsheet-0.21.2.dev3.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
44
- cribsheet-0.21.2.dev3.dist-info/entry_points.txt,sha256=CjLxgcZdPGI6U4VRZmrwQ2kL1gUkNykYNkLzT8EQkfQ,39
45
- cribsheet-0.21.2.dev3.dist-info/RECORD,,
42
+ cribsheet-0.21.2.dev4.dist-info/METADATA,sha256=l3TJdunKdeWALa-OanzZr-3AtWGbbQYADxoCsPDt0YI,18790
43
+ cribsheet-0.21.2.dev4.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
44
+ cribsheet-0.21.2.dev4.dist-info/entry_points.txt,sha256=CjLxgcZdPGI6U4VRZmrwQ2kL1gUkNykYNkLzT8EQkfQ,39
45
+ cribsheet-0.21.2.dev4.dist-info/RECORD,,