feat(matrix): MatrixEngine pipeline + system/user prompt split#36
feat(matrix): MatrixEngine pipeline + system/user prompt split#36shlokchorge wants to merge 16 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new MatrixEngine pipeline for generating milestone timelines via Claude, and splits the prompt into a fixed system prompt (rules/schema) plus a per-request user message (goal parameters). It also adds a new ConvexApiHelper.sendMessageToClaude(systemPrompt, userMessage, ...) overload intended to support the split.
Changes:
- Added
MatrixEngineto build prompts, call Claude viaConvexApiHelper, parse JSON milestones with fallbacks, and persist results toMatrixStorage. - Added
MatrixPromptsto centralize the system/user prompt templates for timeline generation. - Added a
ConvexApiHelperoverload to send system + user fields separately.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| app/src/main/java/com/example/iaso/matrix/MatrixPrompts.java | Adds system/user prompt constants for Matrix timeline generation. |
| app/src/main/java/com/example/iaso/matrix/MatrixEngine.java | Implements the milestone generation pipeline, parsing, and persistence into Matrix storage/snapshot. |
| app/src/main/java/com/example/iaso/ConvexApiHelper.java | Adds an overload intended to send system + user prompts separately to Convex/Claude. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Validate day sum — soft fix: redistribute remainder into last milestone | ||
| int sum = 0; | ||
| for (MatrixMilestone m : milestones) sum += m.getAllocatedDays(); | ||
| if (sum != totalDays) { | ||
| Log.w(TAG, "Day sum mismatch: expected " + totalDays + ", got " + sum); | ||
| MatrixMilestone last = milestones.get(milestones.size() - 1); | ||
| last.setAllocatedDays(Math.max(1, last.getAllocatedDays() + (totalDays - sum))); | ||
| } |
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Implemented in commit e1e5aec: day-sum overflow is now handled explicitly by reducing allocatedDays across milestones from the end (never below 1), recomputing startDay values after normalization, and returning an error if exact normalization to totalDays is impossible.
| JSONObject argsObject = new JSONObject(); | ||
| argsObject.put("systemPrompt", systemPrompt); | ||
| argsObject.put("userMessage", userMessage); | ||
|
|
||
| JSONObject requestJson = new JSONObject(); | ||
| requestJson.put("path", CONVEX_ACTION_PATH); | ||
| requestJson.put("args", argsObject); | ||
|
|
There was a problem hiding this comment.
@copilot apply changes based on this feedback
There was a problem hiding this comment.
Implemented in commit 45d9eda: the Matrix path now uses an explicit overload sendMessageToClaude(systemPrompt, userMessage, dailyMinutes, totalDays, ...) that sends Convex args as { messages, context } (phase=generating) to match workhorse:getClaudeResponse. The 3-arg overload remains for compatibility and delegates to the new one.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/openspace-inc/OpenSpace/sessions/5feba14b-fa98-4c8e-a695-06906f047ed3 Co-authored-by: shlokchorge <224512884+shlokchorge@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/openspace-inc/OpenSpace/sessions/c366579a-c32c-4480-92c8-f46f945b16f3 Co-authored-by: shlokchorge <224512884+shlokchorge@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot review is there any error |
Agent-Logs-Url: https://github.com/openspace-inc/OpenSpace/sessions/19d0b5fa-446e-4a03-98a3-5cb25c8cc2bf Co-authored-by: shlokchorge <224512884+shlokchorge@users.noreply.github.com>
Agent-Logs-Url: https://github.com/openspace-inc/OpenSpace/sessions/19d0b5fa-446e-4a03-98a3-5cb25c8cc2bf Co-authored-by: shlokchorge <224512884+shlokchorge@users.noreply.github.com>
|
@copilot review |
Agent-Logs-Url: https://github.com/openspace-inc/OpenSpace/sessions/19d0b5fa-446e-4a03-98a3-5cb25c8cc2bf Co-authored-by: shlokchorge <224512884+shlokchorge@users.noreply.github.com>
Agent-Logs-Url: https://github.com/openspace-inc/OpenSpace/sessions/19d0b5fa-446e-4a03-98a3-5cb25c8cc2bf Co-authored-by: shlokchorge <224512884+shlokchorge@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Reviewed the latest branch state: I don’t see a new code error in the Matrix/Convex changes. Latest completed workflow run on
I reviewed again at HEAD |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| /** | ||
| * MatrixEngine entry point for the current Convex action contract. | ||
| * Sends only the user message plus timeline context derived from that message. | ||
| */ | ||
| public void sendMessageToClaude( | ||
| String userMessage, | ||
| ClaudeResponseCallback callback) { | ||
| int dailyMinutes = extractFirstInt(userMessage, DAILY_TIME_PATTERN, DEFAULT_DAILY_MINUTES, "dailyMinutes"); | ||
| int totalDays = extractFirstInt(userMessage, TOTAL_DAYS_PATTERN, DEFAULT_TOTAL_DAYS, "totalDays"); | ||
| sendMessageToClaude(userMessage, dailyMinutes, totalDays, callback); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/openspace-inc/OpenSpace/sessions/d2364f56-6741-4d48-b160-253ec0c8a9e1 Co-authored-by: shlokchorge <224512884+shlokchorge@users.noreply.github.com>
Applied the thread feedback in commit Fixes included: removed duplicate No UI changes in this update. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Added MatrixEngine pipeline for milestone generation.
Split the Claude prompt into system and user parts so instructions
go to the system field and goal data goes to the user field.
Also added a new overload in ConvexApiHelper to support this.
Old method is untouched so nothing else breaks.