Skip to content

Commit 3e20ed1

Browse files
committed
fix(model): 语义比较恢复含展示层——文案变化需写入(e2e 契约链路回归)
CI e2e 红灯:@safe-auto-merge 期望 summary 改为 premium 后 proposal 反映新文案——no-op 跳过把展示层排除后,纯文案变化 的重注册不再写契约,proposal 永不更新。 平衡语义:比较含 Summary/Description/Tags(文案变化写入); schema canonical / JSONMap 零值归一保持(同内容跳过)。 幽灵 stale 不受影响:页面 freshness 从不比较展示层。 配套:JS/Python demo summary 兜底对齐 functionID(与 Go/ Java 一致),消除六语言默认文案轮换导致的无关写。
1 parent fc21578 commit 3e20ed1

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

internal/model/function_contract_model.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ func (m *FunctionContractModel) UpsertContract(ctx context.Context, contract *Fu
4848
return db.Save(contract).Error
4949
}
5050

51-
// contractSemanticallyEqual 只比较影响页面契约/治理/执行判断的实质
52-
// 字段(schema 用 canonical JSON——键序/空格差异不算变化)。
53-
// 展示层字段(Summary/Description/Tags)不参与:六语言 SDK 的默认
54-
// 文案不同,轮流注册会轮换这些字段——不构成"契约变化",不应触发
55-
// 重写与下游 freshness 扰动。Diagnostics 属注册期质检快照同理。
51+
// contractSemanticallyEqual 比较契约全部字段(含展示层 Summary/
52+
// Description/Tags——文案变化需要写入,e2e 契约链路依赖 proposal
53+
// 反映新文案);schema 用 canonical JSON(键序/空格形态差异不算
54+
// 变化——六语言 SDK 各自序列化同 schema 字节不同),JSONMap 走
55+
// 零值归一(nil 与 {required:false} 等价)。Diagnostics 属注册期
56+
// 质检快照,轮换不构成契约变化,不参与。
5657
func contractSemanticallyEqual(a, b *FunctionContract) bool {
5758
if a == nil || b == nil {
5859
return false
@@ -68,6 +69,9 @@ func contractSemanticallyEqual(a, b *FunctionContract) bool {
6869
strings.TrimSpace(a.Permission) == strings.TrimSpace(b.Permission) &&
6970
a.Source == b.Source &&
7071
jsonMapEqual(a.Approval, b.Approval) &&
72+
jsonMapEqual(a.Summary, b.Summary) &&
73+
jsonMapEqual(a.Description, b.Description) &&
74+
bytes.Equal(canonicalJSON(a.Tags), canonicalJSON(b.Tags)) &&
7175
bytes.Equal(canonicalJSON(a.InputSchema), canonicalJSON(b.InputSchema)) &&
7276
bytes.Equal(canonicalJSON(a.OutputSchema), canonicalJSON(b.OutputSchema))
7377
}

sdks/js/examples/game_demo.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ function mailClaim(store: DemoStore): FunctionHandler {
385385

386386
function enrichDescriptor(desc: FunctionDescriptor): FunctionDescriptor {
387387
const tags = desc.tags || ([desc.resource, desc.operation].filter(Boolean) as string[]);
388+
// 与 Go/Java demo 对齐:summary 兜底 functionID,避免各语言默认
389+
// 文案不同导致契约展示字段在重注册时轮换。
390+
desc.summary = desc.summary || desc.id;
388391
return {
389392
...desc,
390393
tags,

sdks/python/examples/game_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def enrich_descriptor(desc: FunctionDescriptor) -> FunctionDescriptor:
697697
if not desc.tags:
698698
desc.tags = [value for value in (desc.resource, desc.operation) if value]
699699
if not desc.summary:
700-
desc.summary = f"{desc.resource or 'function'} {desc.operation or 'invoke'}"
700+
desc.summary = desc.id
701701
if not desc.description:
702702
desc.description = (
703703
f"Demo function {desc.id} for {desc.resource or 'unscoped'} {desc.operation or 'invoke'} operations."

0 commit comments

Comments
 (0)