Skip to content

Add a worktree-proximity reference application #104

Description

@ScriptedAlchemy

Summary

Add an examples/ application that proves Agent Bundle can support custom
request hooks, context providers, cross-process topology state, semantic event
routes, RSC guidance, and directed notices without baking collision logic or a
daemon into framework core.

This is intentionally a demanding application example, not a request for
useWorktree, topology inference, dependency-overlap analysis, or collision
policy in framework core.

Scenario

One root task has two child agents in separate Git worktrees. Each begins
working on files whose dependency or path sets overlap. Application code—not
the framework—detects proximity and warns both actors through the delivery
routes their hosts support.

Example structure

examples/worktree-proximity/
  agent-bundle.config.ts
  src/
    providers/
      git-worktree.ts
      agent-topology.ts
    state.ts
    events/
      session/start.tsx
      agent/start.tsx
      tool/before.tsx
      tool/after.tsx
      stop.tsx
    domain/
      proximity.ts
    mcp/
      coordinator/tools/status.tsx
  tests/

The example authors custom APIs from framework primitives:

export const worktree = async (): Promise<WorktreeContext> =>
  (await agent()).providers.gitWorktree;

export const useWorktree = (): WorktreeContext =>
  useAgent().providers.gitWorktree;

The proximity evaluator remains ordinary application code:

export default async function BeforeTool() {
  const { actor, event, providers, notices } = await agent();
  const conflicts = await findProximity(
    providers.agentTopology.snapshot,
    providers.gitWorktree,
    event,
  );

  await Promise.all(conflicts.map((conflict) =>
    notices.publish({
      recipient: { actorId: conflict.actorId },
      content: <Agent.Warning>{conflict.summary}</Agent.Warning>,
    }),
  ));

  return conflicts.length === 0
    ? null
    : <Agent.Warning>{conflicts[0].summary}</Agent.Warning>;
}

Evidence boundary

The deterministic suite uses generated host adapters, two real child hook
processes, separate Git worktrees, and one durable local state driver. It is an
artifact/contract integration test, not proof that an external commercial host
actually dispatched the events.

Optional native smoke runs remain separately authorized and evidence-labelled.

Required journeys

  1. Observe a root actor and two child actors with explicit parent provenance.
  2. Associate each actor with a distinct worktree and current activity.
  3. Record non-overlapping work and emit no warning.
  4. Record overlapping path/dependency intent and warn the current actor.
  5. Publish a notice for the other actor.
  6. Deliver that pending notice on the other actor's next event when no native
    directed-message API exists.
  7. Deduplicate repeated native events.
  8. Mark parent identity unavailable for a fixture whose host does not expose it
    and refuse to fabricate a topology edge.
  9. Restart all hook processes and retain topology/notices through durable
    storage.

Acceptance criteria

  • The example contains no framework-private imports or handwritten host JSON.
  • Custom worktree() and useWorktree() APIs are implemented solely through
    the public context-provider contract.
  • Two independent processes share exact state revisions without a daemon.
  • Collision logic is isolated in the example domain module.
  • Current and remote-recipient warnings use the real Agent Document and notice
    projectors.
  • Unsupported identity/delivery states are visible and tested.
  • The scaffold documents the external-driver boundary. It claims external
    integration only if a real adapter is connected and passes the state-driver
    conformance suite; a disconnected example is not presented as integrated.

Design references

Stack position

Full meta-framework stack

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthost-integrationAgent host capabilities, projection, discovery, and lifecyclemeta-frameworkAgent Bundle compiler-coupled meta-frameworkruntimeRuntime context, state, rendering, or executiontestingFramework test harnesses and integration evidence

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions