harness exec#73
Draft
shwetamurali wants to merge 4 commits into
Draft
Conversation
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.
Description
Adds
tfctl harness exec [--allow-delete=CLASSES] -- <command>which is a human-authorized, session-scoped, auto-reverting permission that lets nestedtfctlinvocations perform noninteractive HCP Terraform DELETEs (e.g. for a coding agent or CI script).By default,
tfctl api -X DELETErequires an interactive confirmation.harness execlets a human deliberately opt in, per session, to allow specific resource classes to be deleted without a prompt. The grant is tied to the lifetime of the wrapping process and auto-reverts to the safe default the moment the child exits.This is a safety rail, not a security boundary: the child runs as the same OS user, so a true guarantee must come from the API token scope server-side. The mechanism is engineered for ephemerality, liveness, and deliberate human opt-in.
How it works
harness execwrites a short-lived session file (~/.config/tfctl/exec/<token>.hcl, mode0600) recording the granted classes + creator PID, takes an exclusive lock, and setsTFCTL_EXEC_SESSION=<token>in the child's environment.tfctl apiresolves the resource class from the path and consults the session: it must exist, be live, and the requesting process must be a descendant of the session creator (ancestry walk) so a leaked env var can't re-authorize an unrelated process.Permission model
--allow-deleteis repeatable and accepts comma-separated values.reversible/allcover any reversible class but never cover the irreversible classesorganizationsandprojectsmust always be named explicitly (--allow-delete=projects).harness exec --allow-delete=<class>command to authorize, or the-X DELETEcommand to run interactively.Testing
execsession,harness exec, and theapiDELETE gate (including a fakeAuthorizer).0600session file; the file is removed on exit;--dry-runcreates no session and prints the would-do message.Example Output
Example
Authorized session: a human wraps the agent; nested deletes for the granted classes succeed without a prompt, and the grant disappears when the child exits:
Default (no session): noninteractive deletes are refused with a self-documenting message:
Irreversible classes are never covered by wildcards: even inside a session granting
all, deleting a project requires an explicit grant:Dry run evaluates the gate but creates no session and sends no request:
PR Checklist
npx changie newor install changie to prepare a new changelog entry for the next set of release notes.--json— Force machine readable output to stdout. Does not apply to stderr.--markdown— Force markdown output to stdout. Does not apply to stderr.--dry-run— Don't make any actual writes or other mutations. Describe what would have changed to stderr.--quiet— Don't render output to stdout.make gen/screenshotif the root command output changes.Autocompletefield to positional arguments and flags to assist shell autocomplete.PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.