feat(services): register workflow-native driver keys in field registry
Workflow reconciliation (see previous commit) showed the 20261022
state variable really stores person identity under driver{i}ID /
driver{i}Phonenumber (x2), while the API get_info group keys
(sfzmhm{i}/sjhm{i}) have zero references in any workflow version -
the legacy group read always returned empty for workflow-produced data.
- registry: +4 keys (driver1/2ID, driver1/2Phonenumber) in
human1/human2 groups, SENSITIVE, documented as synonymous with
sfzmhm{i}/sjhm{i}; 24 -> 28 specs
- driver{i}License deliberately NOT registered: the sandbox reads
state.hphm{i} and only renames the output for confirmation prompts -
it is not a state key, set_info rejects it as unknown (workflow
never consumes it)
- intentional diff documented: acdhuman1/2 group output now includes
the driver keys (legacy FastGPT output did not) - fixes the legacy
'workflow person data unreadable by group' gap; synonym merging
(driver1ID vs sfzmhm1) deferred pending caller confirmation
- tests: registry size 28, driver keys present with sensitive level,
License alias excluded
Verified: 230 unit tests
This commit is contained in:
@@ -56,12 +56,23 @@
|
|||||||
### 对账发现的一个真实差异
|
### 对账发现的一个真实差异
|
||||||
|
|
||||||
20261022 workflow 的 `state` 变量中人员信息键为
|
20261022 workflow 的 `state` 变量中人员信息键为
|
||||||
`driver1ID / driver1License / driver1Phonenumber`(×2),
|
`driver1ID / driver1Phonenumber`(×2,sandbox 另把 `hphm1/2`
|
||||||
|
车牌改名 `driver{i}License` 输出给确认提示词——该名不是 state 键),
|
||||||
与 API `get_info` 分组键(`sfzmhm1/sjwh1/sjhm1` 等)**不同名**。
|
与 API `get_info` 分组键(`sfzmhm1/sjwh1/sjhm1` 等)**不同名**。
|
||||||
旧 FastGPT 实现按 API 分组键读 state,这些键在 workflow state 中
|
旧 FastGPT 实现按 API 分组键读 state,这些键在 workflow state 中
|
||||||
本就读空——属于既有行为。新后端注册表沿用了 API 契约键
|
本就读空——属于既有行为。
|
||||||
(保证 get/set_info 自洽),workflow 侧键名差异已列入审计:
|
|
||||||
若线上有调用方依赖 `driver1ID` 等键,需决定是否补登记别名。
|
**处理(2026-10-22 已落地)**:注册表把 workflow 原生键
|
||||||
|
`driver{i}ID / driver{i}Phonenumber`(×2,同义 sfzmhm/sjhm)
|
||||||
|
登记进 human1/human2 分组——
|
||||||
|
- set/get_info 单键直读写 driver 系键与旧 API 行为一致;
|
||||||
|
- **有意差异**:`acdhuman1/2` 分组输出现包含 driver 系键
|
||||||
|
(旧 FastGPT 分组输出没有它们)。调用方按 JSON 取键,多键无害;
|
||||||
|
这修正了旧实现"workflow 真实人员数据无法分组读到"的问题;
|
||||||
|
- `driver{i}License` 非 state 键,对其 set_info 按未知键拒绝
|
||||||
|
(workflow 不消费它);
|
||||||
|
- 同义键(driver1ID vs sfzmhm1)暂不合并:合并需调用方确认
|
||||||
|
实际使用侧后作为后续优化,已列入审计项。
|
||||||
|
|
||||||
## 待审计项(作业 6-7 要求的后续工作)
|
## 待审计项(作业 6-7 要求的后续工作)
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,21 @@ def _human_fields(index: int) -> list[FieldSpec]:
|
|||||||
FieldSpec(f"sjhm{index}", group, str, True, SensitiveLevel.SENSITIVE, f"{side}手机号码"),
|
FieldSpec(f"sjhm{index}", group, str, True, SensitiveLevel.SENSITIVE, f"{side}手机号码"),
|
||||||
FieldSpec(f"sjwh{index}", group, str, True, SensitiveLevel.PUBLIC, f"{side}手机文号"),
|
FieldSpec(f"sjwh{index}", group, str, True, SensitiveLevel.PUBLIC, f"{side}手机文号"),
|
||||||
FieldSpec(f"csbw{index}", group, str, True, SensitiveLevel.PUBLIC, f"{side}常熟部位/身份标识"),
|
FieldSpec(f"csbw{index}", group, str, True, SensitiveLevel.PUBLIC, f"{side}常熟部位/身份标识"),
|
||||||
|
# workflow 原生键(对账发现,见 docs/assignment6-compat.md):
|
||||||
|
# state 变量中真实读写的人员身份键,与上方 API 契约键同义并存:
|
||||||
|
# driver{i}ID ~= sfzmhm{i}(身份证明号码)、
|
||||||
|
# driver{i}Phonenumber ~= sjhm{i}(手机号码)。
|
||||||
|
# 注意:workflow Code Sandbox 输出的 driver{i}License 是提示词
|
||||||
|
# 输出别名(源数据为 state.hphm{i}),并非 state 键,故不登记——
|
||||||
|
# 对它 set_info 会按未知键拒绝。
|
||||||
|
FieldSpec(
|
||||||
|
f"driver{index}ID", group, str, True, SensitiveLevel.SENSITIVE,
|
||||||
|
f"{side}驾驶员身份证明号码(workflow 原生键,同义 sfzmhm{index})",
|
||||||
|
),
|
||||||
|
FieldSpec(
|
||||||
|
f"driver{index}Phonenumber", group, str, True, SensitiveLevel.SENSITIVE,
|
||||||
|
f"{side}驾驶员手机号码(workflow 原生键,同义 sjhm{index})",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ from src.services.fields_registry import (
|
|||||||
def test_registry_covers_all_three_groups():
|
def test_registry_covers_all_three_groups():
|
||||||
"""注册表完整覆盖 acd/human1/human2 三个分组(作业 6-3)。"""
|
"""注册表完整覆盖 acd/human1/human2 三个分组(作业 6-3)。"""
|
||||||
assert set(GROUP_KEYS) == set(FieldGroup)
|
assert set(GROUP_KEYS) == set(FieldGroup)
|
||||||
assert len(FIELD_REGISTRY) == 24
|
assert len(FIELD_REGISTRY) == 28
|
||||||
assert len(GROUP_KEYS[FieldGroup.ACD]) == 8
|
assert len(GROUP_KEYS[FieldGroup.ACD]) == 8
|
||||||
assert len(GROUP_KEYS[FieldGroup.HUMAN1]) == 8
|
assert len(GROUP_KEYS[FieldGroup.HUMAN1]) == 10
|
||||||
assert len(GROUP_KEYS[FieldGroup.HUMAN2]) == 8
|
assert len(GROUP_KEYS[FieldGroup.HUMAN2]) == 10
|
||||||
|
|
||||||
|
|
||||||
def test_person_fields_include_full_set():
|
def test_person_fields_include_full_set():
|
||||||
@@ -33,6 +33,17 @@ def test_person_fields_include_full_set():
|
|||||||
assert f"{suffix}{index}" in group_keys
|
assert f"{suffix}{index}" in group_keys
|
||||||
|
|
||||||
|
|
||||||
|
def test_workflow_native_driver_keys_registered():
|
||||||
|
"""workflow 20261022 state 原生人员键(对账发现)已登记,
|
||||||
|
与 API 契约键同义并存;driver1License 是 sandbox 输出别名而非
|
||||||
|
state 键,不登记。"""
|
||||||
|
for index in (1, 2):
|
||||||
|
assert f"driver{index}ID" in FIELD_REGISTRY
|
||||||
|
assert f"driver{index}Phonenumber" in FIELD_REGISTRY
|
||||||
|
assert FIELD_REGISTRY[f"driver{index}ID"].sensitive is SensitiveLevel.SENSITIVE
|
||||||
|
assert f"driver{index}License" not in FIELD_REGISTRY
|
||||||
|
|
||||||
|
|
||||||
def test_registry_metadata_recorded():
|
def test_registry_metadata_recorded():
|
||||||
"""每个字段都记录类型、可写性、敏感级别(作业 6-4)。"""
|
"""每个字段都记录类型、可写性、敏感级别(作业 6-4)。"""
|
||||||
for spec in FIELD_REGISTRY.values():
|
for spec in FIELD_REGISTRY.values():
|
||||||
|
|||||||
Reference in New Issue
Block a user