Skip to content

Refactor skill and workflow generation with required bootstrap - #56

Merged
ainetx merged 3 commits into
mainfrom
requried-prompt-modules
Jun 26, 2026
Merged

Refactor skill and workflow generation with required bootstrap#56
ainetx merged 3 commits into
mainfrom
requried-prompt-modules

Conversation

@ainetx

@ainetx ainetx commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Implement a required bootstrap unit for generated skills and workflows to ensure proper execution of runtime rules and enhance PDSL handling. This change streamlines the execution process and improves protocol management.

Summary by CodeRabbit

  • New Features
    • Generated agent/workflow shims now prepend a standard bootstrap unit before transferring control to the target.
    • Shims and routing now support the newer LOAD and RUN ... as controlling protocol flow, with the legacy follow-based format retained as a fallback.
  • Bug Fixes
    • Improved ownership detection and stale-artifact cleanup for generated agent/workflow files.
  • Documentation
    • Updated PDSL execution semantics and CLI/generation contracts; added/expanded required bootstrap documentation.
  • Tests
    • Expanded assertions to validate bootstrap/control-protocol markers and runtime memory activation.

ainetx added 2 commits June 25, 2026 16:25
…workflows

Signed-off-by: ainetx <viator@via-net.org>
…handling

Signed-off-by: ainetx <viator@via-net.org>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 81957018-b63e-4d6f-aab2-c74c6e0d8c8a

📥 Commits

Reviewing files that changed from the base of the PR and between d84bc6e and 2d6b353.

📒 Files selected for processing (2)
  • skills/studio/scripts/studio/commands/agents.py
  • tests/test_subagent_registration.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/test_subagent_registration.py
  • skills/studio/scripts/studio/commands/agents.py

📝 Walkthrough

Walkthrough

Generated agent shims now prepend a required bootstrap unit, use LOAD and RUN as the controlling-protocol transfer syntax, and update runtime specs, target detection, cleanup, and tests to match the new protocol shape.

Changes

Generated bootstrap and control protocol

Layer / File(s) Summary
Generated entrypoint bootstrap contract
architecture/features/agent-integration.md, architecture/specs/PDSL.md, architecture/specs/cli.md
Generated skill/workflow entrypoints now require a prepended bootstrap unit, and LOAD and RUN <target> is defined as the controlling-protocol transfer syntax with ALWAYS open and follow kept as a fallback.
Required bootstrap and PDSL execution rules
skills/studio/modules/runtime/required-bootstrap.md, skills/studio/modules/runtime/pdsl-execution-card.md
The new RequiredBootstrap spec loads runtime modules and memory capabilities in order, and the execution card revises continuation handling and semantic strictness rules.
Generated shim emission and template context
skills/studio/scripts/studio/commands/agents.py
Agent shim generation now emits GeneratedBootstrapUnit before GeneratedFollowProtocol and passes required_bootstrap_path into workflow and skill templates.
Target extraction, ownership, and cleanup
skills/studio/scripts/studio/commands/agents.py
New helpers recognize controlling-protocol targets, derive studio-owned targets, and update pure-generated detection, install detection, proxy renaming, stale alias cleanup, and legacy workflow command cleanup.
Protocol regression coverage
tests/test_agents_coverage.py, tests/test_subagent_registration.py, tests/test_ralphex_delegation.py
Coverage updates now expect LOAD and RUN markers, add _extract_studio_control_target cases, and adjust generated follow-protocol ordering and delegation assertions.
Generated artifact bootstrap checks
tests/test_cli_integration.py, tests/test_workflow_subagents_dispatch.py
Generated SKILL.md files are now checked for bootstrap/control-protocol markers, and the required bootstrap spec is verified to load context memory, content memory, and resource context memory.

Sequence Diagram(s)

sequenceDiagram
  participant cfs_generate_agents as cfs generate-agents
  participant GeneratedBootstrapUnit
  participant RequiredBootstrap
  participant GeneratedFollowProtocol
  participant skill_workflow_shim as skill/workflow shim
  cfs_generate_agents->>GeneratedBootstrapUnit: prepend bootstrap unit
  GeneratedBootstrapUnit->>RequiredBootstrap: LOAD and RUN required-bootstrap.md
  GeneratedBootstrapUnit->>GeneratedFollowProtocol: LOAD and RUN <target> as controlling protocol
  GeneratedFollowProtocol->>skill_workflow_shim: transfer execution to target
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • constructorfabric/studio#14: Both PRs adjust the same generated follow-protocol block and the matching assertions in agents.py and tests/test_subagent_registration.py.
  • constructorfabric/studio#16: Both PRs change the same protocol-block generation path in agents.py, including the ordering and content of the emitted workflow instructions.

Poem

I hopped through shims at dawn's first gleam,
and nibbled LOAD and RUN by stream.
Bootstrap warmed my cotton paws,
while protocols obeyed the laws.
Thump-thump—Studio dreams!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 51.35% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: generated skills and workflows now use a required bootstrap.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch requried-prompt-modules

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
tests/test_agents_coverage.py (1)

4265-4280: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add positive coverage for all accepted managed control-target prefixes.

Line 4265-4280 only validates {cf-studio-path}/ and unmanaged relative paths. _extract_studio_control_target also accepts @/ and absolute /; adding those cases will better lock the contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_agents_coverage.py` around lines 4265 - 4280, Add positive test
coverage for the other accepted managed control-target prefixes in
TestExtractStudioControlTarget so _extract_studio_control_target is verified for
every supported form. Keep the existing checks for "{cf-studio-path}/" and
unmanaged relative paths, and add tests that assert it returns the expected
target for "`@/`..." and absolute "/..." inputs. This should live alongside the
current _extract_studio_control_target tests in the same unittest class.
skills/studio/scripts/studio/commands/agents.py (1)

2659-2659: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated required-bootstrap path into a module constant.

The literal {cf-studio-path}/.core/skills/studio/modules/runtime/required-bootstrap.md is repeated in three render contexts. A single constant keeps these in sync and matches the SonarCloud finding.

♻️ Suggested constant
+_REQUIRED_BOOTSTRAP_PATH = (
+    "{cf-studio-path}/.core/skills/studio/modules/runtime/required-bootstrap.md"
+)

Then reference _REQUIRED_BOOTSTRAP_PATH at Lines 2659, 2851, and 3966.

Also applies to: 2851-2851, 3966-3966

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/studio/scripts/studio/commands/agents.py` at line 2659, The
required-bootstrap path literal is duplicated across multiple render contexts,
so extract it into a single module-level constant in agents.py and reuse that
constant wherever the path is referenced. Define the shared value once (for
example as _REQUIRED_BOOTSTRAP_PATH) and replace the inline string in the render
inputs around the agent setup, ensuring the references in the relevant render
paths all point to the same constant.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/studio/modules/runtime/required-bootstrap.md`:
- Around line 15-18: The bootstrap ordering in the required bootstrap sequence
is wrong because CommandResolution runs before template-variable support is
loaded, so {cfs_cmd} may remain unresolved. Update the bootstrap flow around the
LOAD/RUN steps in the required bootstrap to load template-vars.md before
invoking CommandResolution, keeping context-memory loading in the appropriate
order afterward.

In `@skills/studio/scripts/studio/commands/agents.py`:
- Around line 179-212: The generated-protocol matcher is rebuilding the
bootstrap block with a placeholder instead of the rendered bootstrap path, so
`_pure_generated_stub_matches()` no longer matches the emitted shim from
`_render_template()`. Update `_follow_protocol_lines()` and the matching logic
in `_pure_generated_stub_matches()` to use the same concrete
`required_bootstrap_path` value that `agents.py` renders for
`GeneratedBootstrapUnit`, ensuring the expected multi-line stub matches the
actual generated protocol text and idempotent cleanup works again.

---

Nitpick comments:
In `@skills/studio/scripts/studio/commands/agents.py`:
- Line 2659: The required-bootstrap path literal is duplicated across multiple
render contexts, so extract it into a single module-level constant in agents.py
and reuse that constant wherever the path is referenced. Define the shared value
once (for example as _REQUIRED_BOOTSTRAP_PATH) and replace the inline string in
the render inputs around the agent setup, ensuring the references in the
relevant render paths all point to the same constant.

In `@tests/test_agents_coverage.py`:
- Around line 4265-4280: Add positive test coverage for the other accepted
managed control-target prefixes in TestExtractStudioControlTarget so
_extract_studio_control_target is verified for every supported form. Keep the
existing checks for "{cf-studio-path}/" and unmanaged relative paths, and add
tests that assert it returns the expected target for "`@/`..." and absolute "/..."
inputs. This should live alongside the current _extract_studio_control_target
tests in the same unittest class.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 25f3b9c7-dbc2-41bd-bb35-5bde46ae2c92

📥 Commits

Reviewing files that changed from the base of the PR and between 3b4f7cb and d84bc6e.

📒 Files selected for processing (11)
  • architecture/features/agent-integration.md
  • architecture/specs/PDSL.md
  • architecture/specs/cli.md
  • skills/studio/modules/runtime/pdsl-execution-card.md
  • skills/studio/modules/runtime/required-bootstrap.md
  • skills/studio/scripts/studio/commands/agents.py
  • tests/test_agents_coverage.py
  • tests/test_cli_integration.py
  • tests/test_ralphex_delegation.py
  • tests/test_subagent_registration.py
  • tests/test_workflow_subagents_dispatch.py

Comment thread skills/studio/modules/runtime/required-bootstrap.md
Comment thread skills/studio/scripts/studio/commands/agents.py
@ainetx
ainetx merged commit 68e4e86 into main Jun 26, 2026
21 checks passed
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant