Skip to content

feat(matrix): MatrixEngine pipeline + system/user prompt split#36

Open
shlokchorge wants to merge 16 commits into
mainfrom
ticket-kan-16
Open

feat(matrix): MatrixEngine pipeline + system/user prompt split#36
shlokchorge wants to merge 16 commits into
mainfrom
ticket-kan-16

Conversation

@shlokchorge

Copy link
Copy Markdown
Collaborator

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.

Copilot AI review requested due to automatic review settings May 8, 2026 09:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 MatrixEngine to build prompts, call Claude via ConvexApiHelper, parse JSON milestones with fallbacks, and persist results to MatrixStorage.
  • Added MatrixPrompts to centralize the system/user prompt templates for timeline generation.
  • Added a ConvexApiHelper overload 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.

Comment thread app/src/main/java/com/example/iaso/matrix/MatrixPrompts.java Outdated
Comment on lines +66 to +73
// 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)));
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread app/src/main/java/com/example/iaso/matrix/MatrixEngine.java Outdated
Comment thread app/src/main/java/com/example/iaso/matrix/MatrixEngine.java Outdated
Comment thread app/src/main/java/com/example/iaso/matrix/MatrixEngine.java
Comment thread app/src/main/java/com/example/iaso/ConvexApiHelper.java Outdated
Comment on lines +113 to +120
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);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread app/src/main/java/com/example/iaso/matrix/MatrixEngine.java
shlokchorge and others added 4 commits May 8, 2026 15:24
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>

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

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:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/gradle-launcher-8.7.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/agents/gradle-instrumentation-agent-8.7.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.7 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

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:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/gradle-launcher-8.7.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/agents/gradle-instrumentation-agent-8.7.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.7 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@shlokchorge

Copy link
Copy Markdown
Collaborator Author

@copilot review is there any error

Copilot AI and others added 2 commits May 8, 2026 10:48
@shlokchorge

Copy link
Copy Markdown
Collaborator Author

@copilot review

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

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:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/gradle-launcher-8.7.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/agents/gradle-instrumentation-agent-8.7.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.7 (dns block)
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/gradle-launcher-8.7.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/agents/gradle-instrumentation-agent-8.7.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.7 /OpenSpace Space (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

@copilot review is there any error

Reviewed the latest branch state: I don’t see a new code error in the Matrix/Convex changes. Latest completed workflow run on ticket-kan-16 is green (25551378591), and current new runs are still in progress. Current head reviewed: 45d9eda.

@copilot review

I reviewed again at HEAD 45d9eda: no additional actionable code issue found in the addressed threads. CI: last completed run is successful, and the newest runs are still in progress.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread app/src/main/java/com/example/iaso/ConvexApiHelper.java Outdated
Comment thread app/src/main/java/com/example/iaso/matrix/MatrixEngine.java
Comment thread app/src/main/java/com/example/iaso/matrix/MatrixEngine.java
shlokchorge and others added 2 commits May 8, 2026 16:31
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Comment on lines +112 to +121
/**
* 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);
Comment thread app/src/main/java/com/example/iaso/ConvexApiHelper.java
Comment thread app/src/main/java/com/example/iaso/matrix/MatrixEngine.java
Comment thread app/src/main/java/com/example/iaso/matrix/MatrixEngine.java
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@shlokchorge

Copy link
Copy Markdown
Collaborator Author

@copilot apply changes based on the comments in this thread

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

Applied the thread feedback in commit fa0717e.

Fixes included: removed duplicate sendMessageToClaude(String, callback) signature conflict, restored explicit systemPrompt + userMessage + dailyMinutes + totalDays overload usage in MatrixEngine, added missing ArrayList import, and updated Convex action args to accept optional systemPrompt and pass it through so Matrix JSON instructions can take effect.

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:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/gradle-launcher-8.7.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.7-bin/bhs2wmbdwecv87pi65oeuq5iu/gradle-8.7/lib/agents/gradle-instrumentation-agent-8.7.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.7 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread convex/workhorse.ts
Comment thread app/src/main/java/com/example/iaso/ConvexApiHelper.java
Comment thread app/src/main/java/com/example/iaso/ConvexApiHelper.java Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

3 participants