Skip to content

feat(ingestion): auto-extract awaiting-reply tasks from outbound emails#303

Open
castor-agent wants to merge 4 commits into
mainfrom
fix/issue-176-awaiting-reply-task
Open

feat(ingestion): auto-extract awaiting-reply tasks from outbound emails#303
castor-agent wants to merge 4 commits into
mainfrom
fix/issue-176-awaiting-reply-task

Conversation

@castor-agent
Copy link
Copy Markdown
Collaborator

Fixes #176

Summary

  • Adds a new derived_entities declarative field to SchemaDefinition so schemas can express rules for auto-creating linked entities during ingestion — no hardcoded if (entityType === "email") branches.
  • Implements schema_derived_entity_extraction.ts with pure-function condition evaluation (evaluateCondition), field resolution (resolveDerivedField), and the async extractDerivedEntities orchestrator that re-uses storeStructuredForApi for uniform store semantics and creates a REFERS_TO relationship back to the source entity.
  • Wires the hook into storeStructuredForApi post-store path (non-fatal; failures are logged and skipped).
  • Seeds the email schema with a derived_entities rule: when direction = "outbound" and body contains any pending-reply signal (?, please let me know, looking forward to hearing, please reply, awaiting your response, let me know, your thoughts, waiting to hear), creates a task with task_type: "awaiting_reply", status: "pending", due_context: "reply expected", title "Awaiting reply: {{subject}}".
  • Adds direction field to email schema and task_type/due_context fields to task schema.
  • Updates MCP instructions fenced block to document auto-extraction behavior.
  • 41 new unit tests (pure-function and schema-rule coverage); test catalog regenerated.

Test plan

  • npm run type-check passes
  • npm test passes (41 new unit tests in tests/unit/schema_derived_entity_extraction.test.ts)
  • Store an email entity with direction: "outbound" and a body containing ? — verify a linked awaiting_reply task is auto-created
  • Store an email entity with direction: "outbound" and a neutral body — verify no task is created
  • Store an email entity with direction: "inbound" and a question body — verify no task is created

🤖 Generated with Claude Code

castor-agent and others added 4 commits May 19, 2026 17:43
…rule (#194)

Add a session-start instruction that retrieves the issue_filing_consent
preference entity at startup and caches it for the session. When the stored
value is "always", the effective reporting mode is set to proactive and the
agent MUST file issues without asking. Values "ask" and "never" map to
consent and off respectively. The preference overrides issues.reporting_mode
from config and env for the duration of the session.

Also update the proactive mode contract to explicitly list
issue_filing_consent value "always" as a trigger alongside the CLI config and
env var paths, replacing the obsolete future auto_file_issues forward
reference. Update QA-driven issue filing to check for the stored preference
entity before prompting the user.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements POST /issues/import endpoint and `neotoma issues import
--from-jsonl <file>` CLI command for observer batch ingestion of issues
from JSONL files exported from other systems.

- openapi.yaml: new POST /issues/import endpoint (operationId: importIssuesFromJsonl)
- src/shared/openapi_types.ts: regenerated from updated spec
- src/shared/action_schemas.ts: IssuesImportFromJsonlRequestSchema (Zod)
- src/services/issues/import_from_jsonl.ts: new service; parses JSONL,
  builds deterministic idempotency keys, stores each issue entity
- src/actions.ts: handleIssuesImportFromJsonlHttp handler + routes
- src/tool_definitions.ts: import_issues_from_jsonl MCP tool
- src/shared/contract_mappings.ts: importIssuesFromJsonl row + MCP map entry
- src/cli/issues.ts: issuesImport function + IssuesImportOpts interface
- src/cli/index.ts: `issues import --from-jsonl <file>` subcommand
- scripts/security/protected_routes_manifest.json: regenerated (109 routes)

Fixes #271

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds optional `conversation_turn_id` to `submit_issue` (MCP tool,
HTTP POST /issues/submit, and IssuesSubmitRequestSchema). When provided,
the server creates a REFERS_TO edge from the filed issue entity to the
specified conversation_message entity so the origin of the issue is
directly traceable without a separate create_relationship call.

Changes:
- openapi.yaml: add `conversation_turn_id` field to issuesSubmit requestBody
- src/shared/openapi_types.ts: regenerated
- src/services/issues/types.ts: add `conversation_turn_id` to IssueCreateParams
- src/shared/action_schemas.ts: add field to IssuesSubmitRequestSchema
- src/services/issues/issue_operations.ts: merge conversation_turn_id into
  the allTargetIds list fed to createRelationships alongside entity_ids_to_link
- src/server.ts: parse and forward conversation_turn_id in MCP handler
- src/actions.ts: forward conversation_turn_id in HTTP handler
- src/tool_definitions.ts: expose conversation_turn_id param on submit_issue tool
- docs/developer/mcp/instructions.md: note that agents SHOULD pass
  conversation_turn_id when the current turn entity ID is known

Fixes #192

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements #176.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

Claude finished @castor-agent's task —— View job


PR Review In Progress

  • Read docs/developer/pr_review_reading_list.md
  • Read always-read docs
  • Read conditional docs (ingestion, schema_registry, schema, contracts, mcp, cli, security, record_types, testing)
  • Review PR diff against constraints
  • Post review feedback

Job run · Branch: fix/issue-176-awaiting-reply-task

@castor-agent
Copy link
Copy Markdown
Collaborator Author

@claude review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

Claude finished @castor-agent's task —— View job


PR Review In Progress

  • Read docs/developer/pr_review_reading_list.md
  • Read always-read docs (in-progress; reading remaining ones)
  • Read conditional docs (ingestion, schema_registry, schema, contracts, mcp, cli, security, record_types, testing)
  • Review PR diff against constraints
  • Post review feedback

Job run · Branch: fix/issue-176-awaiting-reply-task

@castor-agent
Copy link
Copy Markdown
Collaborator Author

/create_pr skill audit

Automated audit against the /create_pr skill (Neotoma plan ent_8cde942847555a83253dfe5b), which defines the standard PR description structure (Problems / Solutions / UX improvements / Documentation / Test plan / Breaking changes), the pre-PR checklist from .claude/rules/change_guardrails_rules.md, and the functional-change documentation gate (docs entry + docs/site/site_doc_manifest.yaml + docs server surfacing).

Verdict: does not fully meet standards. Gaps below; recommended changes follow each item.

Findings

  • Title is 71 chars (>70 limit).
  • Missing required sections: Problems, Solutions, UX improvements, Documentation, Breaking changes.
  • Breaking changes section MUST be present, even for non-breaking PRs (write No breaking changes.).
  • PR body does not confirm the doc is reachable via the docs server (src/services/docs/) or list the specific docs/...md path under the Documentation section.

Recommended changes

Update the PR description to match the skill template exactly:

## Problems
- <Concrete pain point or gap.>

## Solutions
- <Concrete change made.>

## UX improvements
- <User-visible behavior change, or `No user-visible change.`>

## Documentation
- <docs/... path(s) added or updated; parameters/outputs/examples/error modes covered.>
- <`docs/site/site_doc_manifest.yaml` entry added/updated; docs service tests pass.>
- <Or: `No functional change; no user-facing docs required.`>

## Test plan
- [ ] `npm run type-check`
- [ ] `npm test`
- [ ] `npm test -- src/services/docs` (if docs changed)
- [ ] Manual verification: <steps>

## Breaking changes
No breaking changes.

## Related
- Plan: <Neotoma plan entity_id or docs/ path>
- Issue(s): <#N>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Functional surfaces detected from the diff: CLI, HTTP, MCP, Schema. Per the skill, the Documentation section must point at a real docs/...md path covering parameters, outputs, at least one example, and error modes, and the doc must be listed in docs/site/site_doc_manifest.yaml so it is surfaced by the docs server and docs site.

Posted by /create_pr skill audit run. See .claude/skills/create_pr/SKILL.md for the full template.

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.

Add 'awaiting reply' task extraction rule for outbound emails with no response yet in inbox

1 participant