This release is a pre-release and may not be stable for production use.
sycommon-python-lib
盛业 Python 公共库 — AI/LLM 生态(langchain/langgraph/deepagents/MCP/ACP/pi)的集成层 + 公司 Java starter jar 包的 Python 原生等价物。与 sycommon-go-lib 契约三端一致(同一 Java 上游、同一键名/键值/阈值/退避参数)。
安装(内网 Nexus):
pip install sycommon-python-lib -i http://192.168.2.174:8081/repository/pypy-group/simple/ --trusted-host 192.168.2.174
包结构
| 包 | 说明 |
|---|---|
sycommon/agent/ |
DeepAgents/多 Agent 团队/沙箱(HOME 泄露封堵+seatbelt)/ACP/sensitive·skill-write·sandbox-path 守卫中间件 |
sycommon/llm/ |
LLM 客户端封装、tiktoken 缓存、Langfuse/LangSmith |
sycommon/pi/ |
pi coding agent 移植 |
sycommon/alert/ |
分级告警(对齐 Java alert-sdk,见下) |
sycommon/logging/ |
Kafka 日志 + L1-L4 分级脱敏引擎 |
sycommon/rabbitmq/ |
MQ 客户端/延迟队列/审计存储(对齐 Java starter-mq) |
sycommon/synacos/ |
Nacos 注册/配置/Feign/BizReject |
sycommon/database/ |
MySQL/Redis/ES/分布式锁/TxnRef |
sycommon/config/ |
YAML 单例 + nacos 分层读(read_key_layered) |
sycommon/middleware/ |
CORS/Trace/上下文 |
sycommon/notice/ |
企微通知/进程监控 |
sycommon/xxljob/ |
XXL-Job + 分片广播 |
sycommon/tools/ |
audit/excel/tree/money/sso_token/usercache 等基础件 |
sycommon/services.py |
Services.plugins 统一装配入口(FastAPI 生命周期、默认挂载件) |
与 Java jar 包的对齐(分级告警/日志/MQ/基础件)
公司 Java starter/common jar 包(字节码反编译逐类对齐)的 Python 原生等价物。sycommon-go-lib 的对应包与这里契约三端一致(同一 Java 上游),跨语言互通按下列对照表核验:
分级告警 — sycommon/alert/ ↔ Java shengye-platform-alert-sdk(1.0.0-SNAPSHOT,47 类反编译)
| Java jar 组件 | Python 实现 | 说明 |
|---|---|---|
| AlertSdk 四级告警(fatal/critical/warn/info × title/detail/Throwable 重载矩阵) | alert/api.py:fatal/critical/warn/info + biz_*(templateNo 前置=BizAlertSdk) |
AlertAo 15 字段/优先级(fatal=100/critical=50/warn=20)/compareTo 排序序/hutool 4.6.1 JSON 序列化形态逐字段对齐 |
| InnerSdk 发送通道(批量投递/优先级队列) | alert/sdk.py + queue.py(BoundedAlarmQueue) |
队列满驱逐最低优先最旧、SelfCheck 自检通道、网关 URL 按 profile 路由(wsdev/wsuat1/prod)对齐 |
| AlertEnv 配置读取 | alert/env.py |
relaxed binding(SY_ALERT_MONITOR_ENABLE ↔ sy-alert.monitor.enable)/nacos 分层(read_key_layered)对齐 |
| GcMonitor(排除 young GC 的 GC 占比监控) | alert/monitor.py _gc_monitor_loop |
gc.callbacks start/stop 计时差累计(真·时间占比);阈值 falt 0.5/critical 0.2/warning 0.05;msg 模板逐字节同;告警 msg 追加分代窗口增量 (分代: gen0=+N ... /stats gen0=X)(Go 侧无分代概念,此为 Python 独有诊断增强) |
| DatasourceMonitor(连接池饱和度) | monitor.py register_db_stats + bridge.py |
SQLAlchemy engine.pool.status() 注入;阈值 0.7/0.8/0.95 与 4 字段 desc 对齐 |
| spring.factories 自动挂载 | services.py 生命周期 6.5 步 → bridge.init_alert_monitors() |
引入基础包即集成;sy-alert.monitor.enable 默认 false 零行为变化 |
分级日志脱敏 — sycommon/logging/ ↔ Java shengye-platform-starter-log 2.0.0-SNAPSHOT
| Java jar 组件 | Python 实现 | 说明 |
|---|---|---|
| MaskEngine/MaskUtil L1-L4 分级脱敏 | logging/mask_engine.py + log_masker.py |
快照构建/levels 解析/shouldMask 状态机/慢告警/nacos 热更新(MaskConfigRefresher 同款 reload 回调);len≤7 全 x/全串匹配/逐键分层三锚点 |
| LogModel 三方 29 字段表 | logging/kafka_log.py |
pSpanId/pAgentId 等逐字段对齐;msg 819200/detail 102400 双限长分离;getFormattedMessage 解包对齐 |
| Kafka 日志投递 | logging/bounded_kafka_sink.py |
有界队列治 loguru enqueue 无界 OOM;信封与 Java starter-log 平台侧契约一致 |
MQ — sycommon/rabbitmq/ + synacos/ ↔ Java shengye-platform-starter-mq(1.0.0-SNAPSHOT,22 类逆向)
| Java jar 组件 | Python 实现 | 说明 |
|---|---|---|
| 消费失败告警 MqAlertHelper | alert/mq_alert.py |
Redis SETNX 限频(mq:alert:throttle:{topic},300s)/topic 维度/manualFlag 不进计数链 |
| BizRejectException(588) | synacos/feign.py BizRejectError |
588 业务拒绝语义化;必须在 except Exception 之前放行(语义化拒绝不被兜底吞掉) |
| 消费重投退避 RabbitAwareBeanPostProcessor | rabbitmq/delay_queue.py |
20s/×5/120s cap(可配 MQ_RETRY_BACKOFF_MS);DLX/retry-wait 档位拓扑 |
| MqHelperDao/MqRetryThread | rabbitmq/mq_store.py |
tk_mq_msg 持久化 + 重试线程,自动建表 DDL 同款;无 DB/Redis 静默降级纯直发 |
| FeignRequestInterceptor | synacos/feign.py |
token 重签(reqSource=服务名/全键 ALWAYS/password 剥离/username 派生/时间格式归一)+ inner=1 |
| 消费 ACK 语义/header/traceId 契约 | rabbitmq/rabbitmq_client.py 等 |
handler 成功后 ack + Redis 计数重试;SSOUser 消费链路恢复 |
Java 基础件九件套(与 go-lib α.65 同基线)
| Java 上游 | Python 实现 |
|---|---|
| starter-redis DistributedLock | database/distlock.py(锁键前缀 dstc:lock: 三端统一;Lua 值相等才删) |
| common-web TxnRefUtils | database/txnref.py |
| common-web AuditUtils.log | tools/audit.py |
| common-core ExcelHelper | tools/excel.py |
| common-core TreeUtils | tools/tree.py |
| starter-task ShardingUtils | xxljob/sharding.py |
| CrossTenantContext | models/ 跨租户上下文 |
| common-web 用户缓存 | tools/usercache.py |
| common-core MoneyUtils | tools/money.py(金额大写) |
对齐方法论:Java 侧以字节码反编译为唯一事实源,逐常量池/逐分支核对;每项对齐后跑对抗复审。历史轮次见 git log(
Java/jar关键词):0.2.10a11 信封字段、a15/a17 feign 重签 + MQ 全量、a22 GC 真实时长占比。sycommon-go-lib(infra/alert/、infra/logs/mask_engine.go、infra/rabbitmq/、infra/redis/{distlock,txnref,usercache}.go、core/{excel,tree,money}.go等)与这里共享同一 Java 基线,跨语言契约(键前缀/阈值/退避参数/信封字段)变更时三端同步。
Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? Use the template at the bottom!
Add your files
- Create or upload files
- Add files using the command line or push an existing Git repository with the following command:
cd existing_repo
git remote add origin http://git.syf.com/syai/sycommon-python-lib.git
git branch -M main
git push -uf origin main
Integrate with your tools
Collaborate with your team
- Invite team members and collaborators
- Create a new merge request
- Automatically close issues from merge requests
- Enable merge request approvals
- Automatically merge when pipeline succeeds
Test and Deploy
Use the built-in continuous integration in GitLab.
- Get started with GitLab CI/CD
- Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)
- Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy
- Use pull-based deployments for improved Kubernetes management
- Set up protected environments
Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to makeareadme.com for this template.
Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
Name
Choose a self-explaining name for your project.
Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
License
For open source projects, say how it is licensed.
Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Metadata
Release files for sycommon-python-lib 0.2.12a23
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sycommon_python_lib-0.2.12a23.tar.gz | 3.8 MB | Without provenance | Details for sycommon_python_lib-0.2.12a23.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sycommon_python_lib-0.2.12a23-py3-none-any.whl | Python 3 | none | any | Details for sycommon_python_lib-0.2.12a23-py3-none-any.whl |
Total release size: 7.6 MB
Release files / sycommon_python_lib-0.2.12a23.tar.gz
| Download URL | sycommon_python_lib-0.2.12a23.tar.gz |
|---|---|
| Size | 3.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b56b690c8b3381f1c7b753cff3fe587494b00d989649591133dcfb1843830306
|
|
BLAKE2b-256 checksum How to use checksums |
05ef75b818d97b31e86bee79a0f074a6181aa148c45fd7404bbaa0fa1cbdb5c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / sycommon_python_lib-0.2.12a23-py3-none-any.whl
| Download URL | sycommon_python_lib-0.2.12a23-py3-none-any.whl |
|---|---|
| Size | 3.9 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1ca6307e7d62a28d55d6a5fd48dc2b9ce3974e1bd652e533c27ed5686f0c4d9e
|
|
BLAKE2b-256 checksum How to use checksums |
b38759d0f44fdae2403f5171ded1697124a666cb014d97b23e58664ab78b2120
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for sycommon-python-lib 0.2.12a23
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.