Bug: shared SOP can retain private direct role dependencies
Problem
The main branch allows a shared SOP to reference a role that is private but owned by the SOP's source project. The existing SOP sharing validation accepts this same-project binding, but a cross-project consumer cannot use that role because it is not shared.
This behavior predates PR #478. PR #478 reuses the existing SOP sharing boundary when an AI scheduled task directly references an SOP; it does not recursively change SOP dependency sharing.
Evidence from the pre-PR baseline
The behavior is present in the parent of the scheduled-task feature commit (030435d), before PR #478 added scheduled-task sharing:
internal/httpapi/catalog.goalready containedvalidateWorkflowAgentScopes. Its rule accepted a role when the role belonged to the SOP project, even whenagent.Shared == false; only a role from another project had to be shared.- The workflow save path already required a shared SOP to use an already-shared sandbox. It validated the sandbox state, but did not automatically share the SOP's bound roles or their assets.
- There was no SOP sharing function that called
ShareAgentorShareAgentAssetsfor roles referenced by SOP nodes.
PR #478 moved these existing validations into internal/repo/catalog_sharing.go and added ShareWorkflow as a reusable entry point. ShareWorkflow calls ValidateWorkflowAgentScopes and ValidateWorkflowSharing, then saves the SOP; it does not call ShareAgent for SOP node roles.
Current behavior
- A source project has a private role.
- An SOP in that project binds the role and uses an otherwise shareable sandbox.
- The SOP can be shared because the role belongs to the SOP project.
- A consumer project using the shared SOP cannot execute the role because the role itself is still private.
The behavior has been reproduced against the shared-schedule path with the following result:
publish err=<nil>
after publish: sop.Shared=true agent.Shared=false
subscriber admission err=共享任务使用的角色不属于当前项目且尚未共享
This creates a mismatch between SOP publication validation and cross-project execution visibility. The mismatch is an existing SOP sharing-model gap; the scheduled-task PR exposes it by adding a cross-project consumer path.
Expected behavior to decide
Define the sharing boundary for SOP direct dependencies. Possible policies include:
- sharing an SOP also shares its direct project-owned role dependencies through the existing role sharing path; or
- publishing an SOP for cross-project use rejects private direct role dependencies with a clear validation error.
The follow-up implementation should remain in the SOP/catalog sharing layer rather than adding a second recursive dependency-sharing implementation to AI scheduled tasks.
Related PR: #478
Thanks for the report.
I understand this as a shared SOP still being allowed to depend on a private role owned by the source project, so a cross-project consumer cannot run that role even though the SOP itself is shared. The note also says this sharing boundary was already there before PR #478, and that publication and cross-project execution currently do not agree on whether the role is visible.
This has been seen and will be reviewed along with the existing issues.
Thanks for documenting this. I’d like to take this issue. I reproduced it with two projects: I published a scheduled task whose SOP used a shared sandbox and a role private to the source project. Publication succeeded, but the subscribing project could not start the SOP because the role was still private.
Would the maintainers be comfortable requiring directly referenced roles to be shared before the SOP itself can be shared? If a role is still private, the error would name it and ask the author to share it first. This would follow the existing rule for sandboxes and leave the decision to share each role with its owner.
I also checked that explicitly sharing the role lets the subscribing project pass the same run admission check. If this matches the intended behavior, I’ll open a PR with the catalog change and regression tests for both the rejection and the successful retry.
Thanks for reproducing and taking a look at this issue.
I agree that this should be fixed in the SOP/catalog sharing layer rather than in AI scheduled tasks. My preference is to reuse the existing sharing entry points for direct dependencies instead of requiring users to manually share them beforehand.
This is also consistent with the sharing model used across the platform: when an object is shared, it delegates the sharing of its direct dependencies to their own sharing logic. The upper layer only handles its immediate dependencies, while each dependency remains responsible for its own direct dependencies.
Therefore, when sharing an SOP, the implementation should delegate each directly referenced role to its own sharing logic. The role sharing logic can then handle its directly bound assets through the existing path. The SOP sharing code should not independently traverse or reimplement nested dependency sharing, and scheduled task sharing should continue to call the SOP sharing logic only.
Keeping this behavior consistent across the platform is preferable to introducing a special rule for SOPs. Additional preflight or improved error messaging can be considered as a separate follow-up feature.
Thanks for clarifying the intended behavior, @HFUTcoder. I’ll update the SOP/catalog sharing path to call the existing role-sharing logic for each directly referenced role. Each role will handle its own rules and skills, and scheduled tasks will continue to delegate to the SOP. I’ll add a regression test that publishes from one project and starts the shared SOP from another, then link the PR here.
@HFUTcoder, the fix is ready for review in #1283. The new regression test publishes a scheduled task from one project and runs its SOP to completion from a second project with the mock executor. It also checks that the subscriber can resolve the role’s rule and skill. Thanks again for clarifying how sharing should work.