Skip to main content

a207-policy

A207 统一身份注入 / 权限矩阵 / 状态路径策略包(Plan A 单一事实源)。

13 个 MCP 统一依赖本包,取代原先散落在 M1/M2/M4/M11/M13 的多份权限副本。

用法

from a207_policy import get_caller, enforce_read, enforce_write, LIS_READ_FULL

def get_labs(patient_id: str) -> dict:
    caller = get_caller()                 # 来自 env A207_CALLER,模型碰不到
    enforce_read("a207-lis-mcp")          # 确定性拒绝越权(fail-closed)
    ...
  • 身份注入:A207_CALLER 环境变量由部署配置写入,模型无法自证(修复 P0-1)。
  • 测试:from a207_policy import set_caller; set_caller("doctor_assistant")。
  • 状态路径:from a207_policy import resolve_state_path; resolve_state_path("followup_store.json") 落到 A207_DATA_DIR 或系统临时目录,避免只读安装目录崩溃(修复 P1-3)。
值 对应角色 能干什么(举例)
doctor_assistant 医生助手 全量读写、写化验、生成报告
parent_assistant 家长助手 只看受限视图(没有原始数值)
nutritionist 营养师 出食谱、算目标
child_companion 患儿伙伴 打卡、科普、简单记录
orchestrator 编排层 调度所有服务
risk_warning 风险预警 发预警通知

魔搭社区添加环境变量如下

弹窗字段 应该填什么 详细说明
变量名 A207_CALLER (必填) 必须与 Python 代码中 os.environ.get('A207_CALLER') 的键名完全一致
描述 调用方身份标识 写给人类看的备注信息,方便你自己或别人理解这个变量是干嘛的
详细指引 (可留空) 如果有特殊格式要求可以写提示,没有就留空
是否必填 建议开启(拨到必填) 如果缺少这个变量 Python 代码会报错退出,就开启必填
类型 string 保持默认的 string 即可
测试值 parent_assistant (最关键!) 魔搭容器运行时真正注入的值,直接填你的实际业务值
弹窗字段 应该填什么 详细说明
变量名 A207_DATA_DIR (必填) 必须与 Python 代码中 os.environ.get('A207_DATA_DIR') 的键名完全一致
描述 数据存储路径 写给人类看的备注信息,方便你自己或别人理解这个变量是干嘛的
详细指引 (可留空) 如果有特殊格式要求可以写提示,没有就留空
是否必填 建议开启(拨到必填) 如果缺少这个变量 Python 代码会报错退出,就开启必填
类型 string 保持默认的 string 即可
测试值 /data/a207 (最关键!) 魔搭容器运行时真正注入的值,直接填你的实际业务值

但是在云函数条件下,大概率是没有权限写/data目录的,可以改为/tmp/a207

Metadata

Release files for a207-policy 0.3.65

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a207-policy 0.3.65
File Size Uploaded
a207_policy-0.3.65.tar.gz 79.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a207-policy 0.3.65
File Interpreter ABI Platform
a207_policy-0.3.65-py3-none-any.whl Python 3 none any Details

Total release size: 131.9 kB

Release files / a207_policy-0.3.65.tar.gz

Download URL a207_policy-0.3.65.tar.gz
Size 79.0 kB
Tags Source
SHA-256 checksum
How to use checksums
30849322b50f3009566714c606af225087cffb7982dd152f00c353d7cbb51f84
BLAKE2b-256 checksum
How to use checksums
27110934db80b1d2f62d6872c55371eb26ebf77d6f86144b0dd87fdee4deab49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release files / a207_policy-0.3.65-py3-none-any.whl

Download URL a207_policy-0.3.65-py3-none-any.whl
Size 52.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d63a9be7a8ab91c3064ef056dcbc46ad134989f6b1655fefee3a54e9e9d11bb
BLAKE2b-256 checksum
How to use checksums
08c776199617d353813347187dc14ec9d4607bf78ee74a08d010ee898e6b1df8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.66

2 release files

This release

0.3.65 This release

2 release files

0.3.64

2 release files

0.3.63

2 release files

0.3.62

2 release files

0.3.61

2 release files

0.3.60

2 release files

0.3.59

2 release files

0.3.57

2 release files

0.3.56

2 release files

0.3.55

2 release files

0.3.54

2 release files

0.3.53

2 release files

0.3.52

2 release files

0.3.48

2 release files

0.3.47

2 release files

0.3.46

2 release files

0.3.44

2 release files

0.3.43

2 release files

0.3.42

2 release files

0.3.41

2 release files

0.3.40

2 release files

0.3.39

2 release files

0.3.38

2 release files

0.3.36

2 release files

0.3.35

2 release files

0.3.34

2 release files

0.3.33

2 release files

0.3.32

2 release files

0.3.31

2 release files

0.3.30

2 release files

0.3.29

2 release files

0.3.28

2 release files

0.3.27

2 release files

0.3.26

2 release files

0.3.25

2 release files

0.3.24

2 release files

0.3.23

2 release files

0.3.22

2 release files

0.3.21

2 release files

0.3.20

2 release files

0.3.19

2 release files

0.3.18

2 release files

0.3.17

2 release files

0.3.16

2 release files

0.3.15

2 release files

0.3.14

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.11

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page