feat(roles): implement F100 dedicated roles/ namespace for agent role discovery#357
Merged
pocky merged 1 commit intoMay 28, 2026
Merged
Conversation
… discovery - `.gitignore`: add AWF storage state/log directories - `.zpm/kb/default/knowledge.pl`: add project ZPM knowledge base with schema, Go constitution rules, and project memory schema - `.zpm/kb/feedback/journal.wal`: initialize feedback segment WAL - `.zpm/kb/feedback/knowledge.pl`: add feedback rules schema with applicable/effective_rules helpers - `.zpm/mounts.json`: mount feedback memory segment - `CHANGELOG.md`: document F100 breaking changes and migration guide for AWF_AGENTS_PATH → AWF_ROLES_PATH - `CLAUDE.md`: add ZPM project memory workflow section - `README.md`: update Agent Roles feature description with new roles/ namespace paths - `docs/reference/error-codes.md`: update MISSING_ROLE resolution paths to roles/ namespace - `docs/user-guide/agent-steps.md`: update discovery paths, env var name, and add by-name vs explicit path section - `docs/user-guide/workflow-syntax.md`: update role path example to custom-roles/ - `internal/application/loop_executor_core_test.go`: replace unused params with _ in StepExecutorFunc tests - `internal/application/plugin_service_interface_test.go`: strengthen composite interface test to exercise delegation - `internal/application/role_loader_test.go`: add tests for by-name/path resolution, BuildRoleSystemPrompt, and template interpolation - `internal/domain/workflow/agent_role.go`: add AgentRoleSizeWarnBytes constant, RawSizeBytes field, and IsPathRef to AgentRoleNotFoundError - `internal/infrastructure/roles/doc.go`: add package documentation for roles infrastructure adapter - `internal/infrastructure/roles/filesystem_repository.go`: rename AWF_AGENTS_PATH → AWF_ROLES_PATH, switch to roles/ namespace paths, expose RawSizeBytes and use shared constant - `internal/infrastructure/roles/filesystem_repository_test.go`: update tests for roles/ paths, add legacy path rejection and namespace collision tests, use testutil.ChdirIsolated - `internal/infrastructure/skills/filesystem_repository.go`: extract skillSizeWarnBytes constant, fix nil-ignoring UserHomeDir calls, add empty-path filter for candidates - `internal/infrastructure/skills/filesystem_repository_test.go`: add TestLoad_NameValidation for backslash rejection, use fmt.Appendf - `internal/infrastructure/xdg/xdg.go`: rename AWFAgentsDir/LocalAgentsDir → AWFRolesDir/LocalRolesDir, add roles_dir to AWFPaths, fix UserHomeDir error handling - `internal/infrastructure/xdg/xdg_roles_dir_test.go`: add dedicated tests for AWFRolesDir and LocalRolesDir - `internal/infrastructure/xdg/xdg_test.go`: add roles_dir assertions to AWFPaths tests - `internal/interfaces/cli/validate.go`: add agentRoleCombinedPromptWarnBytes constant, refactor validate command - `internal/interfaces/cli/validate_helpers_test.go`: add unit tests for validate helper functions - `internal/interfaces/cli/validate_role_test.go`: update test role paths to roles/ namespace - `internal/testutil/env.go`: add ChdirIsolated helper for safe directory-changing in tests Closes #356
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
roles/namespace for agent role discovery, replacing the oldagents/directories — roles now live under.awf/roles/,.agents/roles/,$XDG_CONFIG_HOME/awf/roles/, and~/.agents/roles/instead of the flat.awf/agents/and.agents/paths from F098AWF_AGENTS_PATHtoAWF_ROLES_PATH, making the roles and skills namespaces structurally symmetric and preventing ambiguous cross-namespace discovery collisionsRawSizeBytestoAgentRoleso the CLI validator avoids a secondos.Statcall, and promotes the 500KB threshold to a named constant (AgentRoleSizeWarnBytes) shared between the infrastructure loader and the validatordefaultandfeedbackmemory segments) with the project's constitution rules, architecture integrity checks, and queryable feedback schema, wiring them as auto-mounted project segmentsChanges
Domain
internal/domain/workflow/agent_role.go: AddAgentRoleSizeWarnBytesconstant,RawSizeBytesfield onAgentRole, andIsPathRefflag onAgentRoleNotFoundErrorfor cleaner error disambiguation in the validatorInfrastructure — Roles
internal/infrastructure/roles/filesystem_repository.go: Switch fromAWF_AGENTS_PATH/.awf/agents/.agentstoAWF_ROLES_PATH/.awf/roles/.agents/roles; setIsPathRef: trueinLoadFromPath; useAgentRoleSizeWarnBytesconstant; populateRawSizeBytes; addcrossClientGlobalRolesDir()internal/infrastructure/roles/filesystem_repository_test.go: Update all fixture paths toroles/namespace; addTestLoad_AWFRolesPathOverride(including negative case assertingAWF_AGENTS_PATHis ignored),TestLoad_OldAgentsPathNotFound,TestLoad_SkillsRoleNoCollision; replace manualos.Chdir/defer os.Chdirwithtestutil.ChdirIsolatedinternal/infrastructure/roles/doc.go: New file — package-level architecture overview for the roles adapterInfrastructure — Skills
internal/infrastructure/skills/filesystem_repository.go: ExtractskillSizeWarnBytesconstant (intentionally decoupled from roles); filter empty candidates before appending paths; fixcrossClientGlobalSkillsDir/claudeGlobalSkillsDirto return""onUserHomeDirerror; align path-traversal guard to useContainsAny("/\\")internal/infrastructure/skills/filesystem_repository_test.go: AddTestLoad_NameValidationcovering backslash rejection; usefmt.Appendfin two existing testsInfrastructure — XDG
internal/infrastructure/xdg/xdg.go: RenameAWFAgentsDir→AWFRolesDir,LocalAgentsDir→LocalRolesDir; guardConfigHome/DataHomeagainstUserHomeDirerrors returning""instead of"/.config"; exposeroles_dirkey inAWFPaths()internal/infrastructure/xdg/xdg_roles_dir_test.go: New file — tests forAWFRolesDir(XDG priority chain,AWF_CONFIG_HOMEoverride) andLocalRolesDir(structural parity withLocalSkillsDir)internal/infrastructure/xdg/xdg_test.go: Assertroles_dirkey inAWFPathstestsApplication
internal/application/role_loader_test.go: Add 11 new tests coveringResolveAgentRolepath-vs-name semantics (FR-008/FR-009),BuildRoleSystemPromptcomposition, template resolution, nil-repo, nil-role fallback, and error propagation pathsCLI Interface
internal/interfaces/cli/validate.go: PromoteagentRoleCombinedPromptWarnBytesto named constant; passctxintovalidateRoleRefsinstead of creating a newcontext.Background()inside; extractroleContentWarningshelper; replaceroleDirExistsWithoutAgentsMDheuristic withIsPathRefflag; emit user-oriented role-not-found messages without exposing internal search pathsinternal/interfaces/cli/validate_role_test.go: Update all fixtures toroles/namespace; addtestutil.ChdirIsolatedcalls; add assertions verifying thatagents/paths do not appear in error messages; passcontext.Background()explicitlyinternal/interfaces/cli/validate_helpers_test.go: New file — unit tests for the extractedroleContentWarningshelperTest Utilities
internal/testutil/env.go: New file —ChdirIsolated(t, dir)helper that changes to a directory and restores the original working directory viat.Cleanup, eliminating the manualdefer os.Chdir(origDir)pattern repeated across ~12 test functionsZPM Knowledge Base
.zpm/kb/default/knowledge.pl: New file — base schema (task graph, component graph, ADR, feedback, integrity violations) and Go constitution rules (hexagonal layer checks, panic detection, coverage thresholds).zpm/kb/feedback/knowledge.pl: New file — queryable feedback segment schema (rule/5,trigger/3,applicable/2, helper aggregations).zpm/kb/feedback/journal.wal: New file — empty WAL for feedback segment.zpm/mounts.json: Registerfeedbacksegment as auto-mounted alongsidedefaultDocumentation & Config
CHANGELOG.md: Add F100 breaking-changes section with migration guide for all renamed paths and the env variable renameCLAUDE.md: Add ZPM project memory usage guide (segment table, read/write query examples, category index)README.md: Update Agent Roles bullet to describe theroles/namespace andAWF_ROLES_PATHdocs/reference/error-codes.md: UpdateUSER.INPUT.MISSING_ROLEresolution steps to useroles/paths andAWF_ROLES_PATHdocs/user-guide/agent-steps.md: Update directory structure examples, search-path table (4 entries, renamed env var), add Role Resolution by-name vs explicit-path guidance tabledocs/user-guide/workflow-syntax.md: Updaterole:field description path example.gitignore: Add.awf/storage/states/and.awf/storage/logs/Test Cleanup
internal/application/loop_executor_core_test.go: Replace named-but-unused parameters with_inStepExecutorFuncliterals to satisfy linterinternal/application/plugin_service_interface_test.go: Strengthen composite interface assertion to exercise delegated methods at runtime rather than compile-time onlyTest plan
make build && make lint && make testpass with zero violationsAWF_ROLES_PATH=/tmp/custom-roles awf run <workflow-with-role>resolves roles exclusively from the override path; roles under.awf/roles/are not consulted.awf/agents/go-senior/→.awf/roles/go-senior/and runningawf validate <workflow>reports valid; leaving it at the old path producesErrRoleNotFoundawf validateerror message for a missing role contains the role name but does not expose internal filesystem search paths (e.g. no.awf/roles/missing-rolein output)Closes #356
Generated with awf commit workflow