@alvarolorentedev/opencode-taskfeed 0.0.0-stage → 0.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +431 -2
  3. package/docs/architecture.md +123 -0
  4. package/docs/configuration.md +123 -0
  5. package/docs/development.md +312 -0
  6. package/docs/integrations.md +84 -0
  7. package/docs/operations.md +136 -0
  8. package/docs/releases/v0.1.0-alpha.1.md +164 -0
  9. package/docs/security.md +120 -0
  10. package/examples/README.md +7 -0
  11. package/examples/approvals/README.md +27 -0
  12. package/examples/flowgraph/config.yaml +28 -0
  13. package/examples/flowgraph/opencode.jsonc +14 -0
  14. package/examples/headless/README.md +25 -0
  15. package/examples/headless/config.yaml +21 -0
  16. package/examples/native-agent/config.yaml +31 -0
  17. package/examples/native-agent/opencode.jsonc +10 -0
  18. package/examples/playground/README.md +61 -0
  19. package/examples/playground/config.yaml +40 -0
  20. package/examples/playground/opencode.jsonc +5 -0
  21. package/package.json +89 -4
  22. package/src/config/load.ts +122 -0
  23. package/src/config/repository.ts +72 -0
  24. package/src/config/schema.ts +215 -0
  25. package/src/core/approval.ts +190 -0
  26. package/src/core/comments.ts +175 -0
  27. package/src/core/index.ts +5 -0
  28. package/src/core/ports.ts +185 -0
  29. package/src/core/state.ts +186 -0
  30. package/src/core/types.ts +430 -0
  31. package/src/executors/flowgraph/client.ts +27 -0
  32. package/src/executors/flowgraph/executor.ts +593 -0
  33. package/src/executors/flowgraph/lazy.ts +77 -0
  34. package/src/executors/flowgraph/rpc.ts +145 -0
  35. package/src/executors/flowgraph/worker.ts +538 -0
  36. package/src/executors/native/bridge.ts +421 -0
  37. package/src/executors/native/executor.ts +295 -0
  38. package/src/executors/native/prompt.ts +57 -0
  39. package/src/executors/native/trust.ts +105 -0
  40. package/src/index.ts +116 -0
  41. package/src/rpc.ts +75 -0
  42. package/src/runtime/backends.ts +27 -0
  43. package/src/runtime/engine.ts +2345 -0
  44. package/src/runtime/server-backends.ts +136 -0
  45. package/src/runtime/service.ts +276 -0
  46. package/src/sources/github/client.ts +98 -0
  47. package/src/sources/github/source.ts +490 -0
  48. package/src/storage/capacity.ts +223 -0
  49. package/src/storage/jobs.ts +249 -0
  50. package/src/storage/locks.ts +342 -0
  51. package/src/tui.tsx +399 -0
  52. package/src/util/ids.ts +18 -0
  53. package/src/util/logger.ts +52 -0
  54. package/src/util/process.ts +119 -0
  55. package/src/util/redact.ts +28 -0
  56. package/src/version.ts +2 -0
  57. package/src/workspaces/native.ts +162 -0
  58. package/src/workspaces/publication.ts +477 -0
@@ -0,0 +1,136 @@
1
+ # Operations and recovery
2
+
3
+ ## Startup
4
+
5
+ - Taskfeed loads as an OpenCode server plugin at each location.
6
+ - Only the canonical checkout attempts scheduler ownership.
7
+ - Multiple sessions, clients or worktrees therefore converge on one owner.
8
+ - Worktree locations run an observer and, when Flowgraph is present, a location RPC worker.
9
+ - Nothing runs when automation is disabled, but durable job state remains.
10
+
11
+ ## Headless operation
12
+
13
+ OpenCode unloads idle locations by default. A plugin cannot retain a location by itself. For persistent headless operation:
14
+
15
+ ```jsonc
16
+ {
17
+ "experimental": { "location_idle_timeout": false }
18
+ }
19
+ ```
20
+
21
+ Start the server and activate the repository location once:
22
+
23
+ ```sh
24
+ opencode serve
25
+ opencode api POST /api/session \
26
+ --data '{"location":{"directory":"/absolute/path/to/repo"}}'
27
+ ```
28
+
29
+ A session is only used to activate the location; it does not need a prompt or a model call. If the location is evicted, the scheduler stops. Taskfeed does not claim to monitor unactivated repositories.
30
+
31
+ ## Scheduler ownership
32
+
33
+ A local lease keyed by project ID + canonical checkout is stored outside the checkout (runtime/temp directory). Acquisition uses an atomic directory create; stale takeover and release are serialized by a breaker; heartbeat updates an open file descriptor so an old owner cannot touch a replacement lease. A former owner checks the lease before dispatching, prompt submission, approval forwarding, workflow observation and publication. On loss it stops.
34
+
35
+ Only the canonical checkout can acquire the lease or run a tick. Worktree observers reject all scheduler controls with an actionable error; they never dispatch, retry or enable automation locally.
36
+
37
+ Supported boundary: one local OpenCode server/user on one machine. Cross-host exactly-once execution is not supported. Local state is source of truth for execution ownership; GitHub is source of truth for requirements and decisions.
38
+
39
+ ## Global capacity
40
+
41
+ Capacity slots are file-backed and shared across projects in the local server boundary. Every adoption, heartbeat, ambiguous mark and release is serialized by a capacity mutex and fenced by token+generation, so a former owner cannot overwrite a newer adoption. A slot is created before workspace/session admission and released only after confirmed completion, confirmed cancellation or proven rejection before admission. Timeouts, missing sessions/runs, failed cancellation and lost provider responses retain the slot in `ambiguous` state. Adopting an existing slot requires explicit recovery and increments its generation.
42
+
43
+ - Awaiting external approval: capacity released, workspace retained.
44
+ - Native permission pending: capacity retained.
45
+ - Ambiguous session/run admission or provider outage: capacity retained in `ambiguous` state; do not expect timeout-based release.
46
+ - Approval that resumes execution: capacity acquired first; otherwise the decision is persisted and forwarded later.
47
+
48
+ `globalConcurrency` defaults to 1.
49
+
50
+ ## Restart behavior
51
+
52
+ On restart Taskfeed observes rather than replays:
53
+
54
+ - Existing worktrees and branches are never reset.
55
+ - Recorded native sessions/Flowgraph runs are reused.
56
+ - Native session recovery requires metadata for the exact job, attempt and worktree. A recovered session without a persisted prompt message is resubmitted with the same deterministic message ID, so a prompt that was already accepted is never duplicated.
57
+ - A starting job with no execution reference tries provider recovery; if it cannot prove admission, it blocks.
58
+ - A running job with an unprovable outcome blocks instead of launching a duplicate.
59
+ - Existing capacity obligations are adopted with a new generation; old tokens cannot heartbeat or release them.
60
+ - Native completion is tied to the latest prompt message; the previous turn's success cannot complete a newly submitted rework.
61
+ - Queued Flowgraph worker requests expire and are cancellable. Immediately before admission the worker rechecks the live lease, generation, claim, job/run identity and capacity. A worker restart does not revive an expired or cancelled request.
62
+ - Dirty worktrees are preserved and block publication/cleanup.
63
+
64
+ A blocked job exposes the recovery action in the TUI. Use retry only when the blocker says it is safe, or cancel and inspect the worktree.
65
+
66
+ ## Failure recovery actions
67
+
68
+ | Blocker | Action |
69
+ |---|---|
70
+ | `permission_pending` | Resolve the native permission in the session; Taskfeed resumes observation. |
71
+ | `publication_disabled` | Enable publication and retry; or accept local-only. |
72
+ | `publication_failed` | Fix remote/auth/scan failure and use retry to publish the existing completed session. |
73
+ | `dirty_worktree` | Review/commit manually; retry publication. |
74
+ | `remote_artifact_missing` (Flowgraph) | Publish the workflow PR through the workflow's own publication step, or expose a typed content artifact for plan review. Taskfeed rechecks. |
75
+ | `remote_sha_mismatch` | Update the PR or rerun explicitly. |
76
+ | `decision_stale` | Wait for a fresh gate and decide the new revision. |
77
+ | `review_artifact_changed` | The PR/draft state, worktree HEAD, content digest or original approval comment changed. Review the current artifact and start a fresh review; the old decision is not replayed. |
78
+ | `trusted_context_changed` | Worktree executable policy, agent definitions or plugins no longer match the canonical snapshot. Restore them and start a fresh workflow; the run is cancelled. |
79
+ | `decision_precheck_failed` | No provider side effect occurred. Taskfeed rechecks the persisted decision/artifact before forwarding. |
80
+ | `decision_forward_ambiguous` | The provider may have admitted the decision. Capacity is retained; inspect the provider and do not replay automatically. |
81
+ | `execution_ambiguous` / `provider_error` | Inspect the native session/run; cancel or explicitly retry only after proving state. |
82
+ | `workspace_isolation_failed` | The run was cancelled; inspect Flowgraph and fix location/plugin configuration. |
83
+
84
+ ## Cleanup
85
+
86
+ Workspace cleanup is explicit and only for completed/cancelled/failed jobs. Taskfeed checks:
87
+
88
+ - the directory is in OpenCode's worktree inventory;
89
+ - it is not the canonical checkout;
90
+ - it is clean (no uncommitted/untracked work);
91
+ - the branch is Taskfeed-owned.
92
+
93
+ It removes the worktree with `force: false` and retains the branch/commits. Dirty or user-managed worktrees are never deleted.
94
+
95
+ ## Logs
96
+
97
+ Taskfeed logs structured events to the OpenCode server console with `taskfeed:` prefixes. Secrets and credential-like values are redacted. TUI warnings expose the latest actionable failures. Stable job IDs and issue numbers correlate events.
98
+
99
+ ## Verification
100
+
101
+ ```sh
102
+ bun run typecheck
103
+ bun run test
104
+ bun run verify:pack
105
+ ```
106
+
107
+ Opt-in real tests are split by scope:
108
+
109
+ ```sh
110
+ bun run test:real:native
111
+ bun run test:real:flowgraph
112
+ ```
113
+
114
+ The native suite starts real OpenCode services with controlled temporary repositories and a deterministic mock OpenAI-compatible model that performs real file edits and commits. Native restart coverage uses a killed process and genuine stale-lease recovery; it does not delete locks. It does not require Flowgraph.
115
+
116
+ The Flowgraph suites resolve the Flowgraph plugin from `../opencode-flowgraph` or `FLOWGRAPH_PLUGIN`. The plan-review test demonstrates the current upstream blocker: Flowgraph executes a real planning agent, but its public human gate does not expose a typed content artifact, so Taskfeed blocks instead of inferring a plan from prose.
117
+
118
+ A separately gated real GitHub mutation suite is available but is not run without explicit authorization:
119
+
120
+ ```sh
121
+ RUN_REAL_GITHUB=1 \
122
+ TASKFEED_TEST_REPOSITORY=owner/disposable-repo \
123
+ TASKFEED_GITHUB_ALLOWLIST=owner/disposable-repo \
124
+ bun run test:real:github
125
+ ```
126
+
127
+ The suite refuses the production Taskfeed repository, requires an exact allowlist match, and cleans up its test issue, label (if created), branch and PR. It is reported as pending until actually executed.
128
+
129
+ ## Troubleshooting
130
+
131
+ - **RPC unavailable after install:** restart OpenCode; verify the plugin entry is visible from the canonical and worktree locations.
132
+ - **Scheduler leader false:** another OpenCode instance owns the project or a stale lease is still within its expiry; inspect the TUI warning/log.
133
+ - **Flowgraph unavailable:** ensure Flowgraph is configured and visible in the worktree, not only the canonical checkout.
134
+ - **Flowgraph worker inactive:** commit plugin config/workflow files and/or install plugins globally. Taskfeed fails closed.
135
+ - **Publication blocked:** check remote credentials, branch fast-forward state, clean worktree, protected paths/secrets and PR head SHA.
136
+ - **No jobs:** automation disabled, config invalid, GitHub auth/permission failure, no ready label, or ready label applied by an unauthorized account.
@@ -0,0 +1,164 @@
1
+ # Taskfeed v0.1.0-alpha.1
2
+
3
+ Taskfeed turns authorized GitHub issues into isolated OpenCode agent work. This
4
+ first public prerelease validates the native OpenCode workflow without Flowgraph.
5
+
6
+ ## Product purpose
7
+
8
+ Taskfeed discovers GitHub issues marked with a configured ready label, verifies
9
+ that an authorized user applied the label, runs an existing OpenCode agent in an
10
+ isolated Git worktree, publishes a draft pull request when enabled, and relays an
11
+ authorized GitHub approval or rework decision back to the same native session.
12
+
13
+ Taskfeed does not define agents, models, prompts, provider credentials or a
14
+ workflow engine. It uses the existing OpenCode runtime and keeps scheduler,
15
+ capacity, publication and approval state in local Taskfeed storage.
16
+
17
+ ## Supported native workflow
18
+
19
+ - GitHub issue discovery and enqueue authorization.
20
+ - Stateful job records with durable recovery.
21
+ - Native OpenCode agent execution in an isolated worktree.
22
+ - Native TUI status and controls.
23
+ - Optional draft pull request publication.
24
+ - GitHub approval and rework against the exact reviewed commit.
25
+ - Headless `opencode serve` operation.
26
+ - Flowgraph is not required and is not installed by these instructions.
27
+
28
+ ## Installation
29
+
30
+ Use the explicit prerelease version until a stable `latest` exists:
31
+
32
+ ```jsonc title="opencode.jsonc"
33
+ {
34
+ "plugins": [
35
+ "@alvarolorentedev/opencode-taskfeed@0.1.0-alpha.1"
36
+ ]
37
+ }
38
+ ```
39
+
40
+ Restart OpenCode after changing the plugin configuration. Taskfeed creates
41
+ worktrees, so the plugin must also be visible from worktree locations. A global
42
+ install is the simplest option; a committed `opencode.jsonc` works for a project.
43
+
44
+ ## Configuration example
45
+
46
+ Create `.taskfeed/config.yaml` in the canonical repository:
47
+
48
+ ```yaml
49
+ version: 1
50
+
51
+ source:
52
+ type: github
53
+ repository: auto
54
+ labels:
55
+ - agent-ready
56
+
57
+ execution:
58
+ type: agent
59
+ name: build
60
+
61
+ scheduler:
62
+ enabled: false
63
+ poll_interval_seconds: 60
64
+ concurrency: 1
65
+
66
+ workspace:
67
+ isolation: worktree
68
+
69
+ limits:
70
+ max_attempts: 2
71
+ max_feedback_iterations: 3
72
+ execution_timeout_seconds: 14400
73
+ retry_backoff_seconds: 30
74
+
75
+ approvals:
76
+ provider: github
77
+ authorized_users:
78
+ - your-github-login
79
+ enqueue_users:
80
+ - your-github-login
81
+
82
+ publication:
83
+ enabled: false
84
+ remote: origin
85
+ draft_pull_request: true
86
+ branch_prefix: taskfeed/
87
+ ```
88
+
89
+ Automation and publication are disabled by default. Enable them explicitly in
90
+ `.taskfeed/config.yaml` or through the Taskfeed TUI once the repository and
91
+ identities are correct.
92
+
93
+ A complete disposable-repository example is in
94
+ [`examples/playground`](../../examples/playground).
95
+
96
+ ## First test
97
+
98
+ 1. Create a disposable repository and add the configuration above.
99
+ 2. Authenticate `gh` for that repository and start OpenCode in the canonical
100
+ checkout.
101
+ 3. Create an issue asking for a small README change.
102
+ 4. Apply `agent-ready` from an authorized enqueue user.
103
+ 5. Enable automation explicitly.
104
+ 6. Observe the isolated worktree, the committed change and the draft pull
105
+ request.
106
+ 7. Run `/taskfeed request-changes <gate-id> <revision>` to verify rework, then
107
+ `/taskfeed approve <gate-id> <revision>` on the new gate.
108
+
109
+ ## Security and permission boundaries
110
+
111
+ - A ready label alone is not authorization. The actor must be a configured
112
+ enqueue user, and the label event is persisted as admission evidence.
113
+ - Native OpenCode permissions remain authoritative. Taskfeed never auto-approves
114
+ a permission request.
115
+ - Worktrees provide file isolation, not a sandbox.
116
+ - Publication is explicit opt-in, draft-only, and pushes only the exact
117
+ validated Taskfeed branch SHA.
118
+ - External decisions are bound to the repository, issue, gate, revision, exact
119
+ reviewed artifact and authorized GitHub identity. Edited, stale, replayed and
120
+ unauthorized commands are rejected.
121
+ - Configuration, agents and trusted execution context come from the canonical
122
+ checkout, not from a worktree.
123
+ - Taskfeed never merges, deploys or approves its own work.
124
+
125
+ ## Experimental Flowgraph status
126
+
127
+ Flowgraph remains available but is experimental in this prerelease. It is not
128
+ required for installation or for the supported native workflow. Flowgraph plan
129
+ approval stays fail-closed until the upstream public API exposes a typed content
130
+ artifact and a per-node admission/policy hook. Do not treat Flowgraph's complete
131
+ SDLC integration as production-ready.
132
+
133
+ ## Known limitations
134
+
135
+ - No automatic merge or deployment.
136
+ - Native agents must commit their changes and leave the worktree clean.
137
+ - One scheduler owner is supported per local machine; cross-host exactly-once
138
+ execution is not promised.
139
+ - Approval edit detection uses GitHub REST second precision.
140
+ - Worktrees are not a security sandbox.
141
+ - The internal publication scanner is a conservative denylist, not a complete
142
+ secret-scanning product.
143
+ - No interactive TUI verification is claimed by this release note.
144
+ - The opt-in real GitHub mutation suite requires an explicitly authorized
145
+ disposable repository and was not run for this release.
146
+
147
+ ## Verification
148
+
149
+ Recorded 2026-11-30 against the release tree:
150
+
151
+ - `bun install --frozen-lockfile` → pass.
152
+ - `bun run check` → version consistency, typecheck and 111 passed / 5 skipped.
153
+ - `bun run build` → version consistency and typecheck pass.
154
+ - `bun run verify:pack` with `OPENCODE_BIN` set to OpenCode 2.3.2 → packed tarball installed cleanly, exports and dependencies verified, plugin loaded without Flowgraph, runtime version `0.1.0-alpha.1`, automation disabled.
155
+ - A clean working-tree copy (no `node_modules` or `.git`) → `bun install --frozen-lockfile`, version check and `verify:pack` pass.
156
+ - `bun run test:real:native` → 2 passed with the deterministic mock provider: native worktree execution and restart recovery, plus draft PR publication, rework in the same session and approval of the exact new commit.
157
+ - `bun run test:real:flowgraph` → 2 passed. Flowgraph remains experimental and these results are not a native-release dependency.
158
+ - Release version logic → unit tests cover stable/prerelease dist-tags, malformed tags, tag/package/runtime mismatches, existing versions, missing packages and registry/authentication errors. The `next` dist-tag was confirmed for the prerelease; `latest` remains reserved for stable versions.
159
+ - GitHub Actions workflow files → parsed as valid YAML with the expected jobs and steps. Full `actionlint` validation was not available in the release environment.
160
+ - Real npm publication and OIDC trusted-publishing validation → not performed; npm was not published, tagged or released from this environment.
161
+ - Real disposable GitHub repository suite → not run; no explicitly authorized disposable repository was provided.
162
+ - Interactive TUI verification → not performed in this environment.
163
+
164
+ These results do not claim successful real npm publishing, OIDC bootstrap validation, real GitHub mutation or interactive TUI verification.
@@ -0,0 +1,120 @@
1
+ # Security
2
+
3
+ Taskfeed treats the local developer environment, repository configuration, OpenCode agents and provider credentials as trusted. It treats GitHub issues, comments, linked PR text, attachments and repository content as untrusted input.
4
+
5
+ ## Trust boundaries
6
+
7
+ | Trusted | Untrusted |
8
+ |---|---|
9
+ | `.taskfeed/config.yaml` in the canonical checkout | Issue titles, bodies, comments, attachments |
10
+ | OpenCode agent definitions, models, permissions | PR descriptions and external review text |
11
+ | The installed plugin and Flowgraph workflow source | Files created/changed by an automated agent |
12
+ | Explicitly configured enqueue/approval GitHub accounts | A ready label by itself |
13
+
14
+ Configuration, agents and Flowgraph workflows are resolved from the canonical checkout. A worktree cannot silently alter scheduler permissions or trusted configuration for subsequent steps. Flowgraph workflow hashes at the worktree must match the canonical validated workflow.
15
+
16
+ Before a worktree location is activated, Taskfeed hashes project-controlled executable policy (`opencode.json`, `opencode.jsonc` and `.opencode/**`) and compares it with the canonical checkout. Canonical agent definitions are pinned in the worktree through OpenCode's supported agent transform, and effective agent/plugin snapshots are rechecked at execution boundaries. A changed definition, added agent/plugin, changed local plugin source or changed executable policy fails closed.
17
+
18
+ This is not an OS sandbox. It prevents Taskfeed from admitting a worktree whose policy already differs and pins agents once the trusted location is active, but it cannot revoke plugin code loaded earlier in the process or enforce policy inside every Flowgraph node. Flowgraph's public API has no per-node policy admission hook; that remains an upstream requirement. See [Known limitations](#known-limitations).
19
+
20
+ ## Authorization
21
+
22
+ ### Enqueue
23
+
24
+ A ready label is only a scheduling signal. Taskfeed reads the GitHub issue timeline and requires the **latest active** application of every configured ready label to have been made by an account in `enqueue_users`. Removing a label withdraws the active application; reapplying it by an unauthorized account invalidates the signal. The current issue labels and timeline are revalidated immediately before the durable job is created, not trusted from the discovery result. The resulting actor, label names, event IDs and timestamps are persisted as admission evidence.
25
+
26
+ After admission, Taskfeed consumes the ready label and reloads context without requiring it again. Authorization provenance survives restart and rework. Queued work is withdrawn if eligibility disappears; admitted work is blocked if the issue closes or context identity changes. Ordinary issue updates are not new execution authorization.
27
+
28
+ ### Approval
29
+
30
+ Only `authorized_users` can decide gates. Commands must match the current gate ID, revision, repository, issue, job and captured reviewed SHA. Stale, duplicate, malformed, pre-gate and edited/replayed decisions are rejected. Natural language is never an approval.
31
+
32
+ Commit-based review requires Taskfeed to fetch the current pull request from GitHub and verify:
33
+
34
+ 1. the PR still exists and is open and a draft;
35
+ 2. the gate's recorded `commitSHA`, the current worktree HEAD and the current GitHub PR head SHA are identical;
36
+ 3. the gate's recorded local and remote SHAs are identical.
37
+
38
+ The accepted decision records the exact reviewed PR head SHA. Immediately before forwarding an approval/continuation to an executor (or finalizing a native approval), Taskfeed re-fetches the PR and worktree state and repeats the comparison. Any difference invalidates the gate and blocks the job; a new review is required. Cached linked-PR data is not used for this check.
39
+
40
+ Content-based review instead publishes immutable text as a GitHub issue comment and binds approval to the gate, revision, run and exact content digest. The comment is re-read and hashed before acceptance and forwarding. No PR is required.
41
+
42
+ Approval comments require valid, exactly matching `created_at` and `updated_at` values. Any difference is treated as an edit. Missing, invalid, edited or ambiguous timestamps fail closed. A comment created before the gate and edited into a command is rejected. GitHub REST exposes second precision; an edit within the same second as creation cannot be distinguished from an unedited comment.
43
+
44
+ For decisions persisted while waiting for capacity, Taskfeed rechecks that the original comment still exists with the same author, body and timestamps, that the author remains authorized, and that the gate revision and artifact are still current before forwarding. The decision admission (deterministic request ID, start time and session/run identity) is persisted before the provider side effect. After a crash, restart recovery reconciles the execution instead of releasing capacity or replaying an ambiguous decision.
45
+
46
+ GitHub attributes comments to an account. If ChatGPT and the human share the same authenticated account, GitHub cannot distinguish them. The configuration delegates authority to that account explicitly.
47
+
48
+ ## External side effects
49
+
50
+ - Publication is opt-in.
51
+ - Only Taskfeed-owned branches are pushed.
52
+ - Pushes never use force; non-fast-forward failures block publication.
53
+ - Taskfeed-created pull requests are always drafts. `draft_pull_request: false` is rejected by configuration validation. An existing PR is reused only when it is open, a draft and its head SHA matches the reviewed commit; otherwise publication blocks with an actionable error.
54
+ - Before push, Taskfeed establishes the remote baseline, verifies fast-forward ancestry, enumerates all outgoing commits/newly reachable objects, and scans intermediate file versions, protected/generated paths, symlinks, submodules, sizes, file content and commit messages. Truncated or unsupported scanner output fails closed.
55
+ - The exact validated commit SHA is pushed. Symbolic `HEAD` is never pushed after validation.
56
+ - An existing PR is checked for open/draft/branch/base state before the remote branch is modified.
57
+ - The internal scanner is a conservative denylist, not a replacement for a dedicated secret scanner. See [Known limitations](#known-limitations).
58
+ - Approvals never merge or deploy.
59
+ - Taskfeed does not auto-approve native permissions.
60
+
61
+ ## Native permissions
62
+
63
+ OpenCode's permission rules remain authoritative. Taskfeed adds session-scoped deny rules for external directories and `.taskfeed/**`, but never replies to a permission prompt. A pending permission is a blocker and retains capacity until the user decides it.
64
+
65
+ **Worktrees are not a sandbox.** Shell tools have the host user's filesystem, process and network authority. Prompt instructions are not a security boundary. Prefer explicit OpenCode shell deny/ask policies for unattended execution.
66
+
67
+ ## Prompt injection
68
+
69
+ Issue content is delimited and labeled untrusted, but prompt boundaries are not a security mechanism. The real controls are:
70
+
71
+ - no issue-controlled configuration;
72
+ - no automatic permission approval;
73
+ - canonical-only policy provenance;
74
+ - explicit enqueue/approval allowlists;
75
+ - isolated worktrees and session restrictions;
76
+ - no automatic merge/deploy.
77
+
78
+ ## Credentials
79
+
80
+ - GitHub operations reuse the `gh` CLI authentication.
81
+ - Git operations reuse the user's existing Git credentials.
82
+ - Taskfeed does not read provider API keys or instantiate a separate model client.
83
+ - Logs redact common token formats.
84
+ - GitHub comments never include local environment variables or provider credentials.
85
+
86
+ ## Filesystem
87
+
88
+ - Config must be a regular file under the canonical `.taskfeed` directory; symlinks are rejected.
89
+ - Worktree paths are checked against OpenCode's worktree inventory.
90
+ - Cleanup refuses the canonical checkout, dirty worktrees, and branches not owned by Taskfeed.
91
+ - Publication validates the exact remote head SHA.
92
+ - External content never becomes a shell command string: `gh`/`git` calls use argument arrays.
93
+
94
+ ## Recovery and idempotency
95
+
96
+ An unprovable admission or outcome is blocked, not replayed. Capacity is retained for ambiguous executions. This prioritizes avoiding duplicate side effects and secret/data loss over automatic progress.
97
+
98
+ Native prompt submission uses a deterministic `msg_`-prefixed message ID through OpenCode's supported session prompt `id` field. OpenCode rejects a conflicting durable message ID. Taskfeed treats that conflict as an already-accepted prompt only when the existing message metadata identifies the same job, attempt and prompt kind; otherwise it fails closed. Session recovery requires metadata for the exact job and attempt, at the exact worktree. There is no fallback that adopts the only available session.
99
+
100
+ Flowgraph worker requests carry an expiry, scheduler generation, trusted-context snapshot and response ID. The worker claims one request with a local file lease. After trust verification it re-reads the request and cancellation tombstone, reads the live scheduler generation and verifies the actual scheduler lease file, checks its claim, and validates job/attempt/run identity plus the reserved capacity slot. A durable admission record distinguishes pre-admission cancellation from an already in-flight operation. Flowgraph's deterministic `requestID` remains the provider-level idempotency boundary after admission.
101
+
102
+ ## Local coordination and fencing
103
+
104
+ Scheduler leases and capacity slots are local files under `XDG_RUNTIME_DIR` (or the OS temp directory). Lock acquisition is atomic (`mkdir`), stale takeover and release are serialized by a short-lived breaker directory, and heartbeat uses an open file descriptor so a former owner cannot refresh a replacement lease. Every lock and capacity mutation checks its token and generation; capacity adoption increments the generation. These mechanisms prevent former-owner writes in the supported local boundary, but filesystem coordination is not a consensus protocol and a process paused beyond a stale/breaker window can still lose ownership.
105
+
106
+ Taskfeed verifies leadership immediately before dispatch, prompt submission, approval forwarding, workflow observation and publication. Losing ownership stops new side effects. This is single-machine coordination for one local OpenCode server/user; it is not cross-host consensus and does not claim exactly-once execution.
107
+
108
+ ## Known limitations
109
+
110
+ - Approval edit detection is limited by GitHub REST second precision. An edit in the same second as creation is indistinguishable from an unedited comment.
111
+ - Worktrees are not a sandbox. The agent runs with the host user's authority, and a malicious plugin loaded before Taskfeed cannot be revoked by later detection.
112
+ - Flowgraph nodes are executed by Flowgraph. Taskfeed verifies policy before location activation and at start/respond/observation boundaries, but the public Flowgraph API has no per-node policy admission hook.
113
+ - Flowgraph's current public `human_input` blocker does not expose typed content artifacts. Plan-only external review therefore remains blocked until the upstream contract is extended; Taskfeed does not infer artifacts from node names or prose.
114
+ - The internal publication scanner covers common credential markers, private keys, certificates, protected/generated paths, symlinks, submodules and size limits. It does not replace gitleaks/trufflehog or a repository-specific policy.
115
+ - Package plugin integrity relies on the installed package version and plugin manifest; local plugin sources are content-hashed. A compromised package registry or already-running plugin code is outside this boundary.
116
+ - Taskfeed-managed concurrency cannot constrain a developer who starts or resumes work directly in OpenCode outside Taskfeed. Such sessions are reconciled conservatively from provider state; use Taskfeed controls for managed execution.
117
+
118
+ ## Reporting
119
+
120
+ Do not include provider tokens, GitHub tokens, private issue bodies or local absolute paths in security reports. Redact logs before sharing.
@@ -0,0 +1,7 @@
1
+ # Examples
2
+
3
+ - [playground](playground/): complete native workflow for a disposable repository.
4
+ - [native-agent](native-agent/): GitHub issue → existing OpenCode agent → draft PR review.
5
+ - [flowgraph](flowgraph/): experimental GitHub issue → existing Flowgraph workflow → external human gate.
6
+ - [headless](headless/): persistent OpenCode server operation.
7
+ - [approvals](approvals/): authorized reviewer commands and publication expectations.
@@ -0,0 +1,27 @@
1
+ # External review decisions
2
+
3
+ Taskfeed posts a gate to the issue. Only users in `.taskfeed/config.yaml` `approvals.authorized_users` can decide.
4
+
5
+ Approve:
6
+
7
+ ```text
8
+ /taskfeed approve <gate-id> <revision>
9
+ ```
10
+
11
+ Request changes:
12
+
13
+ ```text
14
+ /taskfeed request-changes <gate-id> <revision>
15
+
16
+ Add a regression test and handle the empty-response case.
17
+ ```
18
+
19
+ Flowgraph declared outcomes:
20
+
21
+ ```text
22
+ /taskfeed outcome <gate-id> <revision> <declared-outcome>
23
+ ```
24
+
25
+ The command must be the first line of a comment created after the gate. It is bound to the exact issue, gate, revision and reviewed remote commit SHA. Stale/edited/replayed decisions are rejected.
26
+
27
+ If publication is disabled or failed, Taskfeed blocks external review instead of presenting local-only code as ready.
@@ -0,0 +1,28 @@
1
+ version: 1
2
+ source:
3
+ type: github
4
+ repository: auto
5
+ labels:
6
+ - agent-ready
7
+ execution:
8
+ type: workflow
9
+ name: development
10
+ scheduler:
11
+ enabled: true
12
+ poll_interval_seconds: 60
13
+ concurrency: 1
14
+ workspace:
15
+ isolation: worktree
16
+ limits:
17
+ max_attempts: 2
18
+ max_feedback_iterations: 3
19
+ execution_timeout_seconds: 14400
20
+ retry_backoff_seconds: 30
21
+ approvals:
22
+ provider: github
23
+ authorized_users:
24
+ - alvarolorentedev
25
+ enqueue_users:
26
+ - alvarolorentedev
27
+ publication:
28
+ enabled: false
@@ -0,0 +1,14 @@
1
+ {
2
+ "plugins": [
3
+ {
4
+ "package": "@alvarolorentedev/opencode-taskfeed@0.1.0-alpha.1",
5
+ "options": {
6
+ "globalConcurrency": 1
7
+ }
8
+ },
9
+ "@alvarolorentedev/opencode-flowgraph"
10
+ ],
11
+ "experimental": {
12
+ "location_idle_timeout": false
13
+ }
14
+ }
@@ -0,0 +1,25 @@
1
+ # Headless operation
2
+
3
+ Persistent OpenCode service, no TUI required.
4
+
5
+ ```jsonc title="opencode.jsonc"
6
+ {
7
+ "plugins": ["@alvarolorentedev/opencode-taskfeed@0.1.0-alpha.1"],
8
+ "experimental": {
9
+ "location_idle_timeout": false
10
+ }
11
+ }
12
+ ```
13
+
14
+ ```sh
15
+ opencode serve
16
+ ```
17
+
18
+ Activate the repository location once:
19
+
20
+ ```sh
21
+ opencode api POST /api/session \
22
+ --data '{"location":{"directory":"/absolute/path/to/repo"}}'
23
+ ```
24
+
25
+ A session only activates the location; it does not need a prompt or model call. Taskfeed's scheduler runs in the server without a TUI. If you use Flowgraph, install/configure it globally or commit the plugin config so worktree locations can load it.
@@ -0,0 +1,21 @@
1
+ version: 1
2
+ source:
3
+ type: github
4
+ repository: owner/repository
5
+ labels:
6
+ - agent-ready
7
+ execution:
8
+ type: agent
9
+ name: build
10
+ scheduler:
11
+ enabled: false
12
+ poll_interval_seconds: 60
13
+ concurrency: 1
14
+ approvals:
15
+ provider: github
16
+ authorized_users:
17
+ - your-login
18
+ enqueue_users:
19
+ - your-login
20
+ publication:
21
+ enabled: false
@@ -0,0 +1,31 @@
1
+ version: 1
2
+ source:
3
+ type: github
4
+ repository: auto
5
+ labels:
6
+ - agent-ready
7
+ execution:
8
+ type: agent
9
+ name: build
10
+ scheduler:
11
+ enabled: true
12
+ poll_interval_seconds: 60
13
+ concurrency: 1
14
+ workspace:
15
+ isolation: worktree
16
+ limits:
17
+ max_attempts: 2
18
+ max_feedback_iterations: 3
19
+ execution_timeout_seconds: 14400
20
+ retry_backoff_seconds: 30
21
+ approvals:
22
+ provider: github
23
+ authorized_users:
24
+ - alvarolorentedev
25
+ enqueue_users:
26
+ - alvarolorentedev
27
+ publication:
28
+ enabled: true
29
+ remote: origin
30
+ draft_pull_request: true
31
+ branch_prefix: taskfeed/
@@ -0,0 +1,10 @@
1
+ {
2
+ "plugins": [
3
+ {
4
+ "package": "@alvarolorentedev/opencode-taskfeed@0.1.0-alpha.1",
5
+ "options": {
6
+ "globalConcurrency": 1
7
+ }
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,61 @@
1
+ # Playground
2
+
3
+ A complete native workflow example for a disposable GitHub repository.
4
+
5
+ 1. Copy `config.yaml` to `.taskfeed/config.yaml` in the disposable repository.
6
+ 2. Replace `your-github-login` with the GitHub account that will authorize and
7
+ approve work.
8
+ 3. Copy `opencode.jsonc` to the repository root, or install the same package
9
+ version globally.
10
+ 4. Create or use an existing native OpenCode `build` agent.
11
+ 5. Authenticate `gh` for the disposable repository and start OpenCode in the
12
+ canonical checkout.
13
+
14
+ The committed example keeps automation and publication disabled. Enable them
15
+ only after the repository, identities and agent are correct:
16
+
17
+ ```yaml
18
+ scheduler:
19
+ enabled: true
20
+
21
+ publication:
22
+ enabled: true
23
+ ```
24
+
25
+ Global execution capacity defaults to one and `scheduler.concurrency` is also
26
+ one, so this example runs one job at a time.
27
+
28
+ ## Minimal first test
29
+
30
+ ```sh
31
+ gh issue create \
32
+ --repo your-account/your-disposable-repo \
33
+ --title "Clarify the README" \
34
+ --body "Add one sentence explaining how to run the project."
35
+
36
+ gh issue edit <number> \
37
+ --repo your-account/your-disposable-repo \
38
+ --add-label agent-ready
39
+ ```
40
+
41
+ Use an enqueue user from `approvals.enqueue_users` to apply the label. Taskfeed
42
+ verifies the actor and label event before creating a job, consumes the label,
43
+ creates an isolated worktree, runs the `build` agent, and expects the agent to
44
+ commit and leave the worktree clean.
45
+
46
+ With publication enabled, Taskfeed pushes only its Taskfeed branch and opens a
47
+ draft pull request, then posts a review gate on the issue. Review the draft PR,
48
+ then request rework or approve:
49
+
50
+ ```text
51
+ /taskfeed request-changes <gate-id> <revision>
52
+
53
+ Add the missing example.
54
+ ```
55
+
56
+ ```text
57
+ /taskfeed approve <gate-id> <revision>
58
+ ```
59
+
60
+ Only configured `authorized_users` are accepted. Approval is bound to the exact
61
+ reviewed commit. Taskfeed never merges the PR.