larry-zy commented on PR #1611:
URL: https://github.com/apache/dubbo-admin/pull/1611#issuecomment-6380449987

   **[P2] Bind rolling-summary ownership to the Session, not the first caller**
   
   Reviewed head: `04fe99de21c734e1deb2d5cf8e8be85b8a7401cc`.
   
   The existing ownership concern also causes summary advancement to stop after 
an authorized actor change. In 
[`ai/component/memory/summary/service.go:192–195`](https://github.com/apache/dubbo-admin/blob/04fe99de21c734e1deb2d5cf8e8be85b8a7401cc/ai/component/memory/summary/service.go#L192-L195),
 a new summary takes the caller's identity, while subsequent updates retain the 
original identity:
   
   ```go
   v := store.Summary{TenantID: a.Subject.TenantID, OwnerID: a.Subject.UserID, 
SessionID: id, SchemaVersion: store.SummarySchemaVersion, TemplateVersion: 
TemplateVersion, Model: cfg.Model}
   if old != nil {
       v = *old
   }
   ```
   
   Meanwhile, [`ValidateSummaryCommit` in 
`ai/store/summary.go:339`](https://github.com/apache/dubbo-admin/blob/04fe99de21c734e1deb2d5cf8e8be85b8a7401cc/ai/store/summary.go#L333-L340)
 rejects the update when `v.OwnerID != a.Subject.UserID`. A summary is thus 
effectively tied to the first actor, even though Session authorization permits 
another same-tenant actor with `ai:sessions:admin`.
   
   I reproduced both actor-switch directions through the Summary Service with 
Memory and GORM/SQLite: an authorized administrator first advances a user-owned 
Session's summary, which is stored with `OwnerID=admin`. After more terminal 
history arrives, the actual Session owner calls `Advance`. The retained 
administrator owner fails commit validation, producing 
`SUMMARY_COMMIT_CONFLICT` and `Backlog=true`; coverage stays at 2 while the 
target is 4. Repeating as that owner cannot advance the summary. Owner-first 
followed by administrator access fails the same way. Both backends produce the 
same conflict on repeated attempts and use the shared commit validator.
   
   This is independently reproducible through the Summary Service/Store 
contract. The separate Compiler authorization problem in #1610 currently masks 
this administrator path in ReAct, so fixing #1610 alone will not resolve it.
   
   Please obtain `TenantID`/`OwnerID` from trusted Session metadata, keep actor 
identity separate, and validate summary ownership against the Session rather 
than the caller. Add owner-to-administrator and administrator-to-owner 
advancement tests. This needs a functional fix, beyond correcting attribution 
metadata.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to