Metadata-Version: 2.5
Name: docketry
Version: 0.17.0
Summary: A local, gate-enforced port that a law firm's email flows into. Base layer for small composable legal workflow tools.
License: 
                                         Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
License-File: NOTICE
Keywords: email,guardrails,law,legal,pipeline
Classifier: Intended Audience :: Legal Industry
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.11
Provides-Extra: cite
Requires-Dist: eyecite>=2; extra == 'cite'
Requires-Dist: httpx>=0.27; extra == 'cite'
Provides-Extra: docx
Requires-Dist: python-docx>=1; extra == 'docx'
Provides-Extra: export
Requires-Dist: openpyxl>=3; extra == 'export'
Requires-Dist: python-docx>=1; extra == 'export'
Provides-Extra: ocr
Requires-Dist: pillow>=10; extra == 'ocr'
Requires-Dist: pytesseract>=0.3; extra == 'ocr'
Provides-Extra: pdf
Requires-Dist: pypdf>=4; extra == 'pdf'
Description-Content-Type: text/markdown

# Docketry

*Working name — a local, gate-enforced port that a law firm's email flows into.*

Most firms work out of their email. Docketry meets them there — without going
into their email. The firm creates a **dedicated intake mailbox** (for example
`intake@yourfirm.com`), points forwarding rules at it, and Docketry drains that
one mailbox with credentials the firm holds. Nothing enters the pipeline that
the firm didn't send across the boundary.

Docketry is the **base layer** of a family of small, composable open-source
legal workflow tools (document classification, e-service notice parsing,
citation verification, draft linting). Each plugs into the port as a **gate**
in a declared pipeline — and the package is laid out so you can check that
rather than take it on faith:

```
docketry/
  core/     the port — envelope, pipeline, store, manifest, roles, config,
            and the gate registry with the hygiene gates.  ~1,700 lines.
  tools/    the family — classification, notice parsing, citation work,
            redaction, timelines, exports, reconciliation, linting, matter
            workflow, contacts, reporting, and the optional local model.
  cli.py    the command line, the review UI, and the setup wizard.
  webui.py
  wizard.py
```

`tools/` imports `core/`. `core/` imports nothing above it, and
`tests/test_boundaries.py` fails the build if that stops being true. The
notice parser and the document classifier plug in as gates by registering
with the port's registry — the same route a third-party gate takes, so the
extension story is the one the shipped code already uses.

**[ARCHITECTURE.md](ARCHITECTURE.md)** draws the whole thing: what happens to
a message, where a gate sits, how the package is bounded, and what the audit
chain does and does not prove.

## Why a firm installs this

Two of the gates are the reason. The rest are hygiene.

**The ethical wall.** List the parties or matters a reviewer must not see
flowing through intake unreviewed. Anything mentioning one stops — not warns,
stops — and the only thing that moves it is a recorded release by the role
your manifest names. What that leaves behind is a row saying who released it
and when, on the firm's own disk. A screen that maps to a bar rule is worth
having; a screen you can show someone the record of is worth more, and that
record is the thing a grievance actually asks about.

**Court e-service.** Docketry parses service and docket notices into case
numbers, document titles and dates — and holds any notice it cannot read
instead of guessing. A misread hearing date is a malpractice claim. An unread
one is a phone call. When a portal changes its template, the queue says so
rather than quietly extracting nothing.

Everything else here — attachment types, sender scope, size caps — is
pipeline hygiene. Useful, worth having on, and not why anyone would install
this. `docketry demo` shows the two above, and the rest as an afterthought.

## Write a gate in five minutes

A gate is one class with one method. Everything Docketry enforces is one —
the ethical wall, the notice parser — and nothing shipped has a privilege
yours does not.

```console
$ docketry new-gate long-subject     # writes a working gate into <home>/gates/
$ docketry try-gate long-subject --subject "a subject with rather too many words in it"
result:  [fail] subject is 9 words, over the 5 this pipeline accepts
$ docketry gates                     # what is bindable, and where each came from
```

Then add four lines to `guardrails.toml` and it runs on every message, held
and released exactly like the shipped ones. Drop a `.py` file in your home's
`gates/` directory, or ship it as a pip package with a `docketry.gates` entry
point. **[GATES.md](GATES.md)** is the five-minute walkthrough and the
reference.

## What makes it different

Best practices here are **code, not suggestions**:

- A message cannot cross a stage boundary without passing its gates or
  carrying a recorded approval from the role the manifest names. `advance()`
  is the only forward path and it re-checks every time. There is no advisory
  mode and no bypass flag.
- Gates declare which pipeline stages they are meant for; binding one
  elsewhere is a load-time error, not a footnote in documentation.
- Every finding and every human approval lands in an audit table on the
  firm's own disk, **hash-chained**: each approval carries a digest over its
  own content and the digest of the row before it, so an edited, deleted or
  reordered release stops verifying. `docketry doctor` checks the chain and
  fails if it is broken. Read the next section for what that is worth.

## What it is not

- **Not hosted.** Docketry runs on the firm's machine. We never hold, transit,
  or store anyone's email.
- **Not case management.** Docketry tracks a matter through the stages your
  firm defines and gates the moves between them. It does no billing, no trust
  accounting, no client portal and no calendar sync — that is your practice
  management system's job and it is better at it.
- **Not an access control system.** Roles decide what a hold is waiting for
  and are recorded against the name of whoever released it. There is no login:
  a role is an attestation, so the registry catches mistakes, not lies.
- **Not a security product.** Docketry makes no malware, phishing, or other
  cybersecurity claims. Its attachment and sender gates are pipeline-hygiene
  policy — what the *pipeline* accepts — nothing more. Get real security from
  your mail provider and endpoint tooling.
- **Not legal advice, and not a currency service.** Docketry never claims any
  rule, deadline, or authority is up to date. It checks the inputs you give
  it against the sources you point it at, and it fails loudly.

## The approval log, and what a hash chain is worth

Approvals are chained, and `docketry anchor` prints the head:

```console
$ docketry anchor
docketry-anchor 2026-08-29T21:14:03+00:00 approvals=118 head=9f2c...e41
```

An intact chain means nothing in the log was edited, deleted or reordered
after it was written. It does **not** mean the log is authentic, and the
difference matters if this is ever the record being questioned. The database
sits on the firm's own disk with no key, so anyone who can edit a row can
recompute every digest after it and hand you a chain that verifies. A test in
`tests/test_chain.py` does exactly that, on purpose, so nobody mistakes the
property for more than it is.

What makes a rewritten history detectable is the anchor: a copy of the head
kept somewhere the editor cannot reach. Mail the line to yourself, paste it
into a case note, print it, or let `docketry digest` carry it into whatever
daily summary the firm already sends. Once that line is somewhere the firm
does not administer, a rewritten log contradicts something that already left
the building — and that contradiction is the finding.

The chain catches the careless edit on its own. The anchor is what makes the
deliberate one need an accomplice. Docketry never sends anything, so moving
the anchor off the machine is the one step that stays yours.

## Data at rest

Docketry stores messages and attachments in plaintext SQLite and files in
its home directory, protected by file permissions (config.toml is *created*
0600 — not written and then tightened, so a stored password is never briefly
world-readable). It does NOT do application-level encryption, deliberately: an
encrypted database whose key sits on the same disk is comfort, not protection.
Protect a Docketry home the way you protect the rest of the client file system
— OS full-disk encryption (BitLocker / FileVault / LUKS) and OS accounts.
Nothing is ever copied off the machine.

On Windows that 0600 buys you nothing: `chmod` there moves the read-only bit
and says nothing about who else may read the file, whose permissions come from
the folder it sits in. On Windows, set `DOCKETRY_IMAP_PASSWORD` in the
environment instead of storing the password — `docketry init` says so too.

## Bring your own model (optional, local only)

Docketry works fully without a model, and calls one only if you configure it:

```toml
[llm]
base_url = "http://127.0.0.1:11434"   # Ollama, llama.cpp, vLLM, LM Studio
model = "qwen2.5"                     # or deepseek-r1, gemma2, llama3.1 ...
```

The endpoint is checked before any request is built and **refused unless it
resolves entirely to your own network** — loopback or private range. Point it
at a hosted API and Docketry stops rather than sending your documents to a
vendor. `docketry llm-check` and `docketry doctor` both say plainly whether
anything can reach off-network; with no model configured they say so too.

Any model your server can load works — the model name is a config string, not
an adapter. Reasoning models are handled: their narration is kept separate
from the answer, never presented as the conclusion.

A model here **proposes**. It never releases a hold, approves anything,
classifies, or decides what to redact. Those stay deterministic and
human-gated, and a test enforces that no gate, the pipeline runner, or the
redaction path can consult one.

We ship no weights and endorse no model; licences differ per release and are
yours to check.

## Try it in sixty seconds

```console
$ pip install docketry   # or grab a one-file executable from Releases
$ docketry demo
```

`demo` seeds a disposable home with sample traffic and opens the local
dashboard. Three messages pass clean. Three stop: a conflicts email naming a
screened party (blocked by the wall, attorney-only release), a court e-service
notice whose portal changed its template (held rather than guessed at), and an
unknown sender with an attachment (hygiene). You release them yourself and
watch the audit rows appear. No mailbox, no configuration, nothing saved.
(Downloadable one-file executables for Windows/macOS/Linux attach to tagged
releases — double-clicking one opens this same demo.)

## Quickstart

```console
$ pip install docketry
$ docketry init        # asks; writes config.toml, guardrails.toml, roles.toml
$ export DOCKETRY_IMAP_PASSWORD='app-password-here'
$ docketry poll        # sweep the intake mailbox once
$ docketry queue       # see anything a gate held for review
$ docketry approve 3 --gate sender-scope --by "Dana" --role paralegal
$ docketry status
```

`init` asks nine questions in plain words — which mailbox, what your firm
calls the person who reviews intake, who can release a conflict hold, which
names are behind the wall — and writes the three config files from the
answers, commented, so nobody has to author TOML to get started. It guesses
the IMAP host from the address and never writes a home that refuses to load.
Pass `--host` and `--user` to skip the questions for scripted installs.

Everything it writes is an ordinary file you can edit afterwards: the pipeline
lives in `guardrails.toml` in your Docketry home (see `examples/`), the roles
in `roles.toml`. Reading the intake mailbox is strictly read-only: messages
are never marked, moved, or deleted.

## Skills starter pack

`skills/` ships nine agent skills for Claude Code (or any Agent
Skills-compatible harness):

| Skill | What it drives |
|---|---|
| `review-draft` | verify-draft + lint on a draft |
| `classify-document` | the deterministic classifier and its staged queue |
| `intake-triage` | the review queue and approvals |
| `redact-document` | redaction, its preview, and its verification |
| `build-timeline` | the case timeline and its exports |
| `reconcile-docket` | diffing the reconstruction against a pulled docket |
| `manage-matter` | matters moving through the firm's workflow stages |
| `pipeline-health` | the report on volume, bottlenecks and dead config |
| `assign-contacts` | who an address belongs to, and what that makes privileged |

Install by copying into your project:

```console
$ cp -r skills/* .claude/skills/
```

The skills are a front door, not a bypass: each one drives the same CLI
commands and gates the pipeline uses, and each carries hard rules — a skill
never verifies a citation from model knowledge, never applies a classification
without a named human approver, never releases a hold itself, never edits a
workflow to get a blocked matter through, never turns queue figures into a
statement about a named person, and never decides for itself who the client is.

Every skill ships with an eval suite, and a test fails the build if one does
not: a tool an agent can drive without evals is an untested tool with a good
description. `examples/` includes three guardrail manifests to start from
(default, solo-strict, litigation-team), plus a bare workflow and roles file.

## Evals

Each skill ships an eval suite (`skills/<name>/evals/`) in the
`claude plugin eval` format. The graders encode the hard rules as tests:
`tool_used` asserts the agent actually RAN `docketry verify-draft` (answering
from model knowledge fails the eval even when the answer is right),
`min: 0, max: 0` graders assert approvals were never executed by the agent,
and judge graders check the honesty of degraded-mode reporting. The eval
runner is currently in early access; the suites are validated for shape in
CI and runnable wherever `claude plugin eval` is enabled.

## Requirements

Python 3.11+. The core is stdlib-only. Feature plugins declare extras
(`pip install "docketry[pdf,ocr]"` etc.) — see [FEATURES.md](FEATURES.md)
for the feature manifest and its dependency graph.

## License

Apache-2.0.
