Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions core/daglang/daglang-driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ pub fn compile_from_module_graph_with_options(
mut module_graph: ModuleGraph,
options: CompileOptions,
) -> Result<CompileOutput, CompileError> {
include_profile_modules(&mut module_graph, &context.roots, options.profile.is_some())?;
include_profile_modules(
&mut module_graph,
&context.roots,
options.profile.as_deref(),
)?;
let callable_scope_result = callable_scope_for_context(context, &module_graph)?;
let (callable_scope, entry_module_name) = match callable_scope_result {
Some((scope, entry)) => (Some(scope), Some(entry)),
Expand Down Expand Up @@ -1092,7 +1096,7 @@ fn discover_target_module_graph_for_context(
fn include_profile_modules(
module_graph: &mut ModuleGraph,
roots: &[PathBuf],
include_bound_services: bool,
active_profile: Option<&str>,
) -> Result<(), CompileError> {
let mut seed_files = Vec::<PathBuf>::new();
for root in roots {
Expand All @@ -1110,7 +1114,7 @@ fn include_profile_modules(
return Ok(());
}

if include_bound_services {
if active_profile.is_some() {
let canonical_roots = daglang_resolve::canonicalize_roots(roots);
let mut implementation_modules = Vec::<PathBuf>::new();
for profile_file in &seed_files {
Expand All @@ -1120,6 +1124,12 @@ fn include_profile_modules(
let Item::ProfileDef(def) = &item.node else {
continue;
};
// Only include implementation modules for the active profile,
// not all profiles. This avoids loading transport-incomplete
// providers that aren't used by the active profile.
if active_profile != Some(def.name.as_str()) {
Comment thread
briansrls marked this conversation as resolved.
Resolved
continue;
}
for bind in &def.binds {
if let Some(path) = resolve_profile_bind_implementation_module_path(
roots,
Expand Down
28 changes: 23 additions & 5 deletions core/daglang/daglang-lower/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ enum ProfileConfigValue {

fn collect_profile_binding_registry(
project: &TypedProject,
require_implementation_resolution: bool,
active_profile: Option<&str>,
) -> Result<ProfileBindingRegistry, LowerError> {
let mut interface_registry = NameAliasRegistry::default();
let mut service_registry = NameAliasRegistry::default();
Expand Down Expand Up @@ -986,7 +986,10 @@ fn collect_profile_binding_registry(
})
}
NameResolution::Missing => {
if require_implementation_resolution {
// Only require implementation resolution for the active profile.
// Non-active profiles may reference modules that weren't loaded.
let is_active = active_profile == Some(def.name.as_str());
if is_active {
return Err(LowerError::InvalidProfileBinding {
profile: profile_full.clone(),
detail: format!(
Expand Down Expand Up @@ -1992,7 +1995,7 @@ fn lower_typed_project_with_callable_scope(
entry_module,
&data_values,
);
let profile_registry = collect_profile_binding_registry(project, active_profile.is_some())?;
let profile_registry = collect_profile_binding_registry(project, active_profile)?;
let active_profile_bindings =
resolve_active_profile_bindings(&profile_registry, active_profile)?;
let profile_bound_interfaces = collect_profile_bound_interface_names(&profile_registry);
Expand Down Expand Up @@ -5012,6 +5015,10 @@ fn derive_service_call_metadata(
Some(TransportBinding::Shell { .. }) => ServiceTransportClass::ShellLocal,
Some(TransportBinding::File { .. }) => ServiceTransportClass::FileBoundary,
Some(TransportBinding::Local) => ServiceTransportClass::LocalDirect,
// Services implementing interfaces that have no transport block get
// InterfaceStub transport. This allows stub providers (unit_test profile)
// to compile without explicit transport declarations.
None if service.implements.is_some() => ServiceTransportClass::InterfaceStub,
None => ServiceTransportClass::Unknown,
};
let mut permissions = operation.permissions.clone();
Expand Down Expand Up @@ -5144,6 +5151,17 @@ fn derive_operation_spec(
ServiceTransportClass::LocalDirect => {
Some(ServiceOperationSpec::Local(derive_local_spec(operation)))
}
ServiceTransportClass::InterfaceStub => {
// Services implementing interfaces with no transport block.
// Use the service name as the interface name (from `: InterfaceName` syntax).
Some(ServiceOperationSpec::InterfaceStub {
interface: service
.implements
.clone()
.unwrap_or_else(|| service.name.clone()),
capability: operation.name.clone(),
})
}
_ => None,
}
}
Expand Down Expand Up @@ -5615,12 +5633,12 @@ fn collect_required_service_call_keys(

fn service_prepare_ports(operation: &OperationDef, metadata: &ServiceCallMetadata) -> Vec<Port> {
let declared_inputs = match metadata.spec.as_ref() {
Some(spec) => spec
Some(spec) if !spec.input_fields().is_empty() => spec
.input_fields()
.iter()
.map(|field| (field.name.clone(), field.type_id.clone()))
.collect::<Vec<_>>(),
None => operation
_ => operation
.inputs
.iter()
.map(|field| {
Expand Down
8 changes: 8 additions & 0 deletions dsl/services/github/issues.dag
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import interfaces.issue_provider { IssueProvider, IssueEvent }
import std.types { TrackedIssue, IssueState, IssueLifecycleStage, NonEmptyStr, Url }

service github.Issues : IssueProvider {
config { endpoint: "https://api.github.com", auth: BearerToken }

// --- Core CRUD ---------------------------------------------------------

Expand All @@ -36,6 +37,7 @@ service github.Issues : IssueProvider {
output {
issue: TrackedIssue from "."
}
transport rest { method: POST, path: "/repos/\{owner\}/\{repo\}/issues" }
}

operation get {
Expand All @@ -46,6 +48,7 @@ service github.Issues : IssueProvider {
issue: TrackedIssue from "."
found: Bool from "status == 200"
}
transport rest { method: GET, path: "/repos/\{owner\}/\{repo\}/issues/\{id\}" }
}

operation close {
Expand All @@ -55,6 +58,7 @@ service github.Issues : IssueProvider {
output {
ok: Bool from "state == \"closed\""
}
transport rest { method: PATCH, path: "/repos/\{owner\}/\{repo\}/issues/\{id\}" }
}

// --- Comments ----------------------------------------------------------
Expand All @@ -71,6 +75,7 @@ service github.Issues : IssueProvider {
comment_id: NonEmptyStr from "id"
ok: Bool from "id != 0"
}
transport rest { method: POST, path: "/repos/\{owner\}/\{repo\}/issues/\{id\}/comments" }
}

// --- Labels (lifecycle stage transitions) ------------------------------
Expand All @@ -86,6 +91,7 @@ service github.Issues : IssueProvider {
output {
ok: Bool from "status == 200"
}
transport rest { method: PUT, path: "/repos/\{owner\}/\{repo\}/issues/\{id\}/labels" }
}

// --- Listing (for polling / batch processing) --------------------------
Expand All @@ -98,6 +104,7 @@ service github.Issues : IssueProvider {
output {
issues: List<TrackedIssue>
}
transport rest { method: GET, path: "/repos/\{owner\}/\{repo\}/issues" }
}

operation list_events {
Expand All @@ -108,6 +115,7 @@ service github.Issues : IssueProvider {
output {
events: List<IssueEvent>
}
transport rest { method: GET, path: "/repos/\{owner\}/\{repo\}/issues/\{id\}/events" }
}
}

Expand Down
8 changes: 8 additions & 0 deletions dsl/services/github/pull_request.dag
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
module services.github.pull_request

service github.PullRequest {
config { endpoint: "https://api.github.com", auth: BearerToken }

operation Create {
input {
Expand All @@ -28,6 +29,7 @@ service github.PullRequest {
node_id: String from "node_id"
head_sha: String from "head.sha"
}
transport rest { method: POST, path: "/repos/\{owner\}/\{repo\}/pulls" }
}

operation Get {
Expand All @@ -47,6 +49,7 @@ service github.PullRequest {
mergeable: Bool? from "mergeable"
merged: Bool from "merged"
}
transport rest { method: GET, path: "/repos/\{owner\}/\{repo\}/pulls/\{number\}" }
}

operation AddComment {
Expand All @@ -60,6 +63,7 @@ service github.PullRequest {
id: Int from "id"
url: String from "html_url"
}
transport rest { method: POST, path: "/repos/\{owner\}/\{repo\}/issues/\{number\}/comments" }
}

operation Merge {
Expand All @@ -76,6 +80,7 @@ service github.PullRequest {
sha: String from "sha"
message: String from "message"
}
transport rest { method: PUT, path: "/repos/\{owner\}/\{repo\}/pulls/\{number\}/merge" }
}

operation ListFiles {
Expand All @@ -88,6 +93,7 @@ service github.PullRequest {
output {
files: Json
}
transport rest { method: GET, path: "/repos/\{owner\}/\{repo\}/pulls/\{number\}/files" }
}

operation RequestReview {
Expand All @@ -101,6 +107,7 @@ service github.PullRequest {
output {
url: String from "html_url"
}
transport rest { method: POST, path: "/repos/\{owner\}/\{repo\}/pulls/\{number\}/requested_reviewers" }
}

operation ListReviews {
Expand All @@ -112,6 +119,7 @@ service github.PullRequest {
output {
reviews: Json
}
transport rest { method: GET, path: "/repos/\{owner\}/\{repo\}/pulls/\{number\}/reviews" }
}
}

Expand Down
3 changes: 3 additions & 0 deletions dsl/services/llm/openai.dag
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
module services.llm.openai

service llm.OpenAI {
config { endpoint: "https://api.openai.com", auth: BearerToken }

operation ChatCompletion {
input {
Expand All @@ -21,6 +22,7 @@ service llm.OpenAI {
prompt_tokens: Int from "usage/prompt_tokens"
completion_tokens: Int from "usage/completion_tokens"
}
transport rest { method: POST, path: "/v1/chat/completions" }
}

operation Responses {
Expand All @@ -36,6 +38,7 @@ service llm.OpenAI {
output_tokens: Int from "usage/output_tokens"
input_tokens: Int from "usage/input_tokens"
}
transport rest { method: POST, path: "/v1/responses" }
}
}

Expand Down
4 changes: 4 additions & 0 deletions dsl/services/sdlc/providers/codex_agent_provider.dag
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,24 @@ service codex.AgentProvider : AgentProvider {
status: AgentStatus
started: Bool
}
transport shell { argv: ["codex", "--model", "\{model\}", "--approval-mode", "\{approval_mode\}", "-C", "\{repo_path\}", "\{prompt\}"] }
Comment thread
briansrls marked this conversation as resolved.
Resolved
}

operation poll {
input { run_id: NonEmptyStr }
output { status: AgentStatus, finished: Bool, exit_code: Int?, error: String? }
transport shell { argv: ["codex", "status", "\{run_id\}"] }
}

operation cancel {
input { run_id: NonEmptyStr, reason: String? }
output { cancelled: Bool, final_status: AgentStatus }
transport shell { argv: ["codex", "cancel", "\{run_id\}"] }
}

operation get_result {
input { run_id: NonEmptyStr }
output { status: AgentStatus, exit_code: Int?, stdout: String?, stderr: String?, files_changed: List<String> }
transport shell { argv: ["codex", "result", "\{run_id\}"] }
}
}
3 changes: 3 additions & 0 deletions dsl/services/sdlc/providers/file_claim_store.dag
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ service file.ClaimStore : ClaimStore {
conflict: Bool
lease_generation: Int
}
transport file { op: WRITE, path: "\{dir\}/claims/\{issue_id\}/\{stage\}.json" }
}

operation heartbeat {
Expand All @@ -54,6 +55,7 @@ service file.ClaimStore : ClaimStore {
generation: Int
}
output { accepted: Bool }
transport file { op: WRITE, path: "\{dir\}/claims/\{issue_id\}/\{stage\}.json" }
}

operation release {
Expand All @@ -64,6 +66,7 @@ service file.ClaimStore : ClaimStore {
generation: Int
}
output { released: Bool }
transport file { op: DELETE, path: "\{dir\}/claims/\{issue_id\}/\{stage\}.json" }
}
}

Expand Down
3 changes: 3 additions & 0 deletions dsl/services/sdlc/providers/file_outcome_ledger.dag
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ service file.OutcomeLedger : OutcomeLedger {
updated: Bool
previous: StageOutcome?
}
transport file { op: WRITE, path: "\{dir\}/outcomes/\{run_key\}/\{stage\}.json" }
}

operation get {
Expand All @@ -52,11 +53,13 @@ service file.OutcomeLedger : OutcomeLedger {
found: Bool
outcome: StageOutcome?
}
transport file { op: READ, path: "\{dir\}/outcomes/\{run_key\}/\{stage\}.json" }
}

operation list_by_issue {
input { issue_id: NonEmptyStr }
output { outcomes: List<StageOutcome> }
transport file { op: READ, path: "\{dir\}/outcomes/\{issue_id\}/" }
}
}

Expand Down
Loading
Loading