phiward 0.2.0b1__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.
Files changed (53) hide show
  1. phiward/__init__.py +8 -0
  2. phiward/__main__.py +5 -0
  3. phiward/_toml.py +211 -0
  4. phiward/adapters/__init__.py +105 -0
  5. phiward/adapters/claude.py +429 -0
  6. phiward/broker.py +831 -0
  7. phiward/carryover.py +1613 -0
  8. phiward/claude_settings.py +1307 -0
  9. phiward/cli.py +110 -0
  10. phiward/config.py +936 -0
  11. phiward/confine.py +476 -0
  12. phiward/copying.py +533 -0
  13. phiward/core.py +105 -0
  14. phiward/data/agents-section.md +43 -0
  15. phiward/doctor.py +1132 -0
  16. phiward/fasthook.py +70 -0
  17. phiward/fsinfo.py +241 -0
  18. phiward/gateway.py +159 -0
  19. phiward/githooks.py +248 -0
  20. phiward/guards/__init__.py +0 -0
  21. phiward/guards/protected_paths.py +1138 -0
  22. phiward/hidden.py +281 -0
  23. phiward/init.py +155 -0
  24. phiward/install.py +828 -0
  25. phiward/inventory.py +173 -0
  26. phiward/mcp.py +186 -0
  27. phiward/mcp_config.py +1736 -0
  28. phiward/names.py +5 -0
  29. phiward/packs/dates.toml +17 -0
  30. phiward/packs/genomics.toml +51 -0
  31. phiward/packs/msk.toml +32 -0
  32. phiward/pathid.py +403 -0
  33. phiward/pathmatch.py +98 -0
  34. phiward/paths.py +942 -0
  35. phiward/pin.py +214 -0
  36. phiward/procinfo.py +73 -0
  37. phiward/remote.py +448 -0
  38. phiward/run.py +788 -0
  39. phiward/safeio.py +84 -0
  40. phiward/sanitize.py +691 -0
  41. phiward/selfcheck.py +1506 -0
  42. phiward/service.py +321 -0
  43. phiward/session_note.py +86 -0
  44. phiward/setup_cmd.py +886 -0
  45. phiward/shell.py +504 -0
  46. phiward/wholetool.py +1463 -0
  47. phiward-0.2.0b1.dist-info/METADATA +147 -0
  48. phiward-0.2.0b1.dist-info/RECORD +53 -0
  49. phiward-0.2.0b1.dist-info/WHEEL +5 -0
  50. phiward-0.2.0b1.dist-info/entry_points.txt +3 -0
  51. phiward-0.2.0b1.dist-info/licenses/LICENSE +662 -0
  52. phiward-0.2.0b1.dist-info/licenses/NOTICE +16 -0
  53. phiward-0.2.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,147 @@
1
+ Metadata-Version: 2.4
2
+ Name: phiward
3
+ Version: 0.2.0b1
4
+ Summary: Guards that keep protected data out of what an AI coding agent (Claude Code) sends to its model provider
5
+ Author: Ronak Shah
6
+ License-Expression: AGPL-3.0-only
7
+ Project-URL: Homepage, https://github.com/msk-access/phiward
8
+ Project-URL: Documentation, https://github.com/msk-access/phiward/tree/main/docs
9
+ Project-URL: Changelog, https://github.com/msk-access/phiward/blob/main/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/msk-access/phiward/issues
11
+ Keywords: phi,hipaa,ai-agents,claude-code,sandbox,data-protection,hpc
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
26
+ Classifier: Topic :: Security
27
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
28
+ Requires-Python: >=3.9
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ License-File: NOTICE
32
+ Dynamic: license-file
33
+
34
+ # phiward
35
+
36
+ phiward keeps protected data (for example patient data) and your credentials out of what an AI
37
+ coding agent sends to its model provider. The agent's tools send their output to the provider,
38
+ and that output can hold file contents, sample identifiers or file names. With phiward, the
39
+ agent works on protected data only through a **gateway** that masks names and identifiers.
40
+
41
+ **Why it exists, and how it differs from sandboxes, containers and PII tools:**
42
+ [docs/why.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/why.md).
43
+
44
+ **Start here:** [docs/quickstart.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/quickstart.md). Three steps: install phiward, set it up
45
+ (with Claude Code's help or by hand), and check it. In short:
46
+
47
+ ```bash
48
+ uv tool install --python-preference only-managed phiward==0.2.0b1
49
+ ```
50
+
51
+ then in Claude Code, `/plugin marketplace add msk-access/phiward#v0.2.0b1`,
52
+ `/plugin install phiward@phiward` and `/phiward:setup`.
53
+
54
+ > **Status: v0.2.0b1, a beta.** Tested with the real Claude Code on macOS, in the desktop app
55
+ > and in the terminal, and against a real HPC cluster. On Linux, only the test suite has run
56
+ > (no real Claude Code session yet). Read
57
+ > [docs/threat-model.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/threat-model.md) before you rely on it for real data.
58
+
59
+ It is a Python package with no dependencies. It makes no network connection of its own and
60
+ has no telemetry. It needs Python 3.9 or
61
+ newer, macOS or Linux, and Claude Code 2.1.295 or newer.
62
+
63
+ ## How it works
64
+
65
+ ```text
66
+ The AI agent's tools What reaches the model provider
67
+ (Read, Grep, Bash, MCP, ...)
68
+ |
69
+ | not protected (the project, your prompts)
70
+ +----------------------------------------> as before, unchanged
71
+ |
72
+ | a protected folder or a credential?
73
+ v
74
+ phiward's hook + the sandbox ---- refused -------> only the refusal and its reason
75
+ |
76
+ | work on protected data
77
+ v
78
+ The gateway (phiward run / copy)
79
+ a broker outside the agent runs the command
80
+ in a kernel sandbox, then masks the output ----> the command's output, names and
81
+ identifiers masked (so print
82
+ counts, not records)
83
+ ```
84
+
85
+ - **Two modes.** Mode A, the default: a normal Claude Code session (the desktop app, an IDE, a
86
+ terminal), wired by `phiward install claude`. Claude Code's own sandbox confines Bash; the file
87
+ tools are refused protected data and credentials by phiward's hook and by permission rules.
88
+ Mode B, the stronger one: `phiward launch` runs the whole agent tool in phiward's kernel
89
+ profile (macOS Seatbelt, Linux bubblewrap). Terminal only for now. See
90
+ [docs/modes.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/modes.md).
91
+ - **The gateway.** The agent works on protected data only through `phiward run -- CMD` and
92
+ `phiward copy`. The broker runs them outside the agent, as you, and masks the output:
93
+ protected paths, file names and identifiers become placeholders. HPC goes through
94
+ `phiward run --remote` and `phiward copy`, over your own shared SSH connection
95
+ ([docs/hpc.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/hpc.md)).
96
+ - **Git hooks** refuse commits that hold protected names or identifiers.
97
+
98
+ ## What it does not do
99
+
100
+ - Masking hides names and identifiers, not other content: through the gateway, print counts and
101
+ summaries, not records.
102
+ - Out of the box, masking inside file contents covers only sequence and alignment file names,
103
+ read names and loci (the `genomics` pack). Subject and sample identifiers inside files are
104
+ masked only with a pack that has them (the `msk` example), your own `[sanitize] patterns` or
105
+ `names_from`. The gateway masks entry names under the protected roots (4 characters or
106
+ longer). Planned for 0.2.0b2: setup asks, doctor warns, and the output says what was masked
107
+ ([#3](https://github.com/msk-access/phiward/issues/3),
108
+ [#5](https://github.com/msk-access/phiward/issues/5)).
109
+ - In Mode A, the file tools are refused inside Claude Code, not by the kernel; hooks and MCP
110
+ servers that are not wrapped run with your rights; credentials that are not files (the macOS
111
+ Keychain, some Kerberos caches, tokens in your environment) are not hidden by a file list.
112
+ - The network is open by default: an agent can send what it can read. In Mode A, `[network] limit`
113
+ (suggested by `phiward setup`) limits shell commands to listed hosts, so `git push` and `pip
114
+ install` fail until you list their hosts; WebFetch, MCP servers and Mode B stay open.
115
+ - Protection follows the path: protected data moved out of a protected folder is not protected.
116
+
117
+ [docs/threat-model.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/threat-model.md) lists every limit.
118
+
119
+ ## Documentation
120
+
121
+ **Use phiward**
122
+ - [Quick start](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/quickstart.md): install, set up, check (start here).
123
+ - [Daily use](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/daily-use.md): working with the agent on protected data; what to do when a
124
+ command is refused.
125
+ - [HPC](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/hpc.md), [plugins](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/plugins.md),
126
+ [agents with nobody watching](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/unattended.md), [Mode B: `phiward launch`](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/launch.md).
127
+ - [Setup in detail](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/setup.md), [configuration](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/configuration.md),
128
+ [glossary](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/glossary.md).
129
+
130
+ **Decide whether phiward is enough for your data**
131
+ - [Why phiward](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/why.md): what exists already, and the gap it fills.
132
+ - [The two modes](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/modes.md): what each one confines.
133
+ - [The threat model](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/threat-model.md): what is protected, what is not, every known
134
+ limit (a summary for reviewers comes first).
135
+
136
+ **Change phiward**
137
+ - [CONTRIBUTING.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/CONTRIBUTING.md) and [the developer guide](https://github.com/msk-access/phiward/blob/v0.2.0b1/docs/developer.md): set up,
138
+ run the tests, how a decision is made.
139
+ - [AGENTS.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/AGENTS.md): the rules for AI agents that work on phiward's code.
140
+
141
+ In a project that uses phiward, `phiward init` adds the rules for agents to that project's
142
+ `AGENTS.md` (the text is in [src/phiward/data/agents-section.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/src/phiward/data/agents-section.md)),
143
+ and [skills/phiward/SKILL.md](https://github.com/msk-access/phiward/blob/v0.2.0b1/skills/phiward/SKILL.md) is the skill.
144
+
145
+ ## Licence
146
+
147
+ AGPL-3.0-only. See [LICENSE](https://github.com/msk-access/phiward/blob/v0.2.0b1/LICENSE). Design credits are in [NOTICE](https://github.com/msk-access/phiward/blob/v0.2.0b1/NOTICE).
@@ -0,0 +1,53 @@
1
+ phiward/__init__.py,sha256=4ifzLzudKLlZ7HdcpKf9DUFgZ75zJ3U6qfDOdF0aENg,358
2
+ phiward/__main__.py,sha256=3et6zekkvim1B3-BImXTRsVqJa0wx3iW1GsALzeG_Ao,59
3
+ phiward/_toml.py,sha256=53j0ZQB_QIOt0_knMbBfSkm62ZGlOyDMikpT4asE3WE,7029
4
+ phiward/broker.py,sha256=FC3lpLY0Aasb2nLHV7EmfLRVF2MvyPZr56a4nhi2TiE,35761
5
+ phiward/carryover.py,sha256=kItx17OpHl1wNYvXekwghQEghuaADZGde5B7Li-hBUE,75750
6
+ phiward/claude_settings.py,sha256=wjD77n4QoWw32k5gf1RSfXq233z6VTrsbiDLAhLBmOw,64713
7
+ phiward/cli.py,sha256=nNXY0EY5tvpybFc0r438gkxcvAxhdTV0xe1tDxJOg8g,4700
8
+ phiward/config.py,sha256=yj39ipXLhw4753KKDjDf3ocHafRXJgLDT9MCAztQaI8,46587
9
+ phiward/confine.py,sha256=ukckdg7iv82BjXl9ZUI5SVk1BHCFOWFZ5EgkbWI9JOE,22334
10
+ phiward/copying.py,sha256=mgA6aj_H-AzPkp9ahJIpv4RZB9f8aVHc5Ey7VtqPrCU,24945
11
+ phiward/core.py,sha256=sMfRVVBXWQqnfU3eob8rixecIu9ThOUEKaiSZbgk08w,4172
12
+ phiward/doctor.py,sha256=-Y7oYBEpDrGH97sDbunz70yf9L08lt0bagBg4V2dDkk,63296
13
+ phiward/fasthook.py,sha256=R-Zp5-gv_ppO_Tbbs1U1LCKHfvG1bf0pJWyUgoXOhq8,2660
14
+ phiward/fsinfo.py,sha256=lthsTjt2WhaPMVCMoDC4bvxSdWNceArbIe7upmowBnI,9886
15
+ phiward/gateway.py,sha256=GgSRDSPnQzkwSEL0tvB1eUrHtUs43Ml1AiukSjljesg,7613
16
+ phiward/githooks.py,sha256=XCqFukXi2JF1M9Jwst5Rj0ZzjLOIfguXsDYu5B5j1oA,9403
17
+ phiward/hidden.py,sha256=g_KUcBTlyemItK4DZI3MLdiq_9JRRPWIWEjdwEvhZ2Y,14501
18
+ phiward/init.py,sha256=Ta26hJwhFLSX4TuKAcp3eOaoX8wKicML0fsVLqtaS-Y,6220
19
+ phiward/install.py,sha256=u7sqrSMcOEq1MtkKBvLNlep_iH0u-cnT4hXlu_ieaaQ,44120
20
+ phiward/inventory.py,sha256=bi-2gvp7xkmEnHWUsLIm6-hRYNtrcCvYP96G0q5gpMU,7210
21
+ phiward/mcp.py,sha256=87S_t6NAE592RMtdkNTIKqTd2Ge0RA3tYH2jnddY428,8274
22
+ phiward/mcp_config.py,sha256=jekYuDFBYlON7Gw42rIqOXXDhbaeXCKp7u04NX5tI9c,79012
23
+ phiward/names.py,sha256=GqSi5p2ArLLCjIGJWtxTDA7uD4AFm706-3WMb4ERF6U,267
24
+ phiward/pathid.py,sha256=Spjhq9cPqa7jWqsgmRkJEQLpyIg_22urHrSfxzMrQME,15160
25
+ phiward/pathmatch.py,sha256=l2iOIci9fajr0OhazejuOsySrMVm88w0aHfhX2A669Q,4006
26
+ phiward/paths.py,sha256=_AhQDSe6rNxO2bfi4LphsAPqEkecgFZLX16aF4Nq1cQ,39361
27
+ phiward/pin.py,sha256=q3hO0LQ5_VmpLBPz7I42jzFVqZS1CYBP7lt_-uw1XBg,9532
28
+ phiward/procinfo.py,sha256=ATNGp20ZDDOK92raH2NzowefuJI7DwCBME1Rlkuf4ck,2456
29
+ phiward/remote.py,sha256=3D3uz6NA1z1d-O9Nx0ZKK-lBKwN64iRM5kh6A7H1Iak,18793
30
+ phiward/run.py,sha256=StYytpGz_HGVG-B8qehisDKDs3L0GLww05AKTUqb-eE,36368
31
+ phiward/safeio.py,sha256=7mwhHO78XJsgodA-2E0-3CuEAzAi_enuQCHOeDgMvbs,3110
32
+ phiward/sanitize.py,sha256=ZrpKw1ZORpLkTGBSPymV0YdvIDUNgUTV9dCafka2qk0,34154
33
+ phiward/selfcheck.py,sha256=K6Wu9PvLk_6ral2dNDbOKCZ0f8k7Hs3JTl_M4zPxHQQ,64854
34
+ phiward/service.py,sha256=IKuZ0W2eymisfkPYfh9cFrEuHSv8x8625eOnGUTHYDI,14289
35
+ phiward/session_note.py,sha256=JK3mCUAW9lJJ30ibf7ep6mNxfUp-Buqsseh-MZNfCY8,4258
36
+ phiward/setup_cmd.py,sha256=gf0ImyLlamZqbDPSYHz3fkWirNkwnWNcY3uFGISZweg,43214
37
+ phiward/shell.py,sha256=SABmQBoPCKIpPuTL9hDURx3Yf9gHrKaKDxnNrFsfwGk,19384
38
+ phiward/wholetool.py,sha256=7gTUjgV5M5J7kHzzJtxGA7a6qZfz2OxDcmIyS7QdZt4,73072
39
+ phiward/adapters/__init__.py,sha256=oFG-CYVBZB_32YMDjgzdtJAVkyWWw3Xm3-WO_x99eJc,4728
40
+ phiward/adapters/claude.py,sha256=-qensX6aE32BFJrZLDlEXtv95KF_UbQmPJISs2TdaWY,24020
41
+ phiward/data/agents-section.md,sha256=Kg2V4-tTFKtyWxwb5H1Mn1SwlasRQZ0e0IqVvprhS-s,3064
42
+ phiward/guards/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ phiward/guards/protected_paths.py,sha256=rdurv3NnnsRCqrXAvIIYgqTNZYzFw42V0Ay8SjUupFE,57216
44
+ phiward/packs/dates.toml,sha256=fxfzD4ujS_LVVGPHKrURMTnV2XtSISoAVFjYtArt-FE,1021
45
+ phiward/packs/genomics.toml,sha256=3SXdL71sPcz82Im9oRRKrZxRSF2-hoL-pZAAWRwUqS8,2665
46
+ phiward/packs/msk.toml,sha256=1yya7l962O-lcaEw7fh03s4Iv_tjiN3zyv7N1Jyt904,1311
47
+ phiward-0.2.0b1.dist-info/licenses/LICENSE,sha256=jVa0BUaKrRH4erV2P5AeJ24I2WRv9chIGxditreJ6e0,34524
48
+ phiward-0.2.0b1.dist-info/licenses/NOTICE,sha256=DnoGyAckKffq6qdqjSqtt008iigI6vUwuvC0Y7iwMPc,905
49
+ phiward-0.2.0b1.dist-info/METADATA,sha256=WVpEIIRn6cGJIA_901Zvt6N-X8PO78ESd4ObFJAv7ws,8749
50
+ phiward-0.2.0b1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
51
+ phiward-0.2.0b1.dist-info/entry_points.txt,sha256=04qNfYdiAtQ-RnxmVJ1jZjtbCXHY2p8n1wXDBnYl51g,77
52
+ phiward-0.2.0b1.dist-info/top_level.txt,sha256=NfZS8sk7y2brpt105aj7HVpbY_l14iWr_dL-2eJD_PM,8
53
+ phiward-0.2.0b1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ agent-guards = phiward.cli:main
3
+ phiward = phiward.cli:main