Skip to content

agent: implement post tasks #103

Open
emilyalbini wants to merge 7 commits intoea-ptqwnqpswsuvfrom
ea-post
Open

agent: implement post tasks #103
emilyalbini wants to merge 7 commits intoea-ptqwnqpswsuvfrom
ea-post

Conversation

@emilyalbini
Copy link
Copy Markdown
Member

Note: This PR is stacked on top of #102.


This PR implements "post tasks", commands that can be executed after all tasks are completed, depending on the outcome of those tasks. Post tasks can be defined at runtime with the new bmat post family of commands:

bmat post success TASK_NAME COMMAND ARG1 ARG2...
bmat post failure TASK_NAME COMMAND ARG1 ARG2...
bmat post always TASK_NAME COMMAND ARG1 ARG2...

Whether to execute success or failure post tasks is decided when the last task is finished: if we are executing success post tasks, a failure in one of them will mark the build as failed, but it will not start executing failure post tasks.

@emilyalbini emilyalbini requested a review from jclulow April 20, 2026 11:33
Copy link
Copy Markdown
Collaborator

@jclulow jclulow left a comment

Choose a reason for hiding this comment

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

I like the direction! I've made some notes.

Comment thread variety/basic/www/live.js Outdated
Comment thread variety/basic/www/live.js Outdated
Comment on lines +73 to +79
if (LAST_SECTION === null) {
LAST_SECTION = evr.section;
/*
* Due to JavaScript being JavaScript, apparently this is the way to compare
* two objects :(
*/
} else if (JSON.stringify(evr.section) !== JSON.stringify(LAST_SECTION)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the indentation here is not quite right here? Lines should come in with hard tabs (which are 8 columns per tab stop) and then 4 additional spaces if it's a continuation of a previous line.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed that, and changed the editorconfig to mention using tabs for JS files.

Comment thread variety/basic/www/style.css Outdated
}

tr.s_post {
background-color: #ffd7ef;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pretty! Might be good to provide s_post_stdout and s_post_stderr as well, using different shades, to make them more visually distinct from primary job tasks?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added some very light shades of pink for the background of post tasks stdout and stderr.

Comment thread agent/src/control/mod.rs Outdated
Comment thread agent/src/control/mod.rs Outdated
Comment thread agent/src/control/mod.rs Outdated
Comment thread agent/src/main.rs
"cannot register more than {QUOTA_POST_TASKS_PER_TYPE} post tasks"
));
}
if queue.iter().any(|p| p.name == task.name) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I feel like we ought, also, to restrict the allowed characters and also the length for post (and background task) names; e.g., no embedded spaces or periods, only visible alphanumeric/hyphen/underscore things, up to 32 characters, etc.

We would then also want to put similar restrictions on stream names in general, I think, up in the server API, where they could be enforced even if someone messes with the agent. I don't know that we sanitise or cap the stream name length today.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added validation for post tasks and background jobs! Also opened #104 to implement validation in the server.

@emilyalbini emilyalbini force-pushed the ea-xsxwxqsvylmq branch 2 times, most recently from 83cd528 to 7fbcbb2 Compare May 4, 2026 09:17
Base automatically changed from ea-xsxwxqsvylmq to main May 4, 2026 09:40
@emilyalbini emilyalbini changed the base branch from main to ea-ptqwnqpswsuv May 4, 2026 09:42
@emilyalbini emilyalbini force-pushed the ea-post branch 5 times, most recently from 9a07f85 to 9afccf4 Compare May 4, 2026 11:40
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.

2 participants